This commit is contained in:
2026-02-23 18:16:07 -06:00
parent 060a494f47
commit 70f560550f
5 changed files with 5 additions and 144 deletions

5
.gitignore vendored
View File

@@ -1,7 +1,12 @@
.git/
.obj/
website/public/
website/site/
website/.hugo_build.lock
.cache
.cell
cell
libcell_runtime*
bin/
build/
*.zip

View File

@@ -1,27 +0,0 @@
// Test backward type propagation
// Functions that use typed ops on parameters should have
// parameter types inferred and type checks eliminated
var sum_ints = function(a, b, c) {
return a + b + c
}
var count_down = function(n) {
var i = n
var total = 0
while (i > 0) {
total = total + i
i = i - 1
}
return total
}
var concat_all = function(a, b, c) {
return a + b + c
}
if (sum_ints(1, 2, 3) != 6) { log.error("FAIL sum_ints") }
if (count_down(5) != 15) { log.error("FAIL count_down") }
if (concat_all("a", "b", "c") != "abc") { log.error("FAIL concat_all") }
log.test("backward type tests passed")

View File

@@ -1,12 +0,0 @@
// Test array guard emission and optimization
var a = [1, 2, 3]
push(a, 4)
var v = a[]
var f = function(arr) {
push(arr, 99)
var x = arr[]
return x
}
f(a)

View File

@@ -1,63 +0,0 @@
// Test all inlined intrinsics
var arr = [1, 2, 3]
var rec = {a: 1}
var fn = function() { return 1 }
var txt = "hello"
var num = 42
var boo = true
// is_array
if (!is_array(arr)) { log.error("FAIL is_array(arr)") }
if (is_array(rec)) { log.error("FAIL is_array(rec)") }
if (is_array(42)) { log.error("FAIL is_array(42)") }
// is_object
if (!is_object(rec)) { log.error("FAIL is_object(rec)") }
if (is_object(arr)) { log.error("FAIL is_object(arr)") }
if (is_object(42)) { log.error("FAIL is_object(42)") }
// is_function
if (!is_function(fn)) { log.error("FAIL is_function(fn)") }
if (is_function(rec)) { log.error("FAIL is_function(rec)") }
// is_stone
var frozen = stone([1, 2])
if (!is_stone(frozen)) { log.error("FAIL is_stone(frozen)") }
if (is_stone(arr)) { log.error("FAIL is_stone(arr)") }
if (!is_stone(42)) { log.error("FAIL is_stone(42)") }
if (!is_stone("hi")) { log.error("FAIL is_stone(str)") }
// length
if (length(arr) != 3) { log.error("FAIL length(arr)") }
if (length(txt) != 5) { log.error("FAIL length(txt)") }
if (length([]) != 0) { log.error("FAIL length([])") }
// is_integer (already existed but now inlined)
if (!is_integer(42)) { log.error("FAIL is_integer(42)") }
if (is_integer(3.14)) { log.error("FAIL is_integer(3.14)") }
// is_text
if (!is_text("hi")) { log.error("FAIL is_text(hi)") }
if (is_text(42)) { log.error("FAIL is_text(42)") }
// is_number
if (!is_number(42)) { log.error("FAIL is_number(42)") }
if (!is_number(3.14)) { log.error("FAIL is_number(3.14)") }
if (is_number("hi")) { log.error("FAIL is_number(hi)") }
// is_logical
if (!is_logical(true)) { log.error("FAIL is_logical(true)") }
if (is_logical(42)) { log.error("FAIL is_logical(42)") }
// is_null
if (!is_null(null)) { log.error("FAIL is_null(null)") }
if (is_null(42)) { log.error("FAIL is_null(42)") }
// push (inlined)
var a = [1]
push(a, 2)
push(a, 3)
if (length(a) != 3) { log.error("FAIL push length") }
if (a[2] != 3) { log.error("FAIL push value") }
log.test("all intrinsic tests passed")

View File

@@ -1,42 +0,0 @@
var fd = use("fd")
var json = use("json")
var tokenize = use("tokenize")
var parse = use("parse")
var fold = use("fold")
var src = text(fd.slurp("internal/bootstrap.cm"))
var tok_result = tokenize(src, "bootstrap.cm")
var ast = parse(tok_result.tokens, src, "bootstrap.cm", tokenize)
var i = 0
var folded = null
var ast_json = null
var f = null
var bytecode = null
var has_errors = ast.errors != null && length(ast.errors) > 0
if (has_errors) {
log.error("PARSE ERRORS:")
while (i < length(ast.errors)) {
log.error(text(ast.errors[i].line) + ":" + text(ast.errors[i].column) + " " + ast.errors[i].message)
i = i + 1
}
} else {
log.test("Parse OK")
log.test(" statements: " + text(length(ast.statements)))
if (ast.functions != null) {
log.test(" functions: " + text(length(ast.functions)))
} else {
log.test(" functions: null")
}
folded = fold(ast)
ast_json = json.encode(folded)
f = fd.open("/tmp/bootstrap_ast.json", "w")
fd.write(f, ast_json)
fd.close(f)
log.test("Wrote AST to /tmp/bootstrap_ast.json")
bytecode = mach_compile_ast("bootstrap", ast_json)
log.test("Bytecode size: " + text(length(bytecode)))
f = fd.open("/tmp/bootstrap_test.mach", "w")
fd.write(f, bytecode)
fd.close(f)
log.test("Wrote bytecode to /tmp/bootstrap_test.mach")
}