Skip to content

Commit 0f20b3f

Browse files
authored
Merge pull request #1991 from andrew-johnson-4/lib2-gc-disabled-deploy-dfdkksoii
Lib2 gc disabled deploy dfdkksoii
2 parents cd7858d + 7d1382c commit 0f20b3f

6 files changed

Lines changed: 59 additions & 11 deletions

File tree

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 --v2 tests/promises/lm-ascript/ascript-integrated.lsts
5+
time lm --v2 tests/promises/string/prefix.lsts
66
gcc tmp.c
77
./a.out
88

lib2/core/baremetal.lsts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ import lib2/core/cstring.lsts;
2828
import lib2/core/array.lsts;
2929
import lib2/core/io.lsts;
3030
import lib2/core/cmp.lsts;
31+
import lib2/core/c_int.lsts;
3132

3233
let config-v23 = true;

lib2/core/c_int.lsts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
declare-binop( $"!=", raw-type(C<"int">), raw-type(C<"int">), raw-type(Bool), ( l"("; x; l"!="; y; l")"; ) );
3+
declare-binop( $"==", raw-type(C<"int">), raw-type(C<"int">), raw-type(Bool), ( l"("; x; l"=="; y; l")"; ) );
4+
declare-binop( $"<", raw-type(C<"int">), raw-type(C<"int">), raw-type(Bool), ( l"("; x; l"<"; y; l")"; ) );
5+
declare-binop( $"<=", raw-type(C<"int">), raw-type(C<"int">), raw-type(Bool), ( l"("; x; l"<="; y; l")"; ) );
6+
declare-binop( $">", raw-type(C<"int">), raw-type(C<"int">), raw-type(Bool), ( l"("; x; l">"; y; l")"; ) );
7+
declare-binop( $">=", raw-type(C<"int">), raw-type(C<"int">), raw-type(Bool), ( l"("; x; l">="; y; l")"; ) );
8+
9+
declare-binop( $"&", raw-type(C<"int">), raw-type(C<"int">), raw-type(C<"int">), ( l"("; x; l"&"; y; l")"; ) );
10+
declare-binop( $"|", raw-type(C<"int">), raw-type(C<"int">), raw-type(C<"int">), ( l"("; x; l"|"; y; l")"; ) );
11+
declare-binop( $"^", raw-type(C<"int">), raw-type(C<"int">), raw-type(C<"int">), ( l"("; x; l"^"; y; l")"; ) );
12+
declare-binop( $"+", raw-type(C<"int">), raw-type(C<"int">), raw-type(C<"int">), ( l"("; x; l"+"; y; l")"; ) );
13+
declare-binop( $"-", raw-type(C<"int">), raw-type(C<"int">), raw-type(C<"int">), ( l"("; x; l"-"; y; l")"; ) );
14+
declare-binop( $"/", raw-type(C<"int">), raw-type(C<"int">), raw-type(C<"int">), ( l"("; x; l"/"; y; l")"; ) );
15+
declare-binop( $"%", raw-type(C<"int">), raw-type(C<"int">), raw-type(C<"int">), ( l"("; x; l"%"; y; l")"; ) );
16+
declare-binop( $"*", raw-type(C<"int">), raw-type(C<"int">), raw-type(C<"int">), ( l"("; x; l"*"; y; l")"; ) );
17+
18+
declare-binop( $"<<", raw-type(C<"int">), raw-type(C<"int">), raw-type(C<"int">), ( l"("; x; l"<<"; y; l")"; ) );
19+
declare-binop( $">>", raw-type(C<"int">), raw-type(C<"int">), raw-type(C<"int">), ( l"("; x; l">>"; y; l")"; ) );
20+
21+
declare-unop( $"~", raw-type(C<"int">), raw-type(C<"int">), ( l"((uint64_t)(~"; x; l"))"; ) );

lib2/core/platform-macros.lsts

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

