Skip to content

Commit 5b22994

Browse files
authored
Merge pull request #1987 from andrew-johnson-4/gradual-patch-lib2-without-gc-dfisiisi
Gradual patch lib2 without gc dfisiisi
2 parents b7bc759 + e1d2d83 commit 5b22994

28 files changed

Lines changed: 3075 additions & 3044 deletions

BOOTSTRAP/cli.c

Lines changed: 2613 additions & 2607 deletions
Large diffs are not rendered by default.

LM23COMMON/typecheck-infer-type-definition.lsts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

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

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

8484
let case-number = 0_u64;
8585
for vector Tuple{ case-tag2=first, case-fields=second } in cases {
86-
complex-type-index = complex-type-index.bind( lhs-type.ground-tag-and-arity, 1_u64 );
86+
complex-type-index = complex-type-index.bind( lhs-type.ground-tag-and-arity, true );
8787
datatype-index = datatype-index.bind( lhs-type.ground-tag-and-arity, true );
8888
let field-ordinal = 0_u64;
8989
for vector Tuple{ field-name3=first, field-type=second } in case-fields {

LM23COMMON/unit-main-core.lsts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ let main(argc: C_int, argv: CString[]): Nil = (
6161
argi = argi + 1;
6262
config-target = argv[argi];
6363
);
64-
fp => (
65-
if plugins-backends-index.has(fp) {
66-
plugin-current-backend = plugins-backends-index.lookup(fp,&plugin-null-backend);
67-
} else { input = cons(fp, input); };
64+
fp1 => (
65+
if plugins-backends-index.has(fp1) {
66+
plugin-current-backend = plugins-backends-index.lookup(fp1,&plugin-null-backend);
67+
} else { input = cons(fp1, input); };
6868
);
6969
};
7070
argi = argi + 1;
@@ -77,22 +77,22 @@ let main(argc: C_int, argv: CString[]): Nil = (
7777
} else {
7878
print("{");
7979
let first-outer = true;
80-
for list fp in input {
80+
for list fp2 in input {
8181
if first-outer {
8282
first-outer = false;
8383
} else {
8484
print(",\n");
8585
};
86-
print-toks-json(fp);
86+
print-toks-json(fp2);
8787
};
8888
print("\n}\n");
8989
};
9090
);
9191
ModeParse{} => (
92-
for list fp in input.reverse { frontend(fp); };
92+
for list fp3 in input.reverse { frontend(fp3); };
9393
);
9494
_ => (
95-
for list fp in input.reverse { frontend(fp); };
95+
for list fp4 in input.reverse { frontend(fp4); };
9696
match config-mode {
9797
ModeTypecheck{} => (preprocess(); typecheck(););
9898
ModeCompile{} => (preprocess(); typecheck(); plugin-current-backend(); );

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CC = clang
22
CFLAGS = -w -O2 -march=native -mtune=native
33

44
dev: install-production
5-
time lm --v23 tests/promises/lm-ascript/ascript-integrated.lsts
5+
time lm --v2 tests/promises/lm-ascript/ascript-integrated.lsts
66
gcc tmp.c
77
./a.out
88

PLUGINS/BACKEND/C/blob-render.lsts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@ let blob-render-simple(ctx: FContext, context-key: CString, term: AST): (FContex
44
match term {
55
ASTNil{} => ();
66
ASTEOF{} => ();
7-
Var{key=key} => r = ctx.lookup(key, typeof-term(term), term).get(context-key);
8-
Lit{key=key} => r = SAtom(key);
7+
Var{key1=key} => r = ctx.lookup(key1, typeof-term(term), term).get(context-key);
8+
Lit{key2=key} => r = SAtom(key2);
99
App{ left:Lit{key:c":"}, right:App{ t=left, right:AType{tt=tt} } } => r = blob-render-simple(ctx, context-key, t).second;
1010
App{ left:Lit{key:c"as"}, right:App{ t=left, right:AType{tt=tt} } } => r = blob-render-simple(ctx, context-key, t).second;
1111
App{ left:Lit{key:c"scope"}, t=right } => r = blob-render-simple(ctx, context-key, t).second;
1212
App{
1313
left:App{ left:Lit{key:c":"}, right:App{ left:Lit{key:c"for-arg"}, right:AType{} } },
1414
right:App{
1515
left:App{
16-
left:Abs{ lhs-t=lhs:Var{lhs=key}, rhs:ASTNil{} },
16+
left:Abs{ lhs-t=lhs:Var{lhs1=key}, rhs:ASTNil{} },
1717
right:App{ left:Var{key:c"for-arg-i"}, right:Var{vsk=key} }
1818
}, iter=right
1919
}
2020
} => (
2121
let vs = ctx.lookup-soft(vsk, ta, mk-eof());
2222
for list vi in vs.vararg {
2323
std-c-fragment-context = std-c-fragment-context.bind(lhs-t, vi);
24-
let inner-ctx = ctx.bind(lhs, vs.type, vi);
24+
let inner-ctx = ctx.bind(lhs1, vs.type, vi);
2525
r = r + blob-render-simple(inner-ctx, context-key, iter).second;
2626
};
2727
);
2828
App{
2929
left:App{ left:Lit{key:c":"}, right:App{ left:Lit{key:c"for-atom"}, right:AType{} } },
3030
right:App{
3131
left:App{
32-
left:Abs{ lhs-t=lhs:Var{lhs=key}, rhs:ASTNil{} },
32+
left:Abs{ lhs-t=lhs:Var{lhs2=key}, rhs:ASTNil{} },
3333
rng=right
3434
}, iter=right
3535
}
@@ -38,7 +38,7 @@ let blob-render-simple(ctx: FContext, context-key: CString, term: AST): (FContex
3838
while non-zero(rngs) { match rngs {
3939
SCons{ a=left, rst=right } => (
4040
let f = mk-expression(a);
41-
let inner-ctx = ctx.bind(lhs, t0(c"L"), f);
41+
let inner-ctx = ctx.bind(lhs2, t0(c"L"), f);
4242
std-c-fragment-context = std-c-fragment-context.bind(lhs-t,f);
4343
r = r + blob-render-simple(inner-ctx, context-key, iter).second;
4444
rngs = rst;
@@ -62,10 +62,10 @@ let blob-render-simple(ctx: FContext, context-key: CString, term: AST): (FContex
6262
r = std-c-mangle-declaration-internal(tt.l1.normalize.rewrite-opaque-type-alias.without-any-phi, term).first;
6363
);
6464
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;
65-
App{ left:Abs{ lhs-t=lhs:Var{lhs=key}, rhs:ASTNil{}, tlt=tt }, rhs=right } => (
65+
App{ left:Abs{ lhs-t=lhs:Var{lhs3=key}, rhs:ASTNil{}, tlt=tt }, rhs=right } => (
6666
let s = blob-render-simple(ctx, context-key, rhs).second;
6767
let f = mk-fragment().set(context-key,s).set(c"expression",s);
68-
ctx = ctx.bind(lhs, typeof-term(rhs), f);
68+
ctx = ctx.bind(lhs3, typeof-term(rhs), f);
6969
std-c-fragment-context = std-c-fragment-context.bind(lhs-t, f);
7070
);
7171
App{ f=left, a=right } => (
@@ -95,16 +95,16 @@ let blob-render-simple(ctx: FContext, context-key: CString, term: AST): (FContex
9595
let blob-render(ctx: FContext, term: AST, f: Fragment): Fragment = (
9696
match term {
9797
App{ left:Lit{key:c":"}, right:App{ t=left, right:AType{} } } => blob-render(ctx, t, f);
98-
App{ left:Var{k=key}, a=right } => (
99-
if k.has-prefix(c":")
100-
then f.set(tail(k), blob-render-simple(ctx, tail(k), a).second)
101-
else f.set(c"expression", blob-render-simple(ctx, tail(k), a).second)
98+
App{ left:Var{k1=key}, a=right } => (
99+
if k1.has-prefix(c":")
100+
then f.set(tail(k1), blob-render-simple(ctx, tail(k1), a).second)
101+
else f.set(c"expression", blob-render-simple(ctx, tail(k1), a).second)
102102
);
103-
App{ rst=left, right:App{ left:Var{k=key}, a=right } } => (
103+
App{ rst=left, right:App{ left:Var{k2=key}, a=right } } => (
104104
f = blob-render(ctx, rst, f);
105-
if k.has-prefix(c":")
106-
then f.set(tail(k), blob-render-simple(ctx, tail(k), a).second)
107-
else f.set(c"expression", blob-render-simple(ctx, tail(k), a).second)
105+
if k2.has-prefix(c":")
106+
then f.set(tail(k2), blob-render-simple(ctx, tail(k2), a).second)
107+
else f.set(c"expression", blob-render-simple(ctx, tail(k2), a).second)
108108
);
109109
_ => f.set(c"expression", blob-render-simple(ctx,c"expression",term).second);
110110
}

PLUGINS/BACKEND/C/escape-as-cstring.lsts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
let .escape-as-cstring(in: CString): S = (
33
let out = (SNil());
44
while non-zero(in) { match in {
5-
c"\"".. rest => (out = out + SAtom(c"\\\\\""); in = rest;);
6-
c"\\:".. rest => (out = out + SAtom(c";"); in = rest;);
7-
c"\\[".. rest => (out = out + SAtom(c"("); in = rest;);
8-
c"\\]".. rest => (out = out + SAtom(c")"); in = rest;);
9-
c"\\\\".. rest => (out = out + SAtom(c"\\\\\\\\"); in = rest;);
10-
c"\\`".. rest => (out = out + SAtom(c"'"); in = rest;);
11-
c"\\l".. rest => (out = out + SAtom(c"λ"); in = rest;);
12-
c"\\n".. rest => (out = out + SAtom(c"\\\\n"); in = rest;);
13-
c"\\o".. rest => (out = out + SAtom(c"#"); in = rest;);
14-
c"\\s".. rest => (out = out + SAtom(c" "); in = rest;);
15-
c"\\t".. rest => (out = out + SAtom(c"\\\\t"); in = rest;);
16-
c"\\".. rest => fail("Illegal Escape Character: \{head(rest)}");
17-
rest => (
18-
out = out + SAtom(clone-rope(head(rest)));
19-
in = tail(rest);
5+
c"\"".. rest1 => (out = out + SAtom(c"\\\\\""); in = rest1;);
6+
c"\\:".. rest2 => (out = out + SAtom(c";"); in = rest2;);
7+
c"\\[".. rest3 => (out = out + SAtom(c"("); in = rest3;);
8+
c"\\]".. rest4 => (out = out + SAtom(c")"); in = rest4;);
9+
c"\\\\".. rest5 => (out = out + SAtom(c"\\\\\\\\"); in = rest5;);
10+
c"\\`".. rest6 => (out = out + SAtom(c"'"); in = rest6;);
11+
c"\\l".. rest7 => (out = out + SAtom(c"λ"); in = rest7;);
12+
c"\\n".. rest8 => (out = out + SAtom(c"\\\\n"); in = rest8;);
13+
c"\\o".. rest9 => (out = out + SAtom(c"#"); in = rest9;);
14+
c"\\s".. rest10 => (out = out + SAtom(c" "); in = rest10;);
15+
c"\\t".. rest11 => (out = out + SAtom(c"\\\\t"); in = rest11;);
16+
c"\\".. rest12 => fail("Illegal Escape Character: \{head(rest12)}");
17+
rest13 => (
18+
out = out + SAtom(clone-rope(head(rest13)));
19+
in = tail(rest13);
2020
);
2121
}};
2222
SAtom(c"\"") + out + SAtom(c"\"")

PLUGINS/BACKEND/C/escape-string.lsts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
let escape-string(s: CString): CString = (
33
let e = SNil;
4-
while head(s) {
4+
while head(s) != 0 {
55
if head(s) == 92 {
66
s = tail(s);
77
match head(s) {
@@ -27,7 +27,7 @@ let escape-string(s: CString): CString = (
2727

2828
let escape-string(s: S): S = (
2929
match s {
30-
SAtom{atom=atom} => SAtom(escape-string(atom));
30+
SAtom{atom=atom} => SAtom(escape-string(atom.into(type(CString))));
3131
SCons{left=left, right=right} => escape-string(left) + escape-string(right);
3232
_ => SNil;
3333
}

PLUGINS/BACKEND/C/std-c-compile-args.lsts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs: AST, f: Fragment): Tuple<Fragment,FContext,FContext> = (
44
match lhs {
5-
App{lhs-rst=left, right:App{ left:Lit{key:c":"}, right:App{left-lhs=left:Var{k=key}, right:AType{kt=tt}} }} => (
5+
App{lhs-rst=left, right:App{ left:Lit{key:c":"}, right:App{left-lhs=left:Var{k1=key}, right:AType{kt=tt}} }} => (
66
if typeof-term(rhs).is-t(c"Cons",2) {
77
match rhs {
88
App{le=left, re=right} => (
@@ -12,7 +12,7 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
1212
if kt.is-open { callee-ctx = union(callee-ctx, unify(kt, typeof-term(re), rhs)); };
1313
let c1 = std-c-compile-expr(caller-ctx, re, false);
1414
caller-ctx = open(c1.context);
15-
callee-ctx = bind-vararg(callee-ctx, k, kt, c1);
15+
callee-ctx = bind-vararg(callee-ctx, k1, kt, c1);
1616
(f, callee-ctx, caller-ctx) = std-c-compile-args(callee-ctx, caller-ctx, lhs, le, f);
1717
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
1818
} else {
@@ -22,7 +22,7 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
2222
if kt.is-open { callee-ctx = union(callee-ctx, unify(kt, typeof-term(re), rhs)); };
2323
let c1 = std-c-compile-expr(caller-ctx, re, false);
2424
caller-ctx = open(c1.context);
25-
callee-ctx = callee-ctx.bind(k, kt, c1);
25+
callee-ctx = callee-ctx.bind(k1, kt, c1);
2626
std-c-fragment-context = std-c-fragment-context.bind( left-lhs, c1 );
2727
(f, callee-ctx, caller-ctx) = std-c-compile-args(callee-ctx, caller-ctx, lhs-rst, le, f);
2828
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
@@ -37,7 +37,7 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
3737
let c1 = std-c-compile-expr(caller-ctx, rhs, false);
3838
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
3939
caller-ctx = open(c1.context);
40-
callee-ctx = bind-vararg(callee-ctx, k, kt, c1);
40+
callee-ctx = bind-vararg(callee-ctx, k1, kt, c1);
4141
} else {
4242
(f, callee-ctx, caller-ctx) = std-c-compile-args(callee-ctx, caller-ctx, lhs-rst, rhs, f);
4343
}
@@ -46,13 +46,13 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
4646
let c1 = std-c-compile-expr(caller-ctx, rhs, false);
4747
caller-ctx = open(c1.context);
4848
std-c-fragment-context = std-c-fragment-context.bind( left-lhs, c1 );
49-
callee-ctx = callee-ctx.bind(k, kt, c1);
49+
callee-ctx = callee-ctx.bind(k1, kt, c1);
5050
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
5151
}
5252
};
5353
(f, callee-ctx, caller-ctx)
5454
);
55-
App{ left:Lit{key:c":"}, right:App{left-lhs=left:Var{k=key}, right:AType{kt=tt}} } => (
55+
App{ left:Lit{key:c":"}, right:App{left-lhs=left:Var{k2=key}, right:AType{kt=tt}} } => (
5656
if typeof-term(rhs).is-t(c"Cons",2) {
5757
match rhs {
5858
App{le=left, re=right} => (
@@ -61,7 +61,7 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
6161
if kt.is-open { callee-ctx = union(callee-ctx, unify(kt, typeof-term(re), rhs)); };
6262
let c1 = std-c-compile-expr(caller-ctx, re, false);
6363
caller-ctx = open(c1.context);
64-
callee-ctx = bind-vararg(callee-ctx, k, kt, c1);
64+
callee-ctx = bind-vararg(callee-ctx, k2, kt, c1);
6565
(f, callee-ctx, caller-ctx) = std-c-compile-args(callee-ctx, caller-ctx, lhs, le, f);
6666
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
6767
} else {
@@ -76,7 +76,7 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
7676
if kt.is-open { callee-ctx = union(callee-ctx, unify(kt, typeof-term(rhs), rhs)); };
7777
let c1 = std-c-compile-expr(caller-ctx, rhs, false);
7878
caller-ctx = open(c1.context);
79-
callee-ctx = bind-vararg(callee-ctx, k, kt, c1);
79+
callee-ctx = bind-vararg(callee-ctx, k2, kt, c1);
8080
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
8181
} else {
8282
(f, callee-ctx, caller-ctx) = std-c-compile-args(callee-ctx, caller-ctx, lhs, rhs, f);
@@ -86,7 +86,7 @@ let std-c-compile-args(callee-ctx: FContext, caller-ctx: FContext, lhs: AST, rhs
8686
let c1 = std-c-compile-expr(caller-ctx, rhs, false);
8787
caller-ctx = open(c1.context);
8888
std-c-fragment-context = std-c-fragment-context.bind( left-lhs, c1 );
89-
callee-ctx = callee-ctx.bind(k, kt, c1);
89+
callee-ctx = callee-ctx.bind(k2, kt, c1);
9090
f = f.set(c"frame", f.get(c"frame") + c1.get(c"frame"));
9191
}
9292
};

PLUGINS/BACKEND/C/std-c-compile-call.lsts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let std-c-compile-call(ctx: FContext, fname: CString, args: AST): Fragment = std
33

44
let std-c-compile-call(ctx: FContext, fname: CString, return-hint-if-constructor: Type, args: AST): Fragment = (
55
let fterm = Some(mk-tctx()).maybe-find-callable(fname, typeof-term(args), args, return-hint-if-constructor)
6-
.expect("std-c-compile-call Function \{fname} was null\nArguments: \{typeof-term(args)}, Return Hint \{return-hint-if-constructor}\n").blame-or-zero;
6+
.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;
77
if typeof-term(fterm).is-t(c"Blob",0) {
88
if typeof-term(fterm).is-open and fname!=c"open" and fname!=c"mov" then {
99
for list tr in Some(mk-tctx()).lookups(fname) {

PLUGINS/BACKEND/C/std-c-compile-destructure-args.lsts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11

22
let std-c-compile-destructure-args(ctx: FContext, lhs: AST, is-fragment: Bool): FContext = (
33
match lhs {
4-
App{ rst=left, right:App{ left:Lit{key:c":"}, right:App{ lhs-v=left:Var{k=key}, right:AType{kt=tt} } } } => (
4+
App{ rst=left, right:App{ left:Lit{key:c":"}, right:App{ lhs-v=left:Var{k1=key}, right:AType{kt=tt} } } } => (
55
ctx = std-c-compile-destructure-args(ctx, rst, is-fragment);
66
if is-fragment then { kt = denormalize(kt); }
77
else { kt = kt.normalize && t0(c"LocalVariable"); };
8-
let fragment = if std-c-is-ctype(kt) then mk-expression(k.replace(c"-",c"_").rewrite-if-reserved) else mk-expression(uuid());
9-
ctx = ctx.bind(k, kt, fragment);
8+
let fragment = if std-c-is-ctype(kt) then mk-expression(k1.replace(c"-",c"_").rewrite-if-reserved) else mk-expression(uuid());
9+
ctx = ctx.bind(k1, kt, fragment);
1010
std-c-fragment-context = std-c-fragment-context.bind(lhs-v, fragment);
1111
);
12-
App{ left:Lit{key:c":"}, right:App{ lhs-v=left:Var{k=key}, right:AType{kt=tt} } } => (
12+
App{ left:Lit{key:c":"}, right:App{ lhs-v=left:Var{k2=key}, right:AType{kt=tt} } } => (
1313
if is-fragment then { kt = denormalize(kt); }
1414
else { kt = kt.normalize && t0(c"LocalVariable"); };
15-
let fragment = if std-c-is-ctype(kt) then mk-expression(k.replace(c"-",c"_").rewrite-if-reserved) else mk-expression(uuid());
16-
ctx = ctx.bind(k, kt, fragment);
15+
let fragment = if std-c-is-ctype(kt) then mk-expression(k2.replace(c"-",c"_").rewrite-if-reserved) else mk-expression(uuid());
16+
ctx = ctx.bind(k2, kt, fragment);
1717
std-c-fragment-context = std-c-fragment-context.bind(lhs-v, fragment);
1818
);
1919
_ => ();

0 commit comments

Comments
 (0)