Skip to content

Commit e9b34d6

Browse files
authored
Merge pull request #1984 from andrew-johnson-4/lib1-zero-init-fdsiiii
Lib1 zero init fdsiiii
2 parents 576ff30 + 508c197 commit e9b34d6

112 files changed

Lines changed: 2789 additions & 6357 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BOOTSTRAP/cli.c

Lines changed: 2604 additions & 2584 deletions
Large diffs are not rendered by default.

LM23COMMON/typecheck-infer-expr.lsts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ let std-infer-call-arg(tctx: TypeContext?, term: AST, function-name: CString, hi
428428
}} else if function-name==c"map::cons" { match term {
429429
App{k=left, m=right} => (
430430
(tctx, let new-k) = std-infer-expr(tctx, k, false, Call(function-name), ta);
431-
let direct-hint = if config-v3
431+
let direct-hint = if config-v3 or config-v23
432432
then t2(c"Hashtable",typeof-term(new-k).normalize.slot(c"Cons",2).l1,typeof-term(new-k).normalize.slot(c"Cons",2).l2) && t0(c"ReturnHint")
433433
else t2(c"HashtableEq",typeof-term(new-k).normalize.slot(c"Cons",2).l1,typeof-term(new-k).normalize.slot(c"Cons",2).l2);
434434
(tctx, let new-m) = std-infer-expr(tctx, m, false, Used(), direct-hint);

LM23COMMON/typecheck-infer-global-terms.lsts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ let infer-global-terms(tctx: TypeContext?, term: AST): (TypeContext?, AST) = (
2525
let kto = typeof-term(rhs);
2626
let ktd = kto && t0(c"GlobalVariable");
2727
tctx = tctx.bind-global(k.key, kto, ktd, term);
28-
mark-global-as-seen(k.key, ktd, ta);
29-
tctx = tctx.ascript(term, ktd);
30-
(tctx, _) = tctx.maybe-apply-callable(c"mov", t2(c"Cons",ktd.without-phi,ktd.without-phi), term);
28+
if not(global-is-seen(k.key, ktd)) {
29+
mark-global-as-seen(k.key, ktd, ta);
30+
tctx = tctx.ascript(term, ktd);
31+
(tctx, _) = tctx.maybe-apply-callable(c"mov", t2(c"Cons",ktd.without-phi,ktd.without-phi), term);
32+
}
3133
);
3234
_ => (
3335
(tctx, term) = std-infer-expr(tctx, term, false, Unused, ta);
@@ -44,10 +46,12 @@ let infer-global-context-prim(term: AST): Nil = (
4446
Glb{ k=key, frhs=val:Abs{lhs=lhs, rhs:App{left:Lit{key:c":"}, right:App{rhs=left, right:AType{return-type=tt}}}, misc-tt=tt} } => (
4547
if k.key.has-prefix(c"primitive::") then {
4648
let ft = t2(c"Arrow", typeof-lhs(lhs), return-type.without-modifiers).without-phi-keep-state && misc-tt;
47-
mark-global-as-seen(k.key, ft, misc-tt);
48-
Some(mk-tctx()).ascript(term, ft);
49-
Some(mk-tctx()).ascript(frhs, ft);
50-
Some(mk-tctx()).bind-global(k.key, ft, ft, term);
49+
if not(global-is-seen(k.key, ft)) {
50+
mark-global-as-seen(k.key, ft, misc-tt);
51+
Some(mk-tctx()).ascript(term, ft);
52+
Some(mk-tctx()).ascript(frhs, ft);
53+
Some(mk-tctx()).bind-global(k.key, ft, ft, term);
54+
}
5155
};
5256
);
5357
_ => ();
@@ -75,10 +79,12 @@ let infer-global-context(term: AST): Nil = (
7579
else if misc-tt.is-t(c"TypedMacro",0) then bind-new-macro(k.key, frhs)
7680
else {
7781
let ft = t2(c"Arrow", typeof-lhs(lhs), return-type.rewrite-type-alias.expand-implied-phi.without-modifiers).without-phi-keep-state && misc-tt;
78-
mark-global-as-seen(k.key, ft, misc-tt);
79-
Some(mk-tctx()).ascript(term, ft);
80-
Some(mk-tctx()).ascript(frhs, ft);
81-
Some(mk-tctx()).bind-global(k.key, ft, denormalize-strong(ft), term);
82+
if not(global-is-seen(k.key, ft)) {
83+
mark-global-as-seen(k.key, ft, misc-tt);
84+
Some(mk-tctx()).ascript(term, ft);
85+
Some(mk-tctx()).ascript(frhs, ft);
86+
Some(mk-tctx()).bind-global(k.key, ft, denormalize-strong(ft), term);
87+
}
8288
};
8389
);
8490
_ => ();

LM23COMMON/unit-main-core.lsts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ let print-toks-json(fp: CString): Nil = (
2929
let show-alloc-count = false;
3030

3131
let main(argc: C_int, argv: CString[]): Nil = (
32+
config-v23 = false;
3233
let argi = 1_sz;
3334
let input = [] : List<CString>;
3435
let highlight = false;
@@ -43,6 +44,7 @@ let main(argc: C_int, argv: CString[]): Nil = (
4344
c"--v0" => (config-v3 = false; config-v0 = true;);
4445
c"--v1" => (config-v3 = false; config-v1 = true;);
4546
c"--v2" => config-v3 = false;
47+
c"--v23" => (config-v3 = false; config-v23 = true;);
4648
c"--v3" => config-v3 = true;
4749
c"--highlight" => (
4850
config-mode = ModeTokenize();

PLUGINS/BACKEND/C/blob-render.lsts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ let blob-render-simple(ctx: FContext, context-key: CString, term: AST): (FContex
5353
let ri = to-i64(clone-rope(rs));
5454
while li < ri {
5555
ri = ri - 1;
56-
r = SCons( close(SAtom(to-string(ri))), close(r) );
56+
r = SCons( close(SAtom(ri.into(type(CString)))), close(r) );
5757
}
5858
);
5959
App{ left:Var{key:c"uuid"} } => r = SAtom(uuid());
@@ -72,7 +72,7 @@ let blob-render-simple(ctx: FContext, context-key: CString, term: AST): (FContex
7272
if typeof-term(f).is-arrow { match f {
7373
Var{fname=key} => (
7474
if fname.has-prefix(c":")
75-
then r = blob-render-simple(ctx, tail-string(fname), a).second
75+
then r = blob-render-simple(ctx, tail(fname), a).second
7676
else r = std-c-compile-call(ctx, fname, a).get(context-key);
7777
);
7878
_ => (
@@ -97,14 +97,14 @@ let blob-render(ctx: FContext, term: AST, f: Fragment): Fragment = (
9797
App{ left:Lit{key:c":"}, right:App{ t=left, right:AType{} } } => blob-render(ctx, t, f);
9898
App{ left:Var{k=key}, a=right } => (
9999
if k.has-prefix(c":")
100-
then f.set(tail-string(k), blob-render-simple(ctx, tail-string(k), a).second)
101-
else f.set(c"expression", blob-render-simple(ctx, tail-string(k), a).second)
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)
102102
);
103103
App{ rst=left, right:App{ left:Var{k=key}, a=right } } => (
104104
f = blob-render(ctx, rst, f);
105105
if k.has-prefix(c":")
106-
then f.set(tail-string(k), blob-render-simple(ctx, tail-string(k), a).second)
107-
else f.set(c"expression", blob-render-simple(ctx, tail-string(k), a).second)
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)
108108
);
109109
_ => f.set(c"expression", blob-render-simple(ctx,c"expression",term).second);
110110
}

PLUGINS/BACKEND/C/compile-program-ordered.lsts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let compile-program-ordered(global-ctx: FContext, program: AST): Nil = (
33
for vector g in program.unroll-seq { match g {
44
Glb{ key=key, val=val } => (
55
if not(typeof-term(def-to-sym(g)).is-open)
6-
|| not(typeof-term(val).is-open) then {
6+
or not(typeof-term(val).is-open) then {
77
std-c-compile-global(global-ctx, key.key, val);
88
};
99
);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ let .escape-as-cstring(in: CString): S = (
1313
c"\\o".. rest => (out = out + SAtom(c"#"); in = rest;);
1414
c"\\s".. rest => (out = out + SAtom(c" "); in = rest;);
1515
c"\\t".. rest => (out = out + SAtom(c"\\\\t"); in = rest;);
16-
c"\\".. rest => fail("Illegal Escape Character: \{head-string(rest)}");
16+
c"\\".. rest => fail("Illegal Escape Character: \{head(rest)}");
1717
rest => (
18-
out = out + SAtom(clone-rope(head-string(rest)));
19-
in = tail-string(rest);
18+
out = out + SAtom(clone-rope(head(rest)));
19+
in = tail(rest);
2020
);
2121
}};
2222
SAtom(c"\"") + out + SAtom(c"\"")

PLUGINS/BACKEND/C/escape-string.lsts

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

22
let escape-string(s: CString): CString = (
33
let e = SNil;
4-
while head-string(s) {
5-
if head-string(s) == 92 {
6-
s = tail-string(s);
7-
match head-string(s) {
4+
while head(s) {
5+
if head(s) == 92 {
6+
s = tail(s);
7+
match head(s) {
88
58 => e = e + SAtom(c";"); # \: -> ;
99
91 => e = e + SAtom(c"("); # \[ -> (
1010
92 => e = e + SAtom(c"\\"); # \\ -> \
@@ -16,10 +16,10 @@ let escape-string(s: CString): CString = (
1616
115 => e = e + SAtom(c" "); # \s -> [space]
1717
c => fail("Illegal Escape Sequence In String: \{c}\n");
1818
};
19-
s = tail-string(s);
19+
s = tail(s);
2020
} else {
21-
e = e + SAtom(clone-rope(head-string(s)));
22-
s = tail-string(s);
21+
e = e + SAtom(clone-rope(head(s)));
22+
s = tail(s);
2323
}
2424
};
2525
clone-rope(e)

PLUGINS/BACKEND/C/mangle-identifier.lsts

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

22
let mangle-identifier(k: CString): S = (
33
let cs = SAtom(c"LM_");
4-
while head-string(k) { match head-string(k) {
4+
while head(k) != 0 { match head(k) {
55
33 => cs = cs + SAtom(c"_EX_"); # !
66
36 => cs = cs + SAtom(c"_DL_"); # $
77
37 => cs = cs + SAtom(c"_MD_"); # %
@@ -28,7 +28,7 @@ let mangle-identifier(k: CString): S = (
2828
124 => cs = cs + SAtom(c"_BR_"); # |
2929
126 => cs = cs + SAtom(c"_TL_"); # ~
3030
c => cs = cs + SAtom(clone-rope(c));
31-
}; k = tail-string(k); };
31+
}; k = tail(k); };
3232
cs
3333
);
3434

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let std-c-compile-call(ctx: FContext, fname: CString, return-hint-if-constructor
2929
exit-error("STD C compile call is open \{fname} (\{typeof-term(args)})\n\{typeof-term(fterm)}\nArgs \{args}\n", args);
3030
};
3131
let push-args = std-c-compile-push-args(ctx, args);
32-
let function-id = if typeof-term(fterm).is-t(c"FFI",0) || typeof-term(fterm).is-t(c"C-FFI",0)
32+
let function-id = if typeof-term(fterm).is-t(c"FFI",0) or typeof-term(fterm).is-t(c"C-FFI",0)
3333
then fname else mangle-identifier-function(fname, typeof-term(fterm));
3434
let ictx = mk-fragment().set(c"function-id", SAtom(function-id));
3535
let inner-ctx = mk-fctx().bind(c"ictx", t0(c"ImplicitContext"), ictx)

0 commit comments

Comments
 (0)