2+
deprecated macro (rl"declare-zop"(op-alias, r-type, op-expr)) (
3+
let :Blob op-alias(): r-type = (
4+
$":expression"(op-expr);
5+
);
6+
);
7+
28
deprecated macro (rl"declare-unop"(op-alias, x-type, r-type, op-expr)) (
39
let :Blob op-alias(x: x-type): r-type = (
410
$":expression"(op-expr);

lib2/core/regex.lsts

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,33 @@ let :Blob .rm_eo(t: C<"regmatch_t">): U64 = (
1010
$":expression"( l"("; $":expression"(t); l".rm_eo)"; );
1111
);
1212

13+
declare-binop( $"set.rm_so", raw-type(C<"regmatch_t">), raw-type(U64), raw-type(Nil), ( l"("; x; l".rm_so="; y; l")"; ) );
14+
declare-binop( $"set.rm_eo", raw-type(C<"regmatch_t">), raw-type(U64), raw-type(Nil), ( l"("; x; l".rm_eo="; y; l")"; ) );
15+
16+
declare-ternop( $"set.rm_so", raw-type(C<"regmatch_t">[]), raw-type(USize), raw-type(U64), raw-type(Nil), ( l"("; x; l"["; y; l"].rm_so="; z; l")"; ) );
17+
declare-ternop( $"set.rm_eo", raw-type(C<"regmatch_t">[]), raw-type(USize), raw-type(U64), raw-type(Nil), ( l"("; x; l"["; y; l"].rm_eo="; z; l")"; ) );
18+
19+
declare-zop( $"reg_startend", raw-type(C<"int">), l"REG_STARTEND" );
20+
declare-zop( $"reg_nomatch", raw-type(C<"int">), l"REG_NOMATCH" );
21+
1322
let .has-prefix(text: String, rgx: Regex): Bool = (
1423
# TODO: fix this mess. The preprocessor is unpacking these erroneously
1524
# macros 2.0 doesn't have this problem, but this code still needs to be updated after swapping
1625
let a1 = &rgx as C<"regex_t">[];
1726
let a2 = (text.data.data + text.start-offset) as C<"char">[];
1827
let a3 = 0 as C<"size_t">;
19-
let a4 = 0 as C<"regmatch_t">[];
20-
let a5 = 0 as C<"int">;
28+
let a4 = () : C<"regmatch_t">[1];
29+
a4[0].rm_so = 0;
30+
a4[0].rm_eo = text.length;
31+
let a5 = reg_startend();
2132
let status = regexec(
2233
a1,
2334
a2,
2435
a3,
25-
a4,
36+
a4 as C<"regmatch_t">[],
2637
a5
2738
);
28-
(status as U64) == 0
39+
status != reg_nomatch() and a4[0].rm_so==0
2940
);
3041

3142
let $"=="(text: CString, rgx: Regex): Bool = (
@@ -42,43 +53,49 @@ let $"=="(text: CString, rgx: Regex): Bool = (
4253
a4,
4354
a5
4455
);
45-
(status as U64)==0 and matches[0].rm_so==0 and matches[0].rm_eo==text.length
56+
status != reg_nomatch() and matches[0].rm_so==0 and matches[0].rm_eo==text.length
4657
);
4758

4859
let .remove-prefix(text: String, rgx: Regex): String? = (
4960
let matches = () : C<"regmatch_t">[1];
61+
matches[0].rm_so = 0;
62+
matches[0].rm_eo = text.length;
5063
let a1 = &rgx as C<"regex_t">[];
5164
let a2 = (text.data.data + text.start-offset) as C<"char">[];
5265
let a3 = 1 as C<"size_t">;
5366
let a4 = matches as C<"regmatch_t">[];
54-
let a5 = 0 as C<"int">;
67+
let a5 = reg_startend();
5568
let status = regexec(
5669
a1,
5770
a2,
5871
a3,
5972
a4,
6073
a5
6174
);
62-
if matches[0].rm_so != 0 then (None : String?)
75+
if status == reg_nomatch() then (None : String?)
76+
else if matches[0].rm_so != 0 then (None : String?)
6377
else if matches[0].rm_eo == 0 then (None : String?)
64-
else Some(text[matches[0].rm_eo as I64 : ])
78+
else Some(text[matches[0].rm_eo as I64 : ]);
6579
);
6680

6781
let .get-prefix(text: String, rgx: Regex): String? = (
6882
let matches = () : C<"regmatch_t">[1];
83+
matches[0].rm_so = 0;
84+
matches[0].rm_eo = text.length;
6985
let a1 = &rgx as C<"regex_t">[];
7086
let a2 = (text.data.data + text.start-offset) as C<"char">[];
7187
let a3 = 1 as C<"size_t">;
7288
let a4 = matches as C<"regmatch_t">[];
73-
let a5 = 0 as C<"int">;
89+
let a5 = reg_startend();
7490
let status = regexec(
7591
a1,
7692
a2,
7793
a3,
7894
a4,
7995
a5
8096
);
81-
if matches[0].rm_so != 0 then (None : String?)
97+
if status == reg_nomatch() then (None : String?)
98+
else if matches[0].rm_so != 0 then (None : String?)
8299
else if matches[0].rm_eo == 0 then (None : String?)
83100
else Some(text[0_i64 : matches[0].rm_eo as I64])
84101
);

tests/promises/string/prefix.lsts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ assert( " ".remove-prefix(r/^[a-zA-Z0-9_-]+/) == (None : String?) );
3030

3131
assert( " import "[1_u64:].remove-prefix(r/^[a-zA-Z0-9_-]+/) == Some(" ") );
3232
assert( " "[1_u64:].remove-prefix(r/^[a-zA-Z0-9_-]+/) == (None : String?) );
33+
34+
assert( "ORANGEAPPLE"[:6_u64].remove-prefix(r/APPLE/) == (None : String?) );
35+
assert( not("ORANGEAPPLE"[:6_u64].has-prefix(r/APPLE/)) );

0 commit comments

Comments
 (0)