Skip to content

Commit 67fd964

Browse files
committed
still only very minor improvements
1 parent 50db377 commit 67fd964

File tree

8 files changed

+3482
-3412
lines changed

8 files changed

+3482
-3412
lines changed

BOOTSTRAP/cli.c

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ let std-c-compile-expr(ctx: FContext, t: AST, is-stmt: Bool): Fragment = (
9595
std-c-fragment-context = std-c-fragment-context.bind( lhs, v );
9696
ctx = ctx.bind( name, lt, v );
9797
if lt.is-t(c"Nil",0) or lt.is-t(c"Never",0) or lt <: type-c-void {
98-
} else if lt <: t1(c"C",t0(c":Label")) {
98+
} else if lt <: type-c-label {
9999
f = f.set(c"expression", v.get(c"expression") + SAtom(c":"));
100100
} else {
101101
(let pre, let post) = std-c-mangle-declaration(lt, t);

PLUGINS/BACKEND/C/std-c-compile-function-args.lsts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let std-c-compile-function-args(ctx: FContext, lhs: AST): S = (
55
let decl = std-c-mangle-declaration(kt, lhs);
66
let text = std-c-compile-function-args(ctx, rest);
77
text = text + SAtom(c",");
8-
if can-unify( t1(c"C",t0(c"...")), kt ) {
8+
if can-unify( type-c-vararg, kt ) {
99
text = text + SAtom(c"...");
1010
} else if can-unify( type-c-void, kt ) {
1111
text = text + SAtom(c"void");
@@ -21,7 +21,7 @@ let std-c-compile-function-args(ctx: FContext, lhs: AST): S = (
2121
App{ left:Lit{key:c":"}, right:App{ v-t=left:Var{k2=key}, right:AType{kt=tt} } } => (
2222
let decl = std-c-mangle-declaration(kt, lhs);
2323
let text = SNil();
24-
if can-unify( t1(c"C",t0(c"...")), kt ) {
24+
if can-unify( type-c-vararg, kt ) {
2525
text = text + SAtom(c"...");
2626
} else if can-unify( type-c-void, kt ) {
2727
text = text + SAtom(c"void");

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ let std-c-compile-global(ctx: FContext, k: CString, term: AST): Nil = (
5757
text = text + post-decl;
5858
text = text + SAtom(c";\n");
5959
if kt.is-t(c"Nil",0) or kt.is-t(c"Never",0) or kt <: type-c-void then ()
60-
else if can-unify(t1(c"C",t0(c"typedef")), tt) or can-unify(t2(c"Array",t1(c"C",t0(c"typedef")),ta), tt) {
60+
else if can-unify(type-c-typedef, tt) or can-unify(type-array-c-typedef, tt) {
6161
assemble-header-typedef-section = assemble-header-typedef-section + text;
6262
} else {
6363
assemble-gdecl-section = assemble-gdecl-section + text;
@@ -96,7 +96,7 @@ let std-c-compile-global(ctx: FContext, k: CString, term: AST): Nil = (
9696
if kt.is-t(c"Nil",0) or kt.is-t(c"Never",0) or kt <: type-c-void then {
9797
text = SNil;
9898
text = SAtom(k) + SAtom(c" = ") + inner-expr.get(c"expression") + SAtom(c";\n");
99-
} else if can-unify(t1(c"C",t0(c"typedef")), tt) or can-unify(t2(c"Array",t1(c"C",t0(c"typedef")),ta), tt) {
99+
} else if can-unify(type-c-typedef, tt) or can-unify(type-array-c-typedef, tt) {
100100
assemble-header-typedef-section = assemble-header-typedef-section + text;
101101
} else {
102102
assemble-gdecl-section = assemble-gdecl-section + text;
@@ -115,7 +115,7 @@ let std-c-compile-global(ctx: FContext, k: CString, term: AST): Nil = (
115115
App{ left:Lit{key:c":"}, right:App{ left:ASTNil{}, right:AType{asc-tt=tt} } } => asc-tt.is-t(c"Nil",0);
116116
_ => true;
117117
};
118-
if initialized or can-unify(t1(c"C",t0(c"typedef")), tt) {
118+
if initialized or can-unify(type-c-typedef, tt) {
119119
let text = SNil();
120120
if not(config-strip-debug) and loc.filename != c"Unknown" {
121121
text = text + SAtom(c"\n#line ");
@@ -131,7 +131,7 @@ let std-c-compile-global(ctx: FContext, k: CString, term: AST): Nil = (
131131
text = text + SAtom(c"(");
132132
text = text + std-c-compile-function-args(ctx, lhs);
133133
text = text + SAtom(c");\n");
134-
if can-unify(t1(c"C",t0(c"typedef")), tt) {
134+
if can-unify(type-c-typedef, tt) {
135135
assemble-header-typedef-section = assemble-header-typedef-section + text;
136136
} else {
137137
assemble-gdecl-section = assemble-gdecl-section + text;

PLUGINS/BACKEND/C/std-c-mangle-type.lsts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let std-c-mangle-type-internal(tt: Type, blame: AST): S = (
1515
let std-c-mangle-type-internal-internal(tt: Type, blame: AST): S = (
1616
match tt {
1717
TAnd{ conjugate=conjugate } => (
18-
let is-c = can-unify(t1(c"C",ta), tt);
18+
let is-c = can-unify(type-c-tany, tt);
1919
let modifiers = SNil;
2020
let result = SNil;
2121
for vector c in conjugate {
@@ -101,7 +101,7 @@ let std-c-mangle-type-internal-internal(tt: Type, blame: AST): S = (
101101
let std-c-mangle-type-simple(tt: Type, blame: AST): S = (
102102
match tt {
103103
TAnd{ conjugate=conjugate } => (
104-
let is-c = can-unify(t1(c"C",ta), tt);
104+
let is-c = can-unify(type-c-tany, tt);
105105
let result = SNil();
106106
for vector c in conjugate {
107107
if is-c and c.simple-tag != c"C" {} else {

PLUGINS/FRONTEND/C/c-ast-to-lm-ast.lsts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let std-c-declare(t: CTerm): Nil = (
2121
);
2222
CIdentifier{name2=value} => (if not(std-c-declare-dedup-index.has-key(name2)) {
2323
std-c-declare-dedup-index = std-c-declare-dedup-index.bind(name2, true);
24-
if can-unify( t1(c"C",t0(c"typedef")), return-type ) {
24+
if can-unify( type-c-typedef, return-type ) {
2525
std-c-typedef-name-index = std-c-typedef-name-index.bind(name2, true);
2626
};
2727
ast-parsed-program = ast-parsed-program + Glb(
@@ -38,7 +38,7 @@ let std-c-declare(t: CTerm): Nil = (
3838
(let name3, let body) = std-c-sig-of-declarator(return-type, arg, ta, (None : Maybe<CTerm>)());
3939
if not(std-c-declare-dedup-index.has-key(name3.into(type(String)))) {
4040
std-c-declare-dedup-index = std-c-declare-dedup-index.bind(name3.into(type(String)), true);
41-
if can-unify( t1(c"C",t0(c"typedef")), return-type ) {
41+
if can-unify( type-c-typedef, return-type ) {
4242
std-c-typedef-name-index = std-c-typedef-name-index.bind(name3.into(type(String)), true);
4343
};
4444
ast-parsed-program = ast-parsed-program + Glb(
@@ -50,7 +50,7 @@ let std-c-declare(t: CTerm): Nil = (
5050
(let name4, let body) = std-c-sig-of-declarator(return-type, arg1, ta, Some(arg2));
5151
if not(std-c-declare-dedup-index.has-key(name4.into(type(String)))) {
5252
std-c-declare-dedup-index = std-c-declare-dedup-index.bind(name4.into(type(String)), true);
53-
if can-unify( t1(c"C",t0(c"typedef")), return-type ) {
53+
if can-unify( type-c-typedef, return-type ) {
5454
std-c-typedef-name-index = std-c-typedef-name-index.bind(name4.into(type(String)), true);
5555
};
5656
ast-parsed-program = ast-parsed-program + Glb(
@@ -63,7 +63,7 @@ let std-c-declare(t: CTerm): Nil = (
6363
(let name5, let body) = std-c-sig-of-declarator(return-type, arg1, ta, Some(arg2));
6464
if not(std-c-declare-dedup-index.has-key(name5.into(type(String)))) {
6565
std-c-declare-dedup-index = std-c-declare-dedup-index.bind(name5.into(type(String)), true);
66-
if can-unify( t1(c"C",t0(c"typedef")), return-type ) {
66+
if can-unify( type-c-typedef, return-type ) {
6767
std-c-typedef-name-index = std-c-typedef-name-index.bind(name5.into(type(String)), true);
6868
};
6969
ast-parsed-program = ast-parsed-program + Glb(
@@ -74,7 +74,7 @@ let std-c-declare(t: CTerm): Nil = (
7474
CBinaryOp{op:"Declarator*", ptr=arg1, arg2:CIdentifier{name6=value} } => (
7575
if not(std-c-declare-dedup-index.has-key(name6)) {
7676
std-c-declare-dedup-index = std-c-declare-dedup-index.bind(name6, true);
77-
if can-unify( t1(c"C",t0(c"typedef")), return-type ) {
77+
if can-unify( type-c-typedef, return-type ) {
7878
std-c-typedef-name-index = std-c-typedef-name-index.bind(name6, true);
7979
};
8080
return-type = std-c-decorate-pointer(return-type, ptr);
@@ -130,7 +130,7 @@ let std-c-nametypes-of-params-list(params: List<CTerm>, is-vararg: Bool): List<(
130130
_ => print("std-c-sig-of-params-list: Unexpected Parameter \{p}\n");
131131
}};
132132
if is-vararg {
133-
nametypes = cons((uuid(), t1(c"C",t0(c"..."))), nametypes);
133+
nametypes = cons((uuid(), type-c-vararg), nametypes);
134134
};
135135
nametypes.reverse
136136
);
@@ -414,7 +414,7 @@ let std-c-expr-of-statement(t: CTerm): AST = (
414414
match std-c-expr-of-statement(arg1) {
415415
Var{key=key} => (
416416
mk-cons(
417-
mk-app( mk-app( mk-var("let"), mk-var(key) ), mk-nil().ascript(t1(c"C",t0(c":Label"))) ),
417+
mk-app( mk-app( mk-var("let"), mk-var(key) ), mk-nil().ascript(type-c-label) ),
418418
std-c-expr-of-statement(arg2)
419419
)
420420
);
@@ -609,15 +609,15 @@ let std-c-decorate-pointer(tt: Type, ptr: CTerm): Type = (
609609
let std-c-type-of-integer(i: String): Type = (
610610
if i.has-prefix("-") {
611611
let n = to-u64(tail(i).into(type(CString)));
612-
if n <= 128 then t1(c"C",t0(c"uint8_t")) else
613-
if n <= 32768 then t1(c"C",t0(c"uint06_t")) else
614-
if n <= 2147483648 then t1(c"C",t0(c"uint22_t")) else
615-
t1(c"C",t0(c"uint64_t"))
612+
if n <= 128 then type-c-uint8 else
613+
if n <= 32768 then type-c-uint16 else
614+
if n <= 2147483648 then type-c-uint32 else
615+
type-c-uint64
616616
} else {
617617
let n = to-u64(i.into(type(CString)));
618-
if n <= 255 then t1(c"C",t0(c"int8_t")) else
619-
if n <= 65535 then t1(c"C",t0(c"int06_t")) else
620-
if n <= 4294967295 then t1(c"C",t0(c"int22_t")) else
621-
t1(c"C",t0(c"int64_t"))
618+
if n <= 255 then type-c-int8 else
619+
if n <= 65535 then type-c-int16 else
620+
if n <= 4294967295 then type-c-int32 else
621+
type-c-int64
622622
};
623623
);

PLUGINS/FRONTEND/LSTS/lsts-parse.lsts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ let lsts-make-lit(t: Token): AST = (
16371637
Var( c".into", with-location(mk-token(".into"),loc) ),
16381638
mk-cons(
16391639
se-rest.first,
1640-
mk-atype(t1(c"Type",t0(c"String")))
1640+
mk-atype(type-type-string)
16411641
)
16421642
);
16431643
if non-zero(base) {

SRC/type-constructor.lsts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ let type-nil = t0(c"Nil");
2626
# new allocations = 0 (constant)
2727
let type-any = t0(c"Any");
2828

29+
# new allocations = 0 (constant)
30+
let type-type-string = t1(c"Type",t0(c"String"));
31+
2932
# new allocations = 0 (constant)
3033
let type-linear-moved = t1(c"Linear",t0(c"Phi::Moved"));
3134

@@ -35,6 +38,45 @@ let type-linear-live = t1(c"Linear",t0(c"Phi::Live"));
3538
# new allocations = 0 (constant)
3639
let type-c-void = t1(c"C",t0(c"void"));
3740

41+
# new allocations = 0 (constant)
42+
let type-c-label = t1(c"C",t0(c":Label"));
43+
44+
# new allocations = 0 (constant)
45+
let type-c-vararg = t1(c"C",t0(c"..."));
46+
47+
# new allocations = 0 (constant)
48+
let type-c-tany = t1(c"C",ta);
49+
50+
# new allocations = 0 (constant)
51+
let type-c-typedef = t1(c"C",t0(c"typedef"));
52+
53+
# new allocations = 0 (constant)
54+
let type-array-c-typedef = t2(c"Array",t1(c"C",t0(c"typedef")),ta);
55+
56+
# new allocations = 0 (constant)
57+
let type-c-int8 = t1(c"C",t0(c"int8_t"));
58+
59+
# new allocations = 0 (constant)
60+
let type-c-int16 = t1(c"C",t0(c"int16_t"));
61+
62+
# new allocations = 0 (constant)
63+
let type-c-int32 = t1(c"C",t0(c"int32_t"));
64+
65+
# new allocations = 0 (constant)
66+
let type-c-int64 = t1(c"C",t0(c"int64_t"));
67+
68+
# new allocations = 0 (constant)
69+
let type-c-uint8 = t1(c"C",t0(c"uint8_t"));
70+
71+
# new allocations = 0 (constant)
72+
let type-c-uint16 = t1(c"C",t0(c"uint16_t"));
73+
74+
# new allocations = 0 (constant)
75+
let type-c-uint32 = t1(c"C",t0(c"uint32_t"));
76+
77+
# new allocations = 0 (constant)
78+
let type-c-uint64 = t1(c"C",t0(c"uint64_t"));
79+
3880
# new allocations = 0 (constant)
3981
let type-any-arrow = t2(c"Arrow", type-any, type-any);
4082

0 commit comments

Comments
 (0)