Skip to content

Commit

Permalink
Merge pull request #1136 from andrew-johnson-4/port-lm-to-lsts-faaelk
Browse files Browse the repository at this point in the history
Port lm to lsts faaelk
  • Loading branch information
andrew-johnson-4 authored Jan 22, 2025
2 parents ee2f58a + ea17858 commit 564ef42
Show file tree
Hide file tree
Showing 14 changed files with 21,937 additions and 21,812 deletions.
43,667 changes: 21,904 additions & 21,763 deletions BOOTSTRAP/cli.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lambda_mountain"
version = "1.20.33"
version = "1.20.34"
authors = ["Andrew <[email protected]>"]
license = "MIT"
description = "Typed Macro Assembler (backed by Coq proofs-of-correctness)"
Expand Down
11 changes: 11 additions & 0 deletions SRC/class-info-index.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

type StructLayout = LM1Style | CStyle;

type ClassInfo = ClassInfo { layout: StructLayout };
let class-info-index = {} :: HashtableEq<Tuple<CString,U64>,ClassInfo>;

let add-class-info(cls: Type, info: ClassInfo): Nil = (
class-info-index = class-info-index.bind( cls.ground-tag-and-arity, info );
);

let .is-class(cls: Type): U64 = class-info-index.has(cls.ground-tag-and-arity);
11 changes: 1 addition & 10 deletions SRC/class-of-tag.lm
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,7 @@ tag-to-class-index := (: (HashtableEq( 0_u64 0_u64 (as 0_u64 Tuple<String,Type>[

index-class-of-tag := λ(: tag String)(: class Type). (: (
(set tag-to-class-index (.bind( tag-to-class-index tag class )))
(match class (
()
( (TGround( cls _ )) (
(set class-to-yes-index (.bind( class-to-yes-index cls 1_u64 )))
))
( _ (
(print 'Unexpected\sClass\sIn\sindex-class-of-tag:\s_s)(print class)(print '\n_s)
(exit 1_u64)
))
))
(add-class-info( class (ClassInfo( LM1Style )) ))
) Nil);

class-of-tag := λ(: tag String). (: (
Expand Down
17 changes: 17 additions & 0 deletions SRC/ground-tag-and-arity.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

let .ground-tag-and-arity(tt: Type): (CString,U64) = (
match tt {
TGround { tag:c"Array", parameters:[_.. array-base..] } => (
let ga = array-base.ground-tag-and-arity;
( ga.first, ga.second + 1000 )
);
TGround { tag:c"Sized" } => (c"", 9999999);
TGround { tag=tag, parameters=parameters } => (tag, parameters.length);
TAny {} => (c"?", 0);
TVar {} => (c"", 9999999);
TAnd { left=left, right=right } => (
let lga = left.ground-tag-and-arity;
if lga.second==9999999 then right.ground-tag-and-arity else lga
);
}
);
1 change: 0 additions & 1 deletion SRC/index-ast.lm
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

import SRC/is-lm-struct.lm;
import SRC/plus.lm;
import SRC/print.lm;
import SRC/var-name-if-var.lm;
Expand Down
1 change: 0 additions & 1 deletion SRC/index-types.lm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import SRC/class-only-child.lm;
import SRC/index-of-tag.lm;
import SRC/size-of-class.lm;
import SRC/class-of-tag.lm;
import SRC/is-class.lm;
import SRC/is-only-child.lsts;
import SRC/is-sized-array.lsts;
import SRC/fields-of-tag.lm;
Expand Down
1 change: 0 additions & 1 deletion SRC/infer-type-definition.lm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
infer-type-definition := λ(: base-type Type)(: body AST)(: case-number U64). (: (
# This works but is too slow
(mark-class-exists( (tag-of base-type) ))
(mark-is-lm-struct( (tag-of base-type) ))
(let r 0_u64)
(match body (
()
Expand Down
7 changes: 0 additions & 7 deletions SRC/is-class.lm

This file was deleted.

10 changes: 0 additions & 10 deletions SRC/is-lm-struct.lm

This file was deleted.

17 changes: 0 additions & 17 deletions SRC/quick-prop.lsts
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@

let quick-prop = {} :: HashtableEq<(CString,U64),List<(Type,Type)>>;

let .ground-tag-and-arity(tt: Type): (CString,U64) = (
match tt {
TGround { tag:c"Array", parameters:[_.. array-base..] } => (
let ga = array-base.ground-tag-and-arity;
( ga.first, ga.second + 1000 )
);
TGround { tag:c"Sized" } => (c"", 9999999);
TGround { tag=tag, parameters=parameters } => (tag, parameters.length);
TAny {} => (c"?", 0);
TVar {} => (c"", 9999999);
TAnd { left=left, right=right } => (
let lga = left.ground-tag-and-arity;
if lga.second==9999999 then right.ground-tag-and-arity else lga
);
}
);

let add-quick-prop(pre: Type, pat: Type, post: Type): Nil = (
let key = pre.ground-tag-and-arity;
let val = quick-prop.lookup(key, ([] :: List<(Type,Type)>));
Expand Down
1 change: 1 addition & 0 deletions SRC/unit-globals.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ import SRC/typeof-tag.lsts;
import SRC/tctx-bind.lsts;

# global indexes
import SRC/class-info-index.lsts;
1 change: 1 addition & 0 deletions SRC/unit-types.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SRC/p.lsts;
import SRC/range.lsts;
import SRC/domain.lsts;
import SRC/arity.lsts;
import SRC/ground-tag-and-arity.lsts;
import SRC/slot.lsts;

# Boolean Queries
Expand Down
2 changes: 1 addition & 1 deletion SRC/with-only-class.lm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ with-only-class := λ(: tt Type). (: (
(if (non-zero rc) (set rt rc) ())
))
( (TGround( tag _ )) (
(if (is-class tag) (
(if (.is-class tt) (
(if (not(is-fragment tag)) (
(set rt tt)
) ())
Expand Down

0 comments on commit 564ef42

Please sign in to comment.