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,170 changes: 2,585 additions & 2,585 deletions BOOTSTRAP/cli.c

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion LM23COMMON/typecheck-infer-expr.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ let std-infer-expr(tctx: Maybe<TypeContext>, term: AST, is-scoped: Bool, used: I
tctx = tctx.phi-override(to-tt, from-tt, term);
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 {
tctx = tctx.phi-move(from-tt, term);
}
};
};

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

let std-infer-call-arg(tctx: TypeContext?, term: AST, function-name: CString, hint: Type): (TypeContext?, AST) = (
let feq = function-name==c"list::cons";
if function-name==c"list::cons" { match term {
App{k=left, m=right} => (
(tctx, let new-k) = std-infer-expr(tctx, k, false, Call(function-name), ta);
Expand Down
2 changes: 1 addition & 1 deletion LM23COMMON/unit-main-core.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ let main(argc: C_int, argv: CString[]): Nil = (
for list fp in input.reverse { frontend(fp); };
match config-mode {
ModeTypecheck{} => (preprocess(); typecheck(););
ModeCompile{} => (preprocess(); typecheck(); plugin-current-backend(););
ModeCompile{} => (preprocess(); typecheck(); plugin-current-backend(); );
};
);
};
Expand Down
28 changes: 17 additions & 11 deletions lib/std/string.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ let .is-digit(base: CString): U64 = (
);

let $"[]"(base: CString, idx: U64): U8 = (
if idx < base.length
if (base as USize) == 0 then fail(c"Index Out Of Bounds in String[]");
else if idx < base.length
then (base as U8[])[idx]
else fail("Index Out Of Bounds in String[]");
else fail(c"Index Out Of Bounds in String[]");
);

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

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

let deep-hash(key: CString): U64 = (
let i = 0_u64;
Expand All @@ -125,11 +126,13 @@ let deep-hash(key: CString): U64 = (
);

let .length(s: CString): U64 = (
let si = 0_u64;
while (s as U8[])[si] != 0 {
si = si + 1;
};
si
if (s as USize) == 0 then 0 else {
let si = 0_u64;
while (s as U8[])[si] != 0 {
si = si + 1;
};
si
}
);

let .has-prefix(base: CString, pfx: CString): U64 = (
Expand Down Expand Up @@ -204,10 +207,13 @@ let .contains(base: CString, pat: CString): U64 = (
);

let $"+"(l: CString, r: CString): CString = (
let l_length = l.length;
let r_length = r.length;
let buf = malloc(l.length + r.length + 1) as C<"char">[];
memset(buf, 0, l.length+r.length+1);
strcat(buf, l as C<"char">[]);
strcat(buf, r as C<"char">[]);
buf[l_length + r_length] = 0 as C<"char">;
buf as CString
);

Expand Down
1 change: 1 addition & 0 deletions lib1/std/vector.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ let .sort(v: Vector<t>): Vector<t> = (
# new allocations = 1 if realloc is necessary
# | 0
let .buffer-into-cstring(v: Vector<U8>): CString = (
v.push(0);
v.data.retain;
v.data.data as CString
);
Expand Down
1 change: 1 addition & 0 deletions lib2/core/vector.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ let .buffer-into-string(v: Vector<U8>): String = (
# new allocations = 1 if realloc is necessary
# | 0
let .buffer-into-cstring(v: Vector<U8>): CString = (
v.push(0);
v.data.retain;
v.data.data as CString
);
Expand Down
Loading