Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,220 changes: 2,613 additions & 2,607 deletions BOOTSTRAP/cli.c

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions LM23COMMON/typecheck-infer-type-definition.lsts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

let type-ast-inserts = mk-vector(type(AST));
let complex-type-index = {} : Hashtable<(CString,U64),U64>;
let complex-type-index = {} : Hashtable<(CString,U64),Bool>;

let visit-field-template(field-name: CString, base-type: Type, field-type: Type, blame: AST, field-ordinal: U64, case-number: U64): Nil = (
let mangled-field-name = case-number.into(type(CString)) + c"_" + field-name;
Expand Down Expand Up @@ -83,7 +83,7 @@ let infer-type-definition(term: AST): Nil = (

let case-number = 0_u64;
for vector Tuple{ case-tag2=first, case-fields=second } in cases {
complex-type-index = complex-type-index.bind( lhs-type.ground-tag-and-arity, 1_u64 );
complex-type-index = complex-type-index.bind( lhs-type.ground-tag-and-arity, true );
datatype-index = datatype-index.bind( lhs-type.ground-tag-and-arity, true );
let field-ordinal = 0_u64;
for vector Tuple{ field-name3=first, field-type=second } in case-fields {
Expand Down
16 changes: 8 additions & 8 deletions LM23COMMON/unit-main-core.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ let main(argc: C_int, argv: CString[]): Nil = (
argi = argi + 1;
config-target = argv[argi];
);
fp => (
if plugins-backends-index.has(fp) {
plugin-current-backend = plugins-backends-index.lookup(fp,&plugin-null-backend);
} else { input = cons(fp, input); };
fp1 => (
if plugins-backends-index.has(fp1) {
plugin-current-backend = plugins-backends-index.lookup(fp1,&plugin-null-backend);
} else { input = cons(fp1, input); };
);
};
argi = argi + 1;
Expand All @@ -77,22 +77,22 @@ let main(argc: C_int, argv: CString[]): Nil = (
} else {
print("{");
let first-outer = true;
for list fp in input {
for list fp2 in input {
if first-outer {
first-outer = false;
} else {
print(",\n");
};
print-toks-json(fp);
print-toks-json(fp2);
};
print("\n}\n");
};
);
ModeParse{} => (
for list fp in input.reverse { frontend(fp); };
for list fp3 in input.reverse { frontend(fp3); };
);
_ => (
for list fp in input.reverse { frontend(fp); };
for list fp4 in input.reverse { frontend(fp4); };
match config-mode {
ModeTypecheck{} => (preprocess(); typecheck(););
ModeCompile{} => (preprocess(); typecheck(); plugin-current-backend(); );
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CC = clang
CFLAGS = -w -O2 -march=native -mtune=native

dev: install-production
time lm --v23 tests/promises/lm-ascript/ascript-integrated.lsts
time lm --v2 tests/promises/lm-ascript/ascript-integrated.lsts
gcc tmp.c
./a.out

Expand Down
32 changes: 16 additions & 16 deletions PLUGINS/BACKEND/C/blob-render.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ let blob-render-simple(ctx: FContext, context-key: CString, term: AST): (FContex
match term {
ASTNil{} => ();
ASTEOF{} => ();
Var{key=key} => r = ctx.lookup(key, typeof-term(term), term).get(context-key);
Lit{key=key} => r = SAtom(key);
Var{key1=key} => r = ctx.lookup(key1, typeof-term(term), term).get(context-key);
Lit{key2=key} => r = SAtom(key2);
App{ left:Lit{key:c":"}, right:App{ t=left, right:AType{tt=tt} } } => r = blob-render-simple(ctx, context-key, t).second;
App{ left:Lit{key:c"as"}, right:App{ t=left, right:AType{tt=tt} } } => r = blob-render-simple(ctx, context-key, t).second;
App{ left:Lit{key:c"scope"}, t=right } => r = blob-render-simple(ctx, context-key, t).second;
App{
left:App{ left:Lit{key:c":"}, right:App{ left:Lit{key:c"for-arg"}, right:AType{} } },
right:App{
left:App{
left:Abs{ lhs-t=lhs:Var{lhs=key}, rhs:ASTNil{} },
left:Abs{ lhs-t=lhs:Var{lhs1=key}, rhs:ASTNil{} },
right:App{ left:Var{key:c"for-arg-i"}, right:Var{vsk=key} }
}, iter=right
}
} => (
let vs = ctx.lookup-soft(vsk, ta, mk-eof());
for list vi in vs.vararg {
std-c-fragment-context = std-c-fragment-context.bind(lhs-t, vi);
let inner-ctx = ctx.bind(lhs, vs.type, vi);
let inner-ctx = ctx.bind(lhs1, vs.type, vi);
r = r + blob-render-simple(inner-ctx, context-key, iter).second;
};
);
App{
left:App{ left:Lit{key:c":"}, right:App{ left:Lit{key:c"for-atom"}, right:AType{} } },
right:App{
left:App{
left:Abs{ lhs-t=lhs:Var{lhs=key}, rhs:ASTNil{} },
left:Abs{ lhs-t=lhs:Var{lhs2=key}, rhs:ASTNil{} },
rng=right
}, iter=right
}
Expand All @@ -38,7 +38,7 @@ let blob-render-simple(ctx: FContext, context-key: CString, term: AST): (FContex
while non-zero(rngs) { match rngs {
SCons{ a=left, rst=right } => (
let f = mk-expression(a);
let inner-ctx = ctx.bind(lhs, t0(c"L"), f);
let inner-ctx = ctx.bind(lhs2, t0(c"L"), f);
std-c-fragment-context = std-c-fragment-context.bind(lhs-t,f);
r = r + blob-render-simple(inner-ctx, context-key, iter).second;
rngs = rst;
Expand All @@ -62,10 +62,10 @@ let blob-render-simple(ctx: FContext, context-key: CString, term: AST): (FContex
r = std-c-mangle-declaration-internal(tt.l1.normalize.rewrite-opaque-type-alias.without-any-phi, term).first;
);
App{ left:Var{key:c"mangle-post"}, right:AType{tt=tt} } => r = std-c-mangle-declaration-internal(tt.l1.normalize.rewrite-opaque-type-alias.without-any-phi, term).second;
App{ left:Abs{ lhs-t=lhs:Var{lhs=key}, rhs:ASTNil{}, tlt=tt }, rhs=right } => (
App{ left:Abs{ lhs-t=lhs:Var{lhs3=key}, rhs:ASTNil{}, tlt=tt }, rhs=right } => (
let s = blob-render-simple(ctx, context-key, rhs).second;
let f = mk-fragment().set(context-key,s).set(c"expression",s);
ctx = ctx.bind(lhs, typeof-term(rhs), f);
ctx = ctx.bind(lhs3, typeof-term(rhs), f);
std-c-fragment-context = std-c-fragment-context.bind(lhs-t, f);
);
App{ f=left, a=right } => (
Expand Down Expand Up @@ -95,16 +95,16 @@ let blob-render-simple(ctx: FContext, context-key: CString, term: AST): (FContex
let blob-render(ctx: FContext, term: AST, f: Fragment): Fragment = (
match term {
App{ left:Lit{key:c":"}, right:App{ t=left, right:AType{} } } => blob-render(ctx, t, f);
App{ left:Var{k=key}, a=right } => (
if k.has-prefix(c":")
then f.set(tail(k), blob-render-simple(ctx, tail(k), a).second)
else f.set(c"expression", blob-render-simple(ctx, tail(k), a).second)
App{ left:Var{k1=key}, a=right } => (
if k1.has-prefix(c":")
then f.set(tail(k1), blob-render-simple(ctx, tail(k1), a).second)
else f.set(c"expression", blob-render-simple(ctx, tail(k1), a).second)
);
App{ rst=left, right:App{ left:Var{k=key}, a=right } } => (
App{ rst=left, right:App{ left:Var{k2=key}, a=right } } => (
f = blob-render(ctx, rst, f);
if k.has-prefix(c":")
then f.set(tail(k), blob-render-simple(ctx, tail(k), a).second)
else f.set(c"expression", blob-render-simple(ctx, tail(k), a).second)
if k2.has-prefix(c":")
then f.set(tail(k2), blob-render-simple(ctx, tail(k2), a).second)
else f.set(c"expression", blob-render-simple(ctx, tail(k2), a).second)
);
_ => f.set(c"expression", blob-render-simple(ctx,c"expression",term).second);
}
Expand Down
30 changes: 15 additions & 15 deletions PLUGINS/BACKEND/C/escape-as-cstring.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
let .escape-as-cstring(in: CString): S = (
let out = (SNil());
while non-zero(in) { match in {
c"\"".. rest => (out = out + SAtom(c"\\\\\""); in = rest;);
c"\\:".. rest => (out = out + SAtom(c";"); in = rest;);
c"\\[".. rest => (out = out + SAtom(c"("); in = rest;);
c"\\]".. rest => (out = out + SAtom(c")"); in = rest;);
c"\\\\".. rest => (out = out + SAtom(c"\\\\\\\\"); in = rest;);
c"\\`".. rest => (out = out + SAtom(c"'"); in = rest;);
c"\\l".. rest => (out = out + SAtom(c"λ"); in = rest;);
c"\\n".. rest => (out = out + SAtom(c"\\\\n"); in = rest;);
c"\\o".. rest => (out = out + SAtom(c"#"); in = rest;);
c"\\s".. rest => (out = out + SAtom(c" "); in = rest;);
c"\\t".. rest => (out = out + SAtom(c"\\\\t"); in = rest;);
c"\\".. rest => fail("Illegal Escape Character: \{head(rest)}");
rest => (
out = out + SAtom(clone-rope(head(rest)));
in = tail(rest);
c"\"".. rest1 => (out = out + SAtom(c"\\\\\""); in = rest1;);
c"\\:".. rest2 => (out = out + SAtom(c";"); in = rest2;);
c"\\[".. rest3 => (out = out + SAtom(c"("); in = rest3;);
c"\\]".. rest4 => (out = out + SAtom(c")"); in = rest4;);
c"\\\\".. rest5 => (out = out + SAtom(c"\\\\\\\\"); in = rest5;);
c"\\`".. rest6 => (out = out + SAtom(c"'"); in = rest6;);
c"\\l".. rest7 => (out = out + SAtom(c"λ"); in = rest7;);
c"\\n".. rest8 => (out = out + SAtom(c"\\\\n"); in = rest8;);
c"\\o".. rest9 => (out = out + SAtom(c"#"); in = rest9;);
c"\\s".. rest10 => (out = out + SAtom(c" "); in = rest10;);
c"\\t".. rest11 => (out = out + SAtom(c"\\\\t"); in = rest11;);
c"\\".. rest12 => fail("Illegal Escape Character: \{head(rest12)}");
rest13 => (
out = out + SAtom(clone-rope(head(rest13)));
in = tail(rest13);
);
}};
SAtom(c"\"") + out + SAtom(c"\"")
Expand Down
4 changes: 2 additions & 2 deletions PLUGINS/BACKEND/C/escape-string.lsts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

let escape-string(s: CString): CString = (
let e = SNil;
while head(s) {
while head(s) != 0 {
if head(s) == 92 {
s = tail(s);
match head(s) {
Expand All @@ -27,7 +27,7 @@ let escape-string(s: CString): CString = (

let escape-string(s: S): S = (
match s {
SAtom{atom=atom} => SAtom(escape-string(atom));
SAtom{atom=atom} => SAtom(escape-string(atom.into(type(CString))));
SCons{left=left, right=right} => escape-string(left) + escape-string(right);
_ => SNil;
}
Expand Down
18 changes: 9 additions & 9 deletions PLUGINS/BACKEND/C/std-c-compile-args.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs: AST, f: Fragment): Tuple<Fragment,FContext,FContext> = (
match lhs {
App{lhs-rst=left, right:App{ left:Lit{key:c":"}, right:App{left-lhs=left:Var{k=key}, right:AType{kt=tt}} }} => (
App{lhs-rst=left, right:App{ left:Lit{key:c":"}, right:App{left-lhs=left:Var{k1=key}, right:AType{kt=tt}} }} => (
if typeof-term(rhs).is-t(c"Cons",2) {
match rhs {
App{le=left, re=right} => (
Expand All @@ -12,7 +12,7 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
if kt.is-open { callee-ctx = union(callee-ctx, unify(kt, typeof-term(re), rhs)); };
let c1 = std-c-compile-expr(caller-ctx, re, false);
caller-ctx = open(c1.context);
callee-ctx = bind-vararg(callee-ctx, k, kt, c1);
callee-ctx = bind-vararg(callee-ctx, k1, kt, c1);
(f, callee-ctx, caller-ctx) = std-c-compile-args(callee-ctx, caller-ctx, lhs, le, f);
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
} else {
Expand All @@ -22,7 +22,7 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
if kt.is-open { callee-ctx = union(callee-ctx, unify(kt, typeof-term(re), rhs)); };
let c1 = std-c-compile-expr(caller-ctx, re, false);
caller-ctx = open(c1.context);
callee-ctx = callee-ctx.bind(k, kt, c1);
callee-ctx = callee-ctx.bind(k1, kt, c1);
std-c-fragment-context = std-c-fragment-context.bind( left-lhs, c1 );
(f, callee-ctx, caller-ctx) = std-c-compile-args(callee-ctx, caller-ctx, lhs-rst, le, f);
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
Expand All @@ -37,7 +37,7 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
let c1 = std-c-compile-expr(caller-ctx, rhs, false);
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
caller-ctx = open(c1.context);
callee-ctx = bind-vararg(callee-ctx, k, kt, c1);
callee-ctx = bind-vararg(callee-ctx, k1, kt, c1);
} else {
(f, callee-ctx, caller-ctx) = std-c-compile-args(callee-ctx, caller-ctx, lhs-rst, rhs, f);
}
Expand All @@ -46,13 +46,13 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
let c1 = std-c-compile-expr(caller-ctx, rhs, false);
caller-ctx = open(c1.context);
std-c-fragment-context = std-c-fragment-context.bind( left-lhs, c1 );
callee-ctx = callee-ctx.bind(k, kt, c1);
callee-ctx = callee-ctx.bind(k1, kt, c1);
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
}
};
(f, callee-ctx, caller-ctx)
);
App{ left:Lit{key:c":"}, right:App{left-lhs=left:Var{k=key}, right:AType{kt=tt}} } => (
App{ left:Lit{key:c":"}, right:App{left-lhs=left:Var{k2=key}, right:AType{kt=tt}} } => (
if typeof-term(rhs).is-t(c"Cons",2) {
match rhs {
App{le=left, re=right} => (
Expand All @@ -61,7 +61,7 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
if kt.is-open { callee-ctx = union(callee-ctx, unify(kt, typeof-term(re), rhs)); };
let c1 = std-c-compile-expr(caller-ctx, re, false);
caller-ctx = open(c1.context);
callee-ctx = bind-vararg(callee-ctx, k, kt, c1);
callee-ctx = bind-vararg(callee-ctx, k2, kt, c1);
(f, callee-ctx, caller-ctx) = std-c-compile-args(callee-ctx, caller-ctx, lhs, le, f);
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
} else {
Expand All @@ -76,7 +76,7 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
if kt.is-open { callee-ctx = union(callee-ctx, unify(kt, typeof-term(rhs), rhs)); };
let c1 = std-c-compile-expr(caller-ctx, rhs, false);
caller-ctx = open(c1.context);
callee-ctx = bind-vararg(callee-ctx, k, kt, c1);
callee-ctx = bind-vararg(callee-ctx, k2, kt, c1);
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
} else {
(f, callee-ctx, caller-ctx) = std-c-compile-args(callee-ctx, caller-ctx, lhs, rhs, f);
Expand All @@ -86,7 +86,7 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
let c1 = std-c-compile-expr(caller-ctx, rhs, false);
caller-ctx = open(c1.context);
std-c-fragment-context = std-c-fragment-context.bind( left-lhs, c1 );
callee-ctx = callee-ctx.bind(k, kt, c1);
callee-ctx = callee-ctx.bind(k2, kt, c1);
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
}
};
Expand Down
2 changes: 1 addition & 1 deletion PLUGINS/BACKEND/C/std-c-compile-call.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let std-c-compile-call(ctx: FContext, fname: CString, args: AST): Fragment = std

let std-c-compile-call(ctx: FContext, fname: CString, return-hint-if-constructor: Type, args: AST): Fragment = (
let fterm = Some(mk-tctx()).maybe-find-callable(fname, typeof-term(args), args, return-hint-if-constructor)
.expect("std-c-compile-call Function \{fname} was null\nArguments: \{typeof-term(args)}, Return Hint \{return-hint-if-constructor}\n").blame-or-zero;
.expect("std-c-compile-call Function \{fname} was null\nArguments: \{typeof-term(args)}, Return Hint \{return-hint-if-constructor}\nAt \{args.location}\n").blame-or-zero;
if typeof-term(fterm).is-t(c"Blob",0) {
if typeof-term(fterm).is-open and fname!=c"open" and fname!=c"mov" then {
for list tr in Some(mk-tctx()).lookups(fname) {
Expand Down
12 changes: 6 additions & 6 deletions PLUGINS/BACKEND/C/std-c-compile-destructure-args.lsts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@

let std-c-compile-destructure-args(ctx: FContext, lhs: AST, is-fragment: Bool): FContext = (
match lhs {
App{ rst=left, right:App{ left:Lit{key:c":"}, right:App{ lhs-v=left:Var{k=key}, right:AType{kt=tt} } } } => (
App{ rst=left, right:App{ left:Lit{key:c":"}, right:App{ lhs-v=left:Var{k1=key}, right:AType{kt=tt} } } } => (
ctx = std-c-compile-destructure-args(ctx, rst, is-fragment);
if is-fragment then { kt = denormalize(kt); }
else { kt = kt.normalize && t0(c"LocalVariable"); };
let fragment = if std-c-is-ctype(kt) then mk-expression(k.replace(c"-",c"_").rewrite-if-reserved) else mk-expression(uuid());
ctx = ctx.bind(k, kt, fragment);
let fragment = if std-c-is-ctype(kt) then mk-expression(k1.replace(c"-",c"_").rewrite-if-reserved) else mk-expression(uuid());
ctx = ctx.bind(k1, kt, fragment);
std-c-fragment-context = std-c-fragment-context.bind(lhs-v, fragment);
);
App{ left:Lit{key:c":"}, right:App{ lhs-v=left:Var{k=key}, right:AType{kt=tt} } } => (
App{ left:Lit{key:c":"}, right:App{ lhs-v=left:Var{k2=key}, right:AType{kt=tt} } } => (
if is-fragment then { kt = denormalize(kt); }
else { kt = kt.normalize && t0(c"LocalVariable"); };
let fragment = if std-c-is-ctype(kt) then mk-expression(k.replace(c"-",c"_").rewrite-if-reserved) else mk-expression(uuid());
ctx = ctx.bind(k, kt, fragment);
let fragment = if std-c-is-ctype(kt) then mk-expression(k2.replace(c"-",c"_").rewrite-if-reserved) else mk-expression(uuid());
ctx = ctx.bind(k2, kt, fragment);
std-c-fragment-context = std-c-fragment-context.bind(lhs-v, fragment);
);
_ => ();
Expand Down
Loading
Loading