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
6,983 changes: 3,492 additions & 3,491 deletions BOOTSTRAP/cli.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ LSTSFLAGS = MALLOC_CHECK_=3
# recommendation: ulimit -s unlimited

dev: install-production
lm tests/promises/typechecking/must-use-reject-2.lsts
lm SRC/dev-index.lsts
$(CC) $(CFLAGS) tmp.c
./a.out

Expand Down
14 changes: 14 additions & 0 deletions SRC/dev-index.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import SRC/unit-util.lsts;
import SRC/dev-unit-type-core.lsts;
import SRC/dev-unit-ast-core.lsts;
import SRC/dev-unit-tctx-core.lsts;
import SRC/dev-unit-prop-core.lsts;
import SRC/dev-unit-ascript-core.lsts;
import SRC/dev-unit-typecheck-core.lsts;
import SRC/dev-unit-backend-core.lsts;
import SRC/unit-main-core.lsts;

import PLUGINS/FRONTEND/LSTS/index.lsts;
import PLUGINS/BACKEND/C/index.lsts;
import PLUGINS/FRONTEND/C/index.lsts;
107 changes: 107 additions & 0 deletions SRC/dev-type-constructor.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

# new allocations = 0
let ta = TAny;

# new allocations = 1
# 1 from close
# 0 from 0 length list
# this is an upper bound, because the list implementation should be replaced with vector eventually
let t0(tag: CString): Type = TGround(tag, mk-vector(type(Type)));

# new allocations = 2
# 1 from close
# 1 from 1 length list
# this is an upper bound, because the list implementation should be replaced with vector eventually
let t1(tag: CString, p1: Type): Type = TGround(tag, mk-vector(type(Type)).push(p1));

# new allocations = 3
# 1 from close
# 2 from 2 length list
# this is an upper bound, because the list implementation should be replaced with vector eventually
let t2(tag: CString, p1: Type, p2: Type): Type = TGround(tag, mk-vector(type(Type)).push(p2).push(p1));

# new allocations = 0
let tv(name: CString): Type = TVar(name);

# new allocations = 0 if either argument is ?
# | 1
let $"&&"(lt: Type, rt: Type): Type = (
match (lt, rt) {
Tuple{first:TAny{}} => rt;
Tuple{second:TAny{}} => lt;
Tuple{first:TAnd{lconjugate=conjugate},second:TAnd{rconjugate=conjugate}} => (
let result = mk-vector(type(Type), lconjugate.length+rconjugate.length);
for vector c in lconjugate { result = result.push(c) };
for vector c in rconjugate { result = result.push(c) };
result = result.sort;
TAnd(result)
);
Tuple{first=first,second:TAnd{rconjugate=conjugate}} => (
let result = mk-vector(type(Type), 1+rconjugate.length);
result = result.push(first);
for vector c in rconjugate { result = result.push(c) };
result = result.sort;
TAnd(result)
);
Tuple{first:TAnd{lconjugate=conjugate},second=second} => (
let result = mk-vector(type(Type), lconjugate.length+1);
for vector c in lconjugate { result = result.push(c) };
result = result.push(second);
result = result.sort;
TAnd(result)
);
Tuple{first=first,second=second} => (
let result = mk-vector(type(Type), 2);
result = result.push(first);
result = result.push(second);
result = result.sort;
TAnd(result)
);
};
);

# new allocations = 0 if either argument is ?
# | 1
let .extend(lt: Type, rt: Type): Type = (
match (lt, rt) {
Tuple{first:TAny{}} => rt;
Tuple{second:TAny{}} => lt;
Tuple{first:TAnd{lconjugate=conjugate},second:TAnd{rconjugate=conjugate}} => (
for vector c in rconjugate { lconjugate = lconjugate.push(c) };
lconjugate = lconjugate.sort;
TAnd(lconjugate)
);
Tuple{first=first,second:TAnd{rconjugate=conjugate}} => (
let result = mk-vector(type(Type), 1+rconjugate.length);
result = result.push(first);
for vector c in rconjugate { result = result.push(c) };
result = result.sort;
TAnd(result)
);
Tuple{first:TAnd{lconjugate=conjugate},second=second} => (
lconjugate = lconjugate.push(second);
lconjugate = lconjugate.sort;
TAnd(lconjugate)
);
Tuple{first=first,second=second} => (
let result = mk-vector(type(Type), 2);
result = result.push(first);
result = result.push(second);
result = result.sort;
TAnd(result)
);
};
);

