Skip to content

Commit

Permalink
Merge pull request #1215 from andrew-johnson-4/lm-to-lsts-feqpfe
Browse files Browse the repository at this point in the history
Lm to lsts feqpfe
  • Loading branch information
andrew-johnson-4 authored Feb 2, 2025
2 parents 749bca8 + 668de06 commit 09cf7a3
Show file tree
Hide file tree
Showing 14 changed files with 21,367 additions and 21,406 deletions.
42,652 changes: 21,319 additions & 21,333 deletions BOOTSTRAP/cli.c

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions PLATFORM/C/LIB/list.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,10 @@ let .lookup(ls: List<Tuple<k,v>>, key: k, default: v): v = (
};
default;
);
let .lookup(ls: List<Tuple<k,v1,v2>>, key: k, default: Tuple<v1,v2>): Tuple<v1,v2> = (
let found = false;
for Tuple{lkey=first, val1=second, val2=third} in ls {
if not(found) && key==lkey { default=Tuple{val1,val2}; found=true; }
};
default;
);
4 changes: 2 additions & 2 deletions PLUGINS/BACKEND/C/compile-c-typedef.lm
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ compile-c-typedef-concrete := λ(: tctx Maybe<TContext>)(: base-type Type)(: bod
compile-c-type-body-of-base-type := (: (HashtableEq( 0_u64 0_u64 (as 0_u64 Tuple<String,Tuple<Type,AST>>[]) )) HashtableEq<String,Tuple<Type,AST>>);

compile-c-typedef := λ(: base-type Type)(: body AST). (: (
(set compile-c-type-body-of-base-type (.bind( compile-c-type-body-of-base-type (tag-of base-type) (Tuple( base-type body )) )))
(set compile-c-type-body-of-base-type (.bind( compile-c-type-body-of-base-type (.tag base-type) (Tuple( base-type body )) )))
(if (.is-lm-struct base-type) (
(if (.is-open base-type) () (
(compile-c-typedef-concrete( (: None Maybe<TContext>) base-type body ))
Expand Down Expand Up @@ -196,7 +196,7 @@ compile-c-mark-field-as-seen := λ(: tt Type). (: (
))
( _ () )
))
(let base-body (.lookup( compile-c-type-body-of-base-type (tag-of tt) (Tuple( TAny ASTEOF )) )))
(let base-body (.lookup( compile-c-type-body-of-base-type (.tag tt) (Tuple( TAny ASTEOF )) )))
(let base-type (.first base-body))
(let body (.second base-body))
(if (&&( (non-zero body) (not(.lookup( is-cstruct-hard-compiled-index tt 0_u64 ))) )) (
Expand Down
4 changes: 2 additions & 2 deletions PLUGINS/BACKEND/C/initialize-c-struct.lm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ initialize-c-struct := λ(: ctx FContext)(: rval AST)(: case-number U64)(: field
(+(
(SAtom '\]*_s)
(+(
(SAtom(tag-of(.r1(.slot( par1 'Array_s )))))
(SAtom(.tag(.r1(.slot( par1 'Array_s )))))
(SAtom '\]\:_s)
))
))
Expand Down Expand Up @@ -75,7 +75,7 @@ initialize-c-struct := λ(: ctx FContext)(: rval AST)(: case-number U64)(: field
(+(
(SAtom '\]*_s)
(+(
(SAtom(tag-of(.r1(.slot( par1 'Array_s )))))
(SAtom(.tag(.r1(.slot( par1 'Array_s )))))
(SAtom '\]\:_s)
))
))
Expand Down
7 changes: 7 additions & 0 deletions SRC/cons-tail-or-self.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

let cons-tail-or-self(tt: Type): Type = (
match tt {
TGround{tag:c"Cons",parameters:[tl..hd..]} => tl;
_ => tt;
}
);
9 changes: 0 additions & 9 deletions SRC/cons-tail.lm

This file was deleted.

2 changes: 0 additions & 2 deletions SRC/index-types.lm
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ import SRC/index-of-tag.lm;
import SRC/is-sized-array.lsts;
import SRC/maybe-specialize.lm;

import SRC/tag-of.lm;
import SRC/has-infinite.lm;
import SRC/has-forward.lm;

import SRC/type-of-s-with-fields.lm;

import SRC/typeof-lhs.lm;
import SRC/cons-tail.lm;
import SRC/apply.lm;
import SRC/apply.lsts;
import SRC/apply-plural.lm;
Expand Down
2 changes: 1 addition & 1 deletion SRC/infer-expr.lm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ infer-expr-one := λ(: tctx Maybe<TContext>)(: term AST)(: scoped IsScoped)(: hi
(set tctx (infer-expr( tctx t Unscoped TAny used )))
(let inner-tt (typeof t))
(if (non-zero inner-tt) (
(if (.has-prefix( (tag-of tt) 'Tag::_s )) (
(if (.has-prefix( (.tag tt) 'Tag::_s )) (
(set tt (&&( tt inner-tt )))
) (
(let inner-class (.with-only-class inner-tt))
Expand Down
10 changes: 0 additions & 10 deletions SRC/tag-of.lm

This file was deleted.

46 changes: 0 additions & 46 deletions SRC/tctx-substitute.lm

This file was deleted.

19 changes: 19 additions & 0 deletions SRC/tctx-substitute.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

let substitute(tctx: Maybe<TContext>, tt: List<Type>): List<Type> = (
match tt {
LCons{head=head,tail=tail} => cons( substitute(tctx,head), substitute(tctx,tail) );
_ => tt;
}
);

let substitute(tctx: Maybe<TContext>, tt: Type): Type = (
match tt {
TAnd{left=left,right=right} => TAnd{close(substitute(tctx,left)), close(substitute(tctx,right))};
TGround{tag=tag,parameters=parameters} => TGround{tag,close(substitute(tctx,parameters))};
TVar{name=name} => (
let ta = tctx.get-or([] :: List<Tuple<CString,Type,AST>>).lookup(name,Tuple{TAny,ASTEOF});
if non-zero(ta.first) then ta.first else tt;
);
_ => tt;
}
);
7 changes: 7 additions & 0 deletions SRC/type-tag.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

let .tag(tt: Type): CString = (
match tt {
TGround{tag=tag} => tag;
_ => c"";
}
);
2 changes: 1 addition & 1 deletion SRC/unit-inference.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SRC/inference-definitions.lsts;
# unification
import SRC/can-unify.lsts;
import SRC/unify.lsts;
import SRC/tctx-substitute.lm;
import SRC/tctx-substitute.lsts;
import SRC/tctx-union.lsts;
import SRC/tctx-and.lsts;
import SRC/tctx-bind.lsts;
Expand Down
2 changes: 2 additions & 0 deletions SRC/unit-types.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import SRC/domain.lsts;
import SRC/arity.lsts;
import SRC/ground-tag-and-arity.lsts;
import SRC/slot.lsts;
import SRC/type-tag.lsts;
import SRC/cons-tail-or-self.lsts;

# Boolean Queries
import SRC/type-cmp.lsts;
Expand Down

0 comments on commit 09cf7a3

Please sign in to comment.