wary booleans

This commit is contained in:
2026-02-21 20:42:17 -06:00
parent 8f415fea80
commit 8e96379377
9 changed files with 34034 additions and 36303 deletions

View File

@@ -1035,7 +1035,7 @@ var mcode = function(ast) {
if (nargs <= 2) {
emit_forward_loop(fwd_L, body_fn)
} else {
emit_jump_cond("jump_true", args.rev, rev_label)
emit_jump_cond("wary_true", args.rev, rev_label)
emit_forward_loop(fwd_L, body_fn)
emit_jump(final_label)
emit_label(rev_label)
@@ -1093,7 +1093,7 @@ var mcode = function(ast) {
emit_3("setarg", f, 1, item)
emit_2("invoke", f, val)
emit_label(call_done_label)
emit_jump_cond("jump_false", val, ret_false)
emit_jump_cond("wary_false", val, ret_false)
emit_3("add", i, i, one)
emit_jump(loop_label)
emit_label(ret_true)
@@ -1146,7 +1146,7 @@ var mcode = function(ast) {
emit_3("setarg", f, 1, item)
emit_2("invoke", f, val)
emit_label(call_done_label)
emit_jump_cond("jump_true", val, ret_true)
emit_jump_cond("wary_true", val, ret_true)
emit_3("add", i, i, one)
emit_jump(loop_label)
emit_label(ret_true)
@@ -1186,7 +1186,7 @@ var mcode = function(ast) {
emit_2("length", fn_arity, fn_slot)
emit_forward_loop(L, function(L) {
emit_arity_call(ctx, [L.item, L.i], 2)
emit_jump_cond("jump_false", val, skip)
emit_jump_cond("wary_false", val, skip)
emit_2("push", result, L.item)
emit_label(skip)
return null
@@ -1240,7 +1240,7 @@ var mcode = function(ast) {
}
var fn_body = function(L) {
emit_arity_call(ctx, [L.item, L.i], 2)
emit_jump_cond("jump_true", val, found_label)
emit_jump_cond("wary_true", val, found_label)
return null
}
emit_2("length", len, arr_slot)
@@ -1253,7 +1253,7 @@ var mcode = function(ast) {
if (nargs <= 2) {
emit_forward_loop(vL, val_body)
} else {
emit_jump_cond("jump_true", args.rev, vrev)
emit_jump_cond("wary_true", args.rev, vrev)
if (nargs >= 4 && args.from >= 0) {
emit_2("move", i, args.from)
}
@@ -1281,7 +1281,7 @@ var mcode = function(ast) {
if (nargs <= 2) {
emit_forward_loop(fL, fn_body)
} else {
emit_jump_cond("jump_true", args.rev, frev)
emit_jump_cond("wary_true", args.rev, frev)
if (nargs >= 4 && args.from >= 0) {
emit_2("move", i, args.from)
}
@@ -1485,7 +1485,7 @@ var mcode = function(ast) {
// No initial
emit_3("lt", check, zero, len)
emit_jump_cond("jump_false", check, null_label)
emit_jump_cond("jump_true", rev_slot, no_init_rev)
emit_jump_cond("wary_true", rev_slot, no_init_rev)
// No initial, forward
emit_3("load_index", acc, arr_slot, zero)
emit_2("move", i, one)
@@ -1507,7 +1507,7 @@ var mcode = function(ast) {
emit_jump(final_label)
// Has initial
emit_label(has_init)
emit_jump_cond("jump_true", rev_slot, init_rev)
emit_jump_cond("wary_true", rev_slot, init_rev)
// Has initial, forward
emit_2("move", acc, init_slot)
emit_2("int", i, 0)
@@ -1554,7 +1554,7 @@ var mcode = function(ast) {
left_slot = gen_expr(left, -1)
dest = alloc_slot()
emit_2("move", dest, left_slot)
emit_jump_cond("jump_false", dest, end_label)
emit_jump_cond("wary_false", dest, end_label)
right_slot = gen_expr(right, -1)
emit_2("move", dest, right_slot)
emit_label(end_label)
@@ -1566,7 +1566,7 @@ var mcode = function(ast) {
left_slot = gen_expr(left, -1)
dest = alloc_slot()
emit_2("move", dest, left_slot)
emit_jump_cond("jump_true", dest, end_label)
emit_jump_cond("wary_true", dest, end_label)
right_slot = gen_expr(right, -1)
emit_2("move", dest, right_slot)
emit_label(end_label)
@@ -2361,7 +2361,7 @@ var mcode = function(ast) {
else_label = gen_label("tern_else")
end_label = gen_label("tern_end")
cond_slot = gen_expr(cond, -1)
emit_jump_cond("jump_false", cond_slot, else_label)
emit_jump_cond("wary_false", cond_slot, else_label)
dest = alloc_slot()
then_slot = gen_expr(then_expr, -1)
emit_2("move", dest, then_slot)
@@ -2586,7 +2586,7 @@ var mcode = function(ast) {
else_label = gen_label("if_else")
end_label = gen_label("if_end")
cond_slot = gen_expr(cond, -1)
emit_jump_cond("jump_false", cond_slot, else_label)
emit_jump_cond("wary_false", cond_slot, else_label)
_i = 0
while (_i < length(then_stmts)) {
gen_statement(then_stmts[_i])
@@ -2627,7 +2627,7 @@ var mcode = function(ast) {
}
emit_label(start_label)
cond_slot = gen_expr(cond, -1)
emit_jump_cond("jump_false", cond_slot, end_label)
emit_jump_cond("wary_false", cond_slot, end_label)
_i = 0
while (_i < length(stmts)) {
gen_statement(stmts[_i])
@@ -2662,7 +2662,7 @@ var mcode = function(ast) {
}
emit_label(cond_label)
cond_slot = gen_expr(cond, -1)
emit_jump_cond("jump_true", cond_slot, start_label)
emit_jump_cond("wary_true", cond_slot, start_label)
emit_label(end_label)
s_loop_break = old_break
s_loop_continue = old_continue
@@ -2696,7 +2696,7 @@ var mcode = function(ast) {
emit_label(start_label)
if (test != null) {
test_slot = gen_expr(test, -1)
emit_jump_cond("jump_false", test_slot, end_label)
emit_jump_cond("wary_false", test_slot, end_label)
}
_i = 0
while (_i < length(stmts)) {