# new allocations = 1
# this is an upper bound, because the list implementation should be replaced with vector eventually
let ts(tag: CString, ps: Vector<Type>): Type = TGround( tag, ps );

# new allocations = 0
let tand(t: Vector<Type>): Type = TAnd(t.sort);

# new allocations = 1
let tand(tt: Type): Type = TAnd(mk-vector(type(Type)).push(tt));

# new allocations = 0
let $"||"(lt: Type, rt: Type): Type = if non-zero(lt) then lt else rt;
37 changes: 37 additions & 0 deletions SRC/dev-type-definition.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

# TGround needs an ordered enum or else unification may not work right
# TGround = 0
# TAny = 1
# TVar = 2
# TAnd = 3
# TODO: replace TGround List implementation with Vector which is much more efficient
# for this reason allocation counts only have an upper bound rather than exact bound
type Type zero TAny implies MustRetain, MustRelease
= TGround { tag:CString, parameters:Vector<Type> }
| TAny
| TVar { name:CString }
| TAnd { conjugate:Vector<Type> };

let .release(t: Type): Nil = (
if t.discriminator-case-tag==(t as Tag::TGround).discriminator-case-tag {
(t as Tag::TGround).parameters.release;
};
if t.discriminator-case-tag==(t as Tag::TAnd).discriminator-case-tag {
(t as Tag::TAnd).conjugate.release;
};
mark-as-released(t);
);

let .retain(t: Type): Type = (
if t.discriminator-case-tag==(t as Tag::TGround).discriminator-case-tag {
mark-as-released((t as Tag::TGround).parameters.retain);
};
if t.discriminator-case-tag==(t as Tag::TAnd).discriminator-case-tag {
mark-as-released((t as Tag::TAnd).conjugate.retain);
};
t
);

# TODO: remove
let .release(tt: x[]): Nil = ();
let .retain(tt: x[]): x[] = tt;
10 changes: 10 additions & 0 deletions SRC/dev-unit-ascript-core.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import SRC/dev-unit-prop-core.lsts;

import SRC/ascript-types-have-changed.lsts;
import SRC/ascript-type-index.lsts;
import SRC/ascript-concrete-index.lsts;
import SRC/ascript-datatype-index.lsts;
import SRC/ascript-with-only-datatype.lsts;
import SRC/ascript-ascript-integrated.lsts;
import SRC/ascript-tctx-resurrect.lsts;
33 changes: 33 additions & 0 deletions SRC/dev-unit-ast-core.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

import SRC/dev-unit-type-core.lsts;
import SRC/ast-definition.lsts;
import SRC/ast-constructor.lsts;
import SRC/ast-location.lsts;
import SRC/ast-with-location.lsts;
import SRC/ast-without-location.lsts;
import SRC/ast-with-location-preserve.lsts;
import SRC/ast-mk-location.lsts;
import SRC/ast-mk-token.lsts;
import SRC/ast-exit-error.lsts;
import SRC/ast-compare.lsts;
import SRC/token-compare.lsts;
import SRC/token-with-key.lsts;
import SRC/token-with-location.lsts;
import SRC/token-without-location.lsts;
import SRC/loc-into-string.lsts;
import SRC/ast-formatted-location.lsts;
import SRC/ast-into-string.lsts;
import SRC/token-unique.lsts;
import SRC/ast-unique.lsts;
import SRC/ast-plus.lsts;
import SRC/ast-var-name-if-var.lsts;
import SRC/ast-misc-todo-remove-or-stabilize.lsts;
import SRC/ast-misc-globals.lsts;
import SRC/ast-acontext-apply.lsts;
import SRC/ast-acontext-bind.lsts;
import SRC/ast-acontext-substitute.lsts;
import SRC/ast-acontext-union.lsts;
import SRC/ast-substitute-uuids.lsts;
import SRC/ast-acontext-to-string.lsts;
import SRC/ast-unroll-seq.lsts;
import SRC/ast-hash.lsts;
14 changes: 14 additions & 0 deletions SRC/dev-unit-backend-core.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import SRC/dev-unit-typecheck-core.lsts;

import SRC/backend-fragment-definition.lsts;
import SRC/backend-mk-fragment.lsts;
import SRC/backend-mk-expression.lsts;
import SRC/backend-mk-fctx.lsts;
import SRC/backend-fctx-bind.lsts;
import SRC/backend-ctx-union.lsts;
import SRC/backend-fctx-lookup.lsts;
import SRC/backend-fragment-set.lsts;
import SRC/backend-fragment-get.lsts;
import SRC/backend-bind-varargs.lsts;
import SRC/backend-global-ctx.lsts;
28 changes: 28 additions & 0 deletions SRC/dev-unit-prop-core.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

import SRC/dev-unit-tctx-core.lsts;
import SRC/prop-core.lsts;
import SRC/prop-alias.lsts;
import SRC/prop-is-special.lsts;
import SRC/prop-normalize.lsts;
import SRC/prop-denormalize.lsts;
import SRC/prop-tctx-apply.lsts;
import SRC/prop-tctx-normalize.lsts;
import SRC/prop-tctx-find-callable.lsts;
import SRC/prop-stack-to-specialize.lsts;
import SRC/prop-tctx-apply-callable.lsts;
import SRC/prop-tctx-phi-merge.lsts;
import SRC/prop-tctx-least-upper-bound.lsts;
import SRC/prop-tctx-definition.lsts;
import SRC/prop-expand-implied-phi.lsts;
import SRC/prop-is-phi-type.lsts;
import SRC/prop-phi-as-state.lsts;
import SRC/prop-phi-override.lsts;
import SRC/prop-misc-todo-remove-or-stabilize.lsts;
import SRC/prop-tctx-substitute.lsts;
import SRC/prop-typeof-var-raw.lsts;
import SRC/prop-typeof-tag.lsts;
import SRC/prop-type-datatype.lsts;
import SRC/prop-is-lone-tag.lsts;
import SRC/prop-is-suffixed.lsts;
import SRC/prop-global-is-seen.lsts;
import SRC/prop-is-macro-head.lsts;
26 changes: 26 additions & 0 deletions SRC/dev-unit-tctx-core.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

import SRC/dev-unit-ast-core.lsts;
import SRC/tctx-definition.lsts;
import SRC/tctx-bind.lsts;
import SRC/tctx-lookup.lsts;
import SRC/tctx-unify.lsts;
import SRC/tctx-and.lsts;
import SRC/tctx-or.lsts;
import SRC/tctx-union.lsts;
import SRC/tctx-substitute.lsts;
import SRC/tctx-compare.lsts;
import SRC/tctx-phi-move-args.lsts;
import SRC/tctx-phi-move.lsts;
import SRC/tctx-phi-fresh.lsts;
import SRC/tctx-phi-append.lsts;
import SRC/tctx-with-phi.lsts;
import SRC/tctx-with-tctx.lsts;
import SRC/tctx-with-pctx.lsts;
import SRC/tctx-without-phi-keep-state.lsts;
import SRC/tctx-with-phi-id-if-phi-state.lsts;
import SRC/tctx-into-string.lsts;
import SRC/tctx-phi-move-all.lsts;
import SRC/tctx-phi-initialize.lsts;
import SRC/tctx-substitute.lsts;
import SRC/tctx-misc-globals.lsts;
import SRC/typecheck-infer-tctx.lsts;
42 changes: 42 additions & 0 deletions SRC/dev-unit-type-core.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

import SRC/unit-util.lsts;

import SRC/dev-type-definition.lsts;
import SRC/dev-type-constructor.lsts;
import SRC/type-destructor.lsts;
import SRC/type-compare.lsts;
import SRC/type-domain.lsts;
import SRC/type-range.lsts;
import SRC/type-is-and.lsts;
import SRC/type-is-t.lsts;
import SRC/type-slot.lsts;
import SRC/type-is-arrow.lsts;
import SRC/type-is-open.lsts;
import SRC/type-is-moved.lsts;
import SRC/type-is-linear-live.lsts;
import SRC/type-is-linear-dead.lsts;
import SRC/type-simple-tag.lsts;
import SRC/type-simple-arity.lsts;
import SRC/type-can-unify.lsts;
import SRC/type-remove-info.lsts;
import SRC/type-ground-tag-and-arity.lsts;
import SRC/type-into-string.lsts;
import SRC/type-is-any-arg-t.lsts;
import SRC/type-hash.lsts;
import SRC/type-cons-root.lsts;
import SRC/type-sanitize-phi.lsts;
import SRC/type-without-phi.lsts;
import SRC/type-without-any-phi.lsts;
import SRC/type-without-slot.lsts;
import SRC/type-move-linear.lsts;
import SRC/type-can-apply.lsts;
import SRC/type-can-receive.lsts;
import SRC/type-without-phi-keep-state.lsts;
import SRC/type-without-phi-keep-id.lsts;
import SRC/type-most-special.lsts;
import SRC/type-as-return-hint.lsts;
import SRC/type-resurrect.lsts;
import SRC/type-cons-tail-or-self.lsts;
import SRC/type-without-modifiers.lsts;
import SRC/type-with-only-phi.lsts;
import SRC/type-reify-type-variables.lsts;
46 changes: 46 additions & 0 deletions SRC/dev-unit-typecheck-core.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

import SRC/dev-unit-ascript-core.lsts;

import SRC/profile-count-ast.lsts;

import SRC/typecheck-accept-interface.lsts;
import SRC/typecheck-interface-index.lsts;
import SRC/typecheck-infer-expr.lsts;
import SRC/typecheck-free-and-seen.lsts;
import SRC/typecheck-var-to-def-index.lsts;
import SRC/typecheck-decorate-var-to-def.lsts;
import SRC/typecheck-release-locals.lsts;
import SRC/typecheck-phi-merge.lsts;
import SRC/typecheck-validate-pctx-del.lsts;
import SRC/typecheck-typeof-var.lsts;
import SRC/typecheck-defof-var.lsts;
import SRC/typecheck-maybe-retain.lsts;
import SRC/typecheck-infer-ctx.lsts;
import SRC/typecheck-typeof-lhs.lsts;
import SRC/typecheck-macro-table.lsts;
import SRC/typecheck-std-apply-macro.lsts;
import SRC/typecheck-std-apply-macro-candidates.lsts;
import SRC/typecheck-std-maybe-release-after-call.lsts;
import SRC/typecheck-index-of-tag.lsts;
import SRC/typecheck-extract-uuids.lsts;
import SRC/typecheck-std-direct-destructure-macro.lsts;
import SRC/typecheck-tctx-substitute-lhs.lsts;
import SRC/typecheck-tctx-substitute.lsts;
import SRC/typecheck-try-destructure-macro.lsts;
import SRC/typecheck-preprocess-apply-hard.lsts;
import SRC/typecheck-preprocess-apply-literals.lsts;
import SRC/typecheck-preprocess-apply-locations.lsts;
import SRC/typecheck-preprocess-apply.lsts;
import SRC/typecheck-validate-interfaces.lsts;
import SRC/typecheck-index-typedefs.lsts;
import SRC/typecheck-preprocess.lsts;
import SRC/typecheck-infer-type-definition.lsts;
import SRC/typecheck-assert-no-infinite-types.lsts;
import SRC/typecheck-assert-one-typed.lsts;
import SRC/typecheck-assert-well-typed.lsts;
import SRC/typecheck-specialize.lsts;
import SRC/typecheck-infer-global-terms.lsts;
import SRC/typecheck-typecheck.lsts;
import SRC/typecheck-plugins-frontends.lsts;
import SRC/typecheck-plugins-backends.lsts;
import SRC/typecheck-index-plugins.lsts;
Loading
Loading