Skip to content

Commit 632629e

Browse files
authored
Merge pull request #2057 from andrew4328/generic-retain-release-fdskdslsl
Generic retain release fdskdslsl
2 parents f03ef48 + 8d62da7 commit 632629e

33 files changed

Lines changed: 6740 additions & 7096 deletions

BOOTSTRAP/cli.c

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

BOOTSTRAP/monolithic.lsts

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

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LSTSFLAGS = MALLOC_CHECK_=3
88
# recommendation: ulimit -s unlimited
99

1010
dev: install-production
11-
lm --v3 tests/promises/meta/fields-of.lsts
11+
lm --v3 --print-ast tests/promises/lm-ast/constructor.lsts > out.txt
1212
gcc tmp.c
1313
./a.out
1414

@@ -102,7 +102,7 @@ smoke-test: smoke-test-clang smoke-test-gcc smoke-test-musl
102102
smoke-test-lite: smoke-test-clang smoke-test-gcc
103103

104104
install:
105-
$(CC) $(CFLAGS) -o lm BOOTSTRAP/cli.c
105+
time $(CC) $(CFLAGS) -o lm BOOTSTRAP/cli.c
106106
ifeq ($(shell test -w /usr/local/bin; echo $$?), 0)
107107
mv lm /usr/local/bin/lm
108108
else

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -231,23 +231,6 @@ let std-c-compile-expr(ctx: FContext, t: AST, is-stmt: Bool): Fragment = (
231231
App{ is-cons=is-cons, left=left, right=right } => (
232232
if not(is-cons) and typeof-term(left).is-arrow {
233233
match left {
234-
Var{fname1=key:c"<:"} => (
235-
match right {
236-
App{ lt=left, rt=right } => (
237-
let lt-tt = typeof-term(lt);
238-
let rt-tt = typeof-term(rt);
239-
if lt-tt.is-t(c"Type",1) and rt-tt.is-t(c"Type",1)
240-
then (
241-
let lt-val = denormalize(lt-tt.slot(c"Type",1).l1);
242-
let rt-val = denormalize(rt-tt.slot(c"Type",1).l1);
243-
if can-unify( rt-val, lt-val )
244-
then mk-expression(c"1")
245-
else mk-expression(c"0")
246-
) else std-c-compile-call(ctx, fname1, right);
247-
);
248-
_ => std-c-compile-call(ctx, fname1, right);
249-
}
250-
);
251234
Var{fname2=key:c".into"} => (
252235
match right {
253236
App{ lt=left, rt=right } => (

PLUGINS/FRONTEND/LSTS/lsts-parse.lsts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,10 @@ let lsts-parse-type-conjugate(tokens: List<Token>): Tuple<Type,List<Token>> = (
360360
lsts-parse-expect(c":", tokens); tokens = tail(tokens);
361361
lsts-parse-expect(c":", tokens); tokens = tail(tokens);
362362
lsts-parse-expect(c"Type", non-zero(tokens), tokens);
363-
if not(lsts-is-type-tag(lsts-parse-head(tokens))) and not(lsts-is-ident-head(lsts-parse-head(tokens))) {
364-
lsts-parse-expect(c"[Type Tag or Variable]", tokens);
363+
if lsts-is-type-tag(lsts-parse-head(tokens)) or lsts-is-ident-head(lsts-parse-head(tokens)) {
364+
base = base + c"::" + lsts-substitute-type-aliases(lsts-parse-head(tokens));
365+
tokens = tail(tokens);
365366
};
366-
base = base + c"::" + lsts-substitute-type-aliases(lsts-parse-head(tokens));
367-
tokens = tail(tokens);
368367
};
369368
let args = mk-vector(type(Type));
370369
if lsts-parse-head(tokens) == c"<" {

SRC/ast-definition.lsts

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -38,85 +38,3 @@ type AST zero ASTEOF implies MustRetain, MustRelease
3838
| Typedef { td: OneOwnedData<ASTTypedef>[] };
3939

4040
let $"App"(left: OneOwnedData<AST>[], right: OneOwnedData<AST>[]): AST = App ( false, left, right );
41-
42-
let .retain(t: ASTTypedef): ASTTypedef = (
43-
mark-as-released(t.lhs-type.retain);
44-
mark-as-released(t.implies.retain);
45-
mark-as-released(t.implements.retain);
46-
mark-as-released(t.size.retain);
47-
mark-as-released(t.alias.retain);
48-
mark-as-released(t.opaque-alias.retain);
49-
mark-as-released(t.cases.retain);
50-
mark-as-released(t.misc-type.retain);
51-
mark-as-released(t.implied-phi.retain);
52-
t
53-
);
54-
55-
let .retain(t: AST): AST = (
56-
if t.discriminator-case-tag==(t as Tag::Meta).discriminator-case-tag {
57-
(t as Tag::Meta).val.retain;
58-
};
59-
if t.discriminator-case-tag==(t as Tag::App).discriminator-case-tag {
60-
(t as Tag::App).left.retain;
61-
(t as Tag::App).right.retain;
62-
};
63-
if t.discriminator-case-tag==(t as Tag::Abs).discriminator-case-tag {
64-
(t as Tag::Abs).lhs.retain;
65-
(t as Tag::Abs).rhs.retain;
66-
mark-as-released((t as Tag::Abs).tt.retain);
67-
};
68-
if t.discriminator-case-tag==(t as Tag::AType).discriminator-case-tag {
69-
mark-as-released((t as Tag::AType).tt.retain);
70-
};
71-
if t.discriminator-case-tag==(t as Tag::Seq).discriminator-case-tag {
72-
mark-as-released((t as Tag::Seq).seq.retain);
73-
};
74-
if t.discriminator-case-tag==(t as Tag::Glb).discriminator-case-tag {
75-
(t as Tag::Glb).val.retain;
76-
};
77-
if t.discriminator-case-tag==(t as Tag::Typedef).discriminator-case-tag {
78-
mark-as-released((t as Tag::Typedef).td.retain);
79-
};
80-
t
81-
);
82-
83-
let .release(t: ASTTypedef): Nil = (
84-
t.lhs-type.release;
85-
t.implies.release;
86-
t.implements.release;
87-
t.size.release;
88-
t.alias.release;
89-
t.opaque-alias.release;
90-
t.cases.release;
91-
t.misc-type.release;
92-
t.implied-phi.release;
93-
);
94-
95-
let .release(t: AST): Nil = (
96-
if t.discriminator-case-tag==(t as Tag::Meta).discriminator-case-tag {
97-
(t as Tag::Meta).val.release;
98-
};
99-
if t.discriminator-case-tag==(t as Tag::App).discriminator-case-tag {
100-
(t as Tag::App).left.release;
101-
(t as Tag::App).right.release;
102-
};
103-
if t.discriminator-case-tag==(t as Tag::Abs).discriminator-case-tag {
104-
(t as Tag::Abs).lhs.release;
105-
(t as Tag::Abs).rhs.release;
106-
(t as Tag::Abs).tt.release;
107-
};
108-
if t.discriminator-case-tag==(t as Tag::AType).discriminator-case-tag {
109-
(t as Tag::AType).tt.release;
110-
};
111-
if t.discriminator-case-tag==(t as Tag::Seq).discriminator-case-tag {
112-
(t as Tag::Seq).seq.release;
113-
};
114-
if t.discriminator-case-tag==(t as Tag::Glb).discriminator-case-tag {
115-
(t as Tag::Glb).val.release;
116-
};
117-
if t.discriminator-case-tag==(t as Tag::Typedef).discriminator-case-tag {
118-
(t as Tag::Typedef).td.release;
119-
};
120-
mark-as-released(t);
121-
);
122-

SRC/ast-into-string.lsts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ let .into(t: AST, tgt: Type<String>): String = (
2121
);
2222
AType{tt=tt} => tt.into(type(String));
2323
Seq{seq=seq} => (
24-
let ret = "{";
25-
for s in seq { if non-zero(ret) then ret = ret + ";"; ret = ret + s.into(type(String)) };
24+
let ret = "{\n";
25+
for s in seq { ret = ret + "\t" + s.into(type(String)) + ";\n" };
2626
ret + "}"
2727
);
2828
Typedef{lhs-type=lhs-type} => (

SRC/tctx-definition.lsts

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,9 @@ let global-tctx = {} : Hashtable<CString,Vector<TypeContextRow>>;
33
let tctx-currently-processing-globals = true;
44

55
type TypeContextRow zero NullTypeContextRow implies MustRetain, MustRelease = NullTypeContextRow | TypeContextRow { key: CString, nt: Type, dt: Type, blame: AST };
6-
let .retain(t: TypeContextRow): TypeContextRow = (
7-
if t.discriminator-case-tag==(t as Tag::TypeContextRow).discriminator-case-tag {
8-
mark-as-released((t as Tag::TypeContextRow).nt.retain);
9-
mark-as-released((t as Tag::TypeContextRow).dt.retain);
10-
mark-as-released((t as Tag::TypeContextRow).blame.retain);
11-
};
12-
t
13-
);
14-
let .release(t: TypeContextRow): Nil = (
15-
if t.discriminator-case-tag==(t as Tag::TypeContextRow).discriminator-case-tag {
16-
(t as Tag::TypeContextRow).nt.release;
17-
(t as Tag::TypeContextRow).dt.release;
18-
(t as Tag::TypeContextRow).blame.release;
19-
};
20-
mark-as-released(t);
21-
);
22-
236
type PhiContextRow zero NullPhiContextRow implies MustRetain, MustRelease = NullPhiContextRow | PhiContextRow { phi-id: U64, phi-tt: Type, blame: AST, dead-on-arrival: Bool, is-global: Bool };
24-
let .retain(t: PhiContextRow): PhiContextRow = (
25-
if t.discriminator-case-tag==(t as Tag::PhiContextRow).discriminator-case-tag {
26-
mark-as-released((t as Tag::PhiContextRow).phi-tt.retain);
27-
mark-as-released((t as Tag::PhiContextRow).blame.retain);
28-
};
29-
t
30-
);
31-
let .release(t: PhiContextRow): Nil = (
32-
if t.discriminator-case-tag==(t as Tag::PhiContextRow).discriminator-case-tag {
33-
(t as Tag::PhiContextRow).phi-tt.release;
34-
(t as Tag::PhiContextRow).blame.release;
35-
};
36-
mark-as-released(t);
37-
);
38-
39-
let .into(pr: PhiContextRow, tt: Type<String>): String = "#\{pr.phi-id-or-zero} : \{pr.phi-tt-or-zero}";
40-
417
type TypeContext implies MustRetain, MustRelease = { tctx:List<TypeContextRow>, pctx: PBTree<U64,PhiContextRow>, is-unsafe: Bool, is-blob: Bool, function-name:CString };
42-
let .retain(t: TypeContext): TypeContext = (
43-
if t.discriminator-case-tag==(t as Tag::TypeContext).discriminator-case-tag {
44-
mark-as-released((t as Tag::TypeContext).tctx.retain);
45-
mark-as-released((t as Tag::TypeContext).pctx.retain);
46-
};
47-
t
48-
);
49-
let .release(t: TypeContext): Nil = (
50-
if t.discriminator-case-tag==(t as Tag::TypeContext).discriminator-case-tag {
51-
(t as Tag::TypeContext).tctx.release;
52-
(t as Tag::TypeContext).pctx.release;
53-
};
54-
mark-as-released(t);
55-
);
8+
let .into(pr: PhiContextRow, tt: Type<String>): String = "#\{pr.phi-id-or-zero} : \{pr.phi-tt-or-zero}";
569

5710
let mk-tctx(): TypeContext = TypeContext( [] : List<TypeContextRow>, mk-pbtree(type(U64), type(PhiContextRow)), false, false, c"" );
5811

SRC/type-constructor.lsts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ let type-lazy = tv(c"lazy");
4444
# new allocations = 0 (constant)
4545
let type-type-string = t1(c"Type",t0(c"String"));
4646

47+
# new allocations = 0 (constant)
48+
let type-cstring-literal = t0(c"CString") && t0(c"Literal");
49+
4750
# new allocations = 0 (constant)
4851
let type-linear-moved = t1(c"Linear",t0(c"Phi::Moved"));
4952

SRC/type-definition.lsts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,3 @@ type Type zero TAny implies MustRetain, MustRelease
1313
| TAny
1414
| TVar { name:CString, parameters:Vector<Type> }
1515
| TAnd { conjugate:Vector<Type> };
16-
17-
let .release(t: Type): Nil = (
18-
if t.discriminator-case-tag==(t as Tag::TGround).discriminator-case-tag {
19-
(t as Tag::TGround).parameters.release;
20-
};
21-
if t.discriminator-case-tag==(t as Tag::TAnd).discriminator-case-tag {
22-
(t as Tag::TAnd).conjugate.release;
23-
};
24-
mark-as-released(t);
25-
);
26-
27-
let .retain(t: Type): Type = (
28-
if t.discriminator-case-tag==(t as Tag::TGround).discriminator-case-tag {
29-
mark-as-released((t as Tag::TGround).parameters.retain);
30-
};
31-
if t.discriminator-case-tag==(t as Tag::TAnd).discriminator-case-tag {
32-
mark-as-released((t as Tag::TAnd).conjugate.retain);
33-
};
34-
t
35-
);
36-
37-
# TODO: remove
38-
let .release(tt: x[]): Nil = ();
39-
let .retain(tt: x[]): x[] = tt;

0 commit comments

Comments
 (0)