Skip to content

Commit

Permalink
Merge pull request #1201 from andrew-johnson-4/lm-to-lsts-23l4k
Browse files Browse the repository at this point in the history
Lm to lsts 23l4k
  • Loading branch information
andrew-johnson-4 authored Jan 30, 2025
2 parents 0ea3b2a + 27f5d6a commit 9ce0985
Show file tree
Hide file tree
Showing 10 changed files with 21,731 additions and 21,755 deletions.
43,416 changes: 21,698 additions & 21,718 deletions BOOTSTRAP/cli.c

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions PLUGINS/BACKEND/C/cc-args.lm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cc-args := λ(: callee-ctx FContext)(: caller-ctx FContext)(: lhs AST)(: rhs AST
()
( (App( le re )) (
(if (.is-t( kt '..._s )) (
(set kt (get-vararg-inner kt))
(set kt (.r1(.slot( kt '..._s ))))
(if (can-unify( kt (typeof re) )) (scope(
(if (.is-open kt) (
(set callee-ctx (union( callee-ctx (unify( kt (typeof re) )) )))
Expand Down Expand Up @@ -41,7 +41,7 @@ cc-args := λ(: callee-ctx FContext)(: caller-ctx FContext)(: lhs AST)(: rhs AST
))
)) (
(if (.is-t( kt '..._s )) (
(set kt (get-vararg-inner kt))
(set kt (.r1(.slot( kt '..._s ))))
(if (can-unify( kt (typeof rhs) )) (scope(
(if (.is-open kt) (
(set callee-ctx (union( callee-ctx (unify( kt (typeof rhs) )) )))
Expand Down Expand Up @@ -70,7 +70,7 @@ cc-args := λ(: callee-ctx FContext)(: caller-ctx FContext)(: lhs AST)(: rhs AST
()
( (App( le re )) (
(if (.is-t( kt '..._s )) (scope(
(set kt (get-vararg-inner kt))
(set kt (.r1(.slot( kt '..._s ))))
(if (.is-open kt) (
(set callee-ctx (union( callee-ctx (unify( kt (typeof re) )) )))
) ())
Expand All @@ -88,7 +88,7 @@ cc-args := λ(: callee-ctx FContext)(: caller-ctx FContext)(: lhs AST)(: rhs AST
))
) (
(if (.is-t( kt '..._s )) (scope(
(set kt (get-vararg-inner kt))
(set kt (.r1(.slot( kt '..._s ))))
(if (.is-open kt) (
(set callee-ctx (union( callee-ctx (unify( kt (typeof rhs) )) )))
) ())
Expand Down
2 changes: 1 addition & 1 deletion PLUGINS/BACKEND/C/compile-destructure-args.lm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ compile-destructure-args := λ(: tt Type)(: ctx FContext)(: lhs AST)(: offset I6
()
( (App( rst (App( (Lit( ':_s _ )) (App( (Var( k _ )) (AType kt) )) )) )) (
(if (.is-t( tt 'Cons_s )) (
(let rst-tt (.p2 tt))
(let rst-tt (.r2 tt))
(set ctx (compile-destructure-args( rst-tt ctx rst offset is-fragment )))
(if is-fragment (
(set kt (denormalize kt))
Expand Down
8 changes: 4 additions & 4 deletions PLUGINS/BACKEND/C/initialize-c-struct.lm
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ initialize-c-struct := λ(: ctx FContext)(: rval AST)(: case-number U64)(: field
(+(
(+(
(SAtom ',sizeof\[_s)
(mangle-c-type(.p2(.slot( par1 'Array_s ))))
(mangle-c-type(.r2(.slot( par1 'Array_s ))))
))
(+(
(SAtom '\]*_s)
(+(
(SAtom(tag-of(.p1(.slot( par1 'Array_s )))))
(SAtom(tag-of(.r1(.slot( par1 'Array_s )))))
(SAtom '\]\:_s)
))
))
Expand Down Expand Up @@ -70,12 +70,12 @@ initialize-c-struct := λ(: ctx FContext)(: rval AST)(: case-number U64)(: field
(+(
(+(
(SAtom ',sizeof\[_s)
(mangle-c-type(.p2(.slot( par1 'Array_s ))))
(mangle-c-type(.r2(.slot( par1 'Array_s ))))
))
(+(
(SAtom '\]*_s)
(+(
(SAtom(tag-of(.p1(.slot( par1 'Array_s )))))
(SAtom(tag-of(.r1(.slot( par1 'Array_s )))))
(SAtom '\]\:_s)
))
))
Expand Down
16 changes: 0 additions & 16 deletions SRC/get-vararg-inner.lm

This file was deleted.

1 change: 0 additions & 1 deletion SRC/index-types.lm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import SRC/is-lone-tag.lm;
import SRC/global-is-seen.lm;
import SRC/index-of-tag.lm;
import SRC/is-sized-array.lsts;
import SRC/get-vararg-inner.lm;
import SRC/maybe-specialize.lm;

import SRC/is-constructor.lm;
Expand Down
4 changes: 2 additions & 2 deletions SRC/infer-expr.lm
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ infer-expr-one := λ(: tctx TContext)(: term AST)(: scoped IsScoped)(: hint Type
()
( (App( kv m )) (
(infer-expr( tctx kv Unscoped TAny Call ))
(infer-expr( tctx m Unscoped (t3( 'HashtableEq_s (.p2(normalize(typeof kv))) (.p1(normalize(typeof kv))) )) Used ))
(infer-expr( tctx m Unscoped (t3( 'HashtableEq_s (.r2(normalize(typeof kv))) (.r1(normalize(typeof kv))) )) Used ))
))
( _ () )
))
Expand Down Expand Up @@ -257,7 +257,7 @@ infer-expr-one := λ(: tctx TContext)(: term AST)(: scoped IsScoped)(: hint Type
(ascript-normal( term rt ))
(if (==( (var-name-if-var l) 'Rc_s )) (
(maybe-specialize( 'inc_s (typeof-var-raw( term tctx 'inc_s ))
(t2( 'Rc_s (.p2(.slot( (.p2(.slot( (.p1 (typeof r)) 'Array_s ))) 'Tuple_s ))) )) # invert Rc constructor to get type parameter
(t2( 'Rc_s (.r2(.slot( (.r2(.slot( (.r1 (typeof r)) 'Array_s ))) 'Tuple_s ))) )) # invert Rc constructor to get type parameter
))
) ())

Expand Down
4 changes: 2 additions & 2 deletions SRC/is-constructor.lm
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ is-constructor := λ(: tt Type). (: (
()
( (TAnd( t1 t2 )) (set r (||( (is-constructor t1) (is-constructor t2) ))) )
( (TGround( 'Constructor_s _ )) (set r 1_u64) )
( (TGround( 'Arrow_s _ )) (set r (is-constructor(.p2 tt))) )
( (TGround( 'Cons_s _ )) (set r (is-constructor(.p2 tt))) )
( (TGround( 'Arrow_s _ )) (set r (is-constructor(.r2 tt))) )
( (TGround( 'Cons_s _ )) (set r (is-constructor(.r2 tt))) )
( _ () )
))
r
Expand Down
19 changes: 16 additions & 3 deletions SRC/p.lsts
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@

let .p(tt: Type, i: U64): Type = (
let .r(tt: Type, i: U64): Type = (
match tt {
TGround { parameters=parameters } => parameters.nth(i, TAny);
_ => TAny;
}
);
let .p1(tt: Type): Type = tt.p(0);
let .p2(tt: Type): Type = tt.p(1);
let .r1(tt: Type): Type = tt.r(0);
let .r2(tt: Type): Type = tt.r(1);
let .r3(tt: Type): Type = tt.r(2);
let .r4(tt: Type): Type = tt.r(3);

let .l(tt: Type, i: U64): Type = (
match tt {
TGround { parameters=parameters } => parameters.reverse.nth(i, TAny);
_ => TAny;
}
);
let .l1(tt: Type): Type = tt.l(0);
let .l2(tt: Type): Type = tt.l(1);
let .l3(tt: Type): Type = tt.l(2);
let .l4(tt: Type): Type = tt.l(3);
8 changes: 4 additions & 4 deletions tests/unit/type-queries.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ assert( t-A.is-t(c"A") );
assert( not(t-A.is-t(c"B")) );
assert( t-B.is-t(c"B") );
assert( not(t-B.is-t(c"A")) );
assert( t-B.p1.is-t(c"A") );
assert( not(t-B.p1.is-t(c"B")) );
assert( t-B.r1.is-t(c"A") );
assert( not(t-B.r1.is-t(c"B")) );
assert( t-AB.is-t(c"A") );
assert( t-AB.is-t(c"B") );
assert( not(t-x.is-t(c"x")) );
Expand All @@ -28,7 +28,7 @@ assert( not(t-B.is-open) );
assert( not(t-AB.is-open) );
assert( t-x.is-open );
assert( t-Ax.is-open );
assert( t-Ax.p1.is-open );
assert( t-Ax.r1.is-open );
assert( t-C.is-open );

# .is-arrow tests
Expand All @@ -40,7 +40,7 @@ assert( not(t-Ax.is-arrow) );
assert( not(t-C.is-arrow) );
assert( t-f.is-arrow );
assert( t-g.is-arrow );
assert( t-g.p2.is-arrow );
assert( t-g.r2.is-arrow );

# domain / range tests
assert( t-f.domain.is-t(c"A") );
Expand Down

0 comments on commit 9ce0985

Please sign in to comment.