Skip to content

Commit e13e410

Browse files
Merge pull request #1504 from andrew-johnson-4/start-using-new-macros
Start using new macros
2 parents 040c236 + f415455 commit e13e410

16 files changed

+30305
-30258
lines changed

BOOTSTRAP/cli.c

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

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CC = cc
2-
CFLAGS = -O3 -march=native -mtune=native
2+
CFLAGS = -O3 -march=native -mtune=native -ferror-limit=50
33

44
dev: install-production
55
lm t.lsts

PLATFORM/C/LIB/common-macros.lsts

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

2-
#typed macro macro::let(lhs: lazy, rhs: lazy): lazy = (
3-
# (fn(lhs) = ()) (rhs)
4-
#);
2+
typed macro macro::let(lhs: lazy, rhs: lazy): lazy = (
3+
(fn(lhs) = ()) (rhs)
4+
);
55

66
typed macro macro::for(item: lazy, iter: List<?>, loop: lazy): lazy = (
77
let uuid(iter-term) = iter;

PLUGINS/BACKEND/C/compile-c.lm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ plugins-backend-c-compile := λ . (: (
1414
(set global-ctx (.bind(
1515
global-ctx k kt fragment
1616
)))
17-
(set std-c-fragment-context (.bind( std-c-fragment-context g-t fragment )))
17+
(set std-c-fragment-context (.bind( std-c-fragment-context (def-to-sym g-t) fragment )))
1818
) (
1919
(let clean-tt (.without-tag kt))
2020
(let mid (mangle-identifier( k clean-tt )))
@@ -25,13 +25,13 @@ plugins-backend-c-compile := λ . (: (
2525
(set global-ctx (.bind(
2626
global-ctx k kt fragment
2727
)))
28-
(set std-c-fragment-context (.bind( std-c-fragment-context g-t fragment )))
28+
(set std-c-fragment-context (.bind( std-c-fragment-context (def-to-sym g-t) fragment )))
2929
) (
3030
(let repr-tt (&&( clean-tt (t1 'GlobalVariable_s) )))
3131
(set global-ctx (.bind(
3232
global-ctx k repr-tt fragment
3333
)))
34-
(set std-c-fragment-context (.bind( std-c-fragment-context g-t fragment )))
34+
(set std-c-fragment-context (.bind( std-c-fragment-context (def-to-sym g-t) fragment )))
3535
))
3636
))
3737
))

PLUGINS/BACKEND/C/compile-expr-direct.lm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ compile-expr-direct := λ(: ctx FContext)(: term AST)(: stack-offset I64)(: used
2525
(set e (compile-expr( ctx t stack-offset Used )))
2626
) )
2727
( (TGround( 'Array_s (LCons( TAny (LCons( inner-tt LEOF )) )) )) (
28-
(let fterm (.lookup( var-to-def-index o-t ASTEOF )))
28+
(let fterm (var-to-def o-t))
2929
(set e (std-c-compile-call( ctx 'open_s fterm t )))
3030
))
3131
( (TGround( 'Array_s (LCons( array-length (LCons( inner-tt LEOF )) )) )) (
3232
(set e (compile-expr( ctx t stack-offset Used )))
3333
))
3434
))
3535
) (
36-
(let fterm (.lookup( var-to-def-index o-t ASTEOF )))
36+
(let fterm (var-to-def o-t))
3737
(set e (std-c-compile-call( ctx 'open_s fterm t )))
3838
))
3939
))
@@ -184,7 +184,7 @@ compile-expr-direct := λ(: ctx FContext)(: term AST)(: stack-offset I64)(: used
184184
(match f (
185185
()
186186
( (Var( fname _ )) (
187-
(let fterm (.lookup( var-to-def-index f ASTEOF )))
187+
(let fterm (var-to-def f))
188188
(set e (std-c-compile-call( ctx fname fterm a )))
189189
))
190190
( (Lit( fname _ )) (

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ compile-program-ordered := λ(: global-ctx FContext)(: program AST). (: (
33
(for-each-v (g in (.unroll-seq program)) (match g (
44
()
55
( (Glb( k_t rhs )) (
6-
(if (.is-open(typeof g)) () (
6+
(if (.is-open(typeof(def-to-sym g))) () (
77
(compile-global( global-ctx k rhs ))
88
))
99
))

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
let std-c-compile-call(ctx: FContext, fname: CString, fterm: AST, args: AST): Fragment = (
3+
fterm = find-global-callable(fname, typeof(args));
34
if not(non-zero(fterm)) then fail("std-c-compile-call Function was null: \{fterm}\nArguments: \{typeof(args)}\n");
45
if typeof(fterm).is-t(c"Blob") {
56
let r = mk-fragment();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
let std-c-compile-expr(ctx: FContext, t: AST, is-stmt: Bool): Fragment = (
33
let f = match t {
44
Var{ key=key } => (
5-
let def = var-to-def-index.lookup(t, ASTEOF);
5+
let def = var-to-def(t);
66
let e = std-c-fragment-context.lookup(def, mk-fragment());
77
if not(non-zero(e)) {
88
exit-error( untern("Unable to Find Variable Fragment in Context: \{key}"), t );

PLUGINS/FRONTEND/LSTS/lsts-parse.lsts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,16 +1061,16 @@ let lsts-parse-small-expression(tokens: List<Token>): Tuple<AST,List<Token>> = (
10611061
lsts-parse-expect(c"=", tokens); tokens = tail(tokens);
10621062
let rhs-rest = lsts-parse-small-expression(tokens);
10631063
tokens = rhs-rest.second;
1064-
#base = mk-app(
1065-
# mk-var(with-location(mk-token("macro::let"),loc)),
1066-
# mk-cons(lhs-rest.first, rhs-rest.first)
1067-
#);
10681064
base = mk-app(
1069-
mk-app(
1070-
mk-var(with-location(mk-token("let"),loc)),
1071-
lhs-rest.first
1072-
), rhs-rest.first
1065+
mk-var(with-location(mk-token("macro::let"),loc)),
1066+
mk-cons(lhs-rest.first, rhs-rest.first)
10731067
);
1068+
#base = mk-app(
1069+
# mk-app(
1070+
# mk-var(with-location(mk-token("let"),loc)),
1071+
# lhs-rest.first
1072+
# ), rhs-rest.first
1073+
#);
10741074
);
10751075
[Token{key:c"while"}.. rest] => (
10761076
let loc = head(tokens).location; tokens = rest;

SRC/ascript-normal.lsts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ let ascript-normal(t: AST, tt: Type): Nil = (
99
exit-error("Type Ascription Inequality\n\{normalize(typeof(t))} does not imply \{normalize(tt)}", t);
1010
}
1111
}
12-
} else {
13-
add-concrete-type-instance(tt);
14-
tt = denormalize(tt);
15-
ascript(t, tt);
16-
types-have-changed = true;
17-
}
12+
} else ascript-force(t, tt);
1813
}
1914
);
15+
16+
let ascript-force(t: AST, tt: Type): Nil = (
17+
add-concrete-type-instance(tt);
18+
tt = denormalize(tt);
19+
ascript(t, tt);
20+
types-have-changed = true;
21+
);

0 commit comments

Comments
 (0)