Skip to content

Commit 576ff30

Browse files
authored
Merge pull request #1983 from andrew-johnson-4/lib1-lib2-merger-zero-init-fdsjjj
Lib1 lib2 merger zero init fdsjjj
2 parents dcdbcc9 + f42fc54 commit 576ff30

6 files changed

Lines changed: 2607 additions & 2598 deletions

File tree

BOOTSTRAP/cli.c

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

LM23COMMON/typecheck-infer-expr.lsts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ let std-infer-expr(tctx: Maybe<TypeContext>, term: AST, is-scoped: Bool, used: I
334334
tctx = tctx.phi-override(to-tt, from-tt, term);
335335
if from-tt.is-t(c"Phi::Id",1) and from-tt.slot(c"Phi::Id",1).l1.simple-tag != to-tt.slot(c"Phi::Id",1).l1.simple-tag {
336336
tctx = tctx.phi-move(from-tt, term);
337-
}
337+
};
338338
};
339339

340340
rt = tctx.with-phi(rt, term);
@@ -408,6 +408,7 @@ let wrap-call(tctx: TypeContext?, fname: CString, term: AST): (TypeContext?, AST
408408
);
409409

410410
let std-infer-call-arg(tctx: TypeContext?, term: AST, function-name: CString, hint: Type): (TypeContext?, AST) = (
411+
let feq = function-name==c"list::cons";
411412
if function-name==c"list::cons" { match term {
412413
App{k=left, m=right} => (
413414
(tctx, let new-k) = std-infer-expr(tctx, k, false, Call(function-name), ta);

LM23COMMON/unit-main-core.lsts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ let main(argc: C_int, argv: CString[]): Nil = (
9393
for list fp in input.reverse { frontend(fp); };
9494
match config-mode {
9595
ModeTypecheck{} => (preprocess(); typecheck(););
96-
ModeCompile{} => (preprocess(); typecheck(); plugin-current-backend(););
96+
ModeCompile{} => (preprocess(); typecheck(); plugin-current-backend(); );
9797
};
9898
);
9999
};

lib/std/string.lsts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ let .is-digit(base: CString): U64 = (
5656
);
5757

5858
let $"[]"(base: CString, idx: U64): U8 = (
59-
if idx < base.length
59+
if (base as USize) == 0 then fail(c"Index Out Of Bounds in String[]");
60+
else if idx < base.length
6061
then (base as U8[])[idx]
61-
else fail("Index Out Of Bounds in String[]");
62+
else fail(c"Index Out Of Bounds in String[]");
6263
);
6364

6465
let .into(s: CString, tgt: Type<String>): String = intern(s);
@@ -104,10 +105,10 @@ let .get-suffix(s: String, pre: String): String = (
104105
s[s.length - pre.length:]
105106
);
106107

107-
let head-string(x: CString): U8 = (x as U8[])[0_u64];
108-
let tail-string(x: CString): CString = ((x as U8[]) + 1_u64) as CString;
109-
let head(x: CString): U8 = (x as U8[])[0_u64];
110-
let tail(x: CString): CString = ((x as U8[]) + 1_u64) as CString;
108+
let head-string(x: CString): U8 = if (x as USize)==0 then 0_u8 else (x as U8[])[0_u64];
109+
let tail-string(x: CString): CString = if (x as USize)==0 then c"" else (((x as U8[]) + 1_u64) as CString);
110+
let head(x: CString): U8 = head-string(x);
111+
let tail(x: CString): CString = tail-string(x);
111112

112113
let deep-hash(key: CString): U64 = (
113114
let i = 0_u64;
@@ -125,11 +126,13 @@ let deep-hash(key: CString): U64 = (
125126
);
126127

127128
let .length(s: CString): U64 = (
128-
let si = 0_u64;
129-
while (s as U8[])[si] != 0 {
130-
si = si + 1;
131-
};
132-
si
129+
if (s as USize) == 0 then 0 else {
130+
let si = 0_u64;
131+
while (s as U8[])[si] != 0 {
132+
si = si + 1;
133+
};
134+
si
135+
}
133136
);
134137

135138
let .has-prefix(base: CString, pfx: CString): U64 = (
@@ -204,10 +207,13 @@ let .contains(base: CString, pat: CString): U64 = (
204207
);
205208

206209
let $"+"(l: CString, r: CString): CString = (
210+
let l_length = l.length;
211+
let r_length = r.length;
207212
let buf = malloc(l.length + r.length + 1) as C<"char">[];
208213
memset(buf, 0, l.length+r.length+1);
209214
strcat(buf, l as C<"char">[]);
210215
strcat(buf, r as C<"char">[]);
216+
buf[l_length + r_length] = 0 as C<"char">;
211217
buf as CString
212218
);
213219

lib1/std/vector.lsts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ let .sort(v: Vector<t>): Vector<t> = (
145145
# new allocations = 1 if realloc is necessary
146146
# | 0
147147
let .buffer-into-cstring(v: Vector<U8>): CString = (
148+
v.push(0);
148149
v.data.retain;
149150
v.data.data as CString
150151
);

lib2/core/vector.lsts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ let .buffer-into-string(v: Vector<U8>): String = (
152152
# new allocations = 1 if realloc is necessary
153153
# | 0
154154
let .buffer-into-cstring(v: Vector<U8>): CString = (
155+
v.push(0);
155156
v.data.retain;
156157
v.data.data as CString
157158
);

0 commit comments

Comments
 (0)