From 49c852701f680cedc127d9ce376bdb1df26dd596 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 1 Sep 2026 13:38:21 +0000 Subject: [PATCH 1/4] Preserve CP on Execute-of-user and shrink T4/ITE snapshots. Lower wrappers (parse_args/2, Execute of user/builtins) without stealing the query continuation: isolated interpreted Execute restores CP, and JS return is Proceed for lowered callees. T4 list recursion uses nil/cons dispatch; unifying ITE snapshots A/X lite. Call/Execute of a lowered callee is a direct JS function call; Call of sub_string/5 is op_builtin. Co-authored-by: johns243a --- .../targets/wam_javascript_lowered_emitter.pl | 342 ++++++++++++++---- .../javascript_wam/runtime.js.mustache | 68 ++++ tests/test_wam_javascript_lowered.pl | 131 ++++++- 3 files changed, 462 insertions(+), 79 deletions(-) diff --git a/src/unifyweaver/targets/wam_javascript_lowered_emitter.pl b/src/unifyweaver/targets/wam_javascript_lowered_emitter.pl index a212cf0a6..d74455bd3 100644 --- a/src/unifyweaver/targets/wam_javascript_lowered_emitter.pl +++ b/src/unifyweaver/targets/wam_javascript_lowered_emitter.pl @@ -154,6 +154,21 @@ sort(FPs, [_]), !, Unique = C1. +% Indexed copies of the same non-ground deterministic body (including +% last-goal Execute wrappers). Collapse to one body so they lower. +classify_clause_shape([FirstLine|Rest], plan(deterministic, none, Unique)) :- + tokenize_line(FirstLine, ["try_me_else", _AltStr]), + js_split_clause_lines([FirstLine|Rest], Clauses), + Clauses = [C1|_], + C1 \== [], + forall(member(Cl, Clauses), + ( Cl \== [], + forall(member(Line, Cl), line_supported(Line)), + last(Cl, LastLine), js_t4_terminal_line(LastLine) )), + maplist(js_clause_op_fingerprint, Clauses, FPs), + sort(FPs, [_]), + !, + Unique = C1. % T4: every clause is a supported deterministic body, including inner % if-then-else (structure_ite). Used for list-recursion helpers such as % first_char_index/4 (nil vs cons + ITE) that would otherwise become @@ -299,6 +314,9 @@ js_split_commit_(R, D1, [trust_me|Acc], Cond, Then). js_split_commit_([Commit|Then], 0, Acc, Acc, Then) :- is_commit(Commit), !. +% Disjunction (A ; B) has no cut on the then-path. Treat the whole +% path as the condition and an empty then — ite(A, [], B). +js_split_commit_([], 0, Acc, Acc, []) :- !. js_split_commit_([I|R], D, Acc, Cond, Then) :- js_split_commit_(R, D, [I|Acc], Cond, Then). @@ -313,7 +331,7 @@ js_take_to_proceed([Line|Rest], [Line], Rest) :- tokenize_line(Line, Parts), - ( Parts == ["proceed"] ; Parts == ["fail"] ), !. + js_clause_terminal_parts(Parts), !. js_take_to_proceed([Line|Rest], More, After) :- tokenize_line(Line, []), !, js_take_to_proceed(Rest, More, After). @@ -356,7 +374,7 @@ js_take_to_terminal([Line|Rest], [Line], Rest) :- tokenize_line(Line, Parts), - ( Parts == ["proceed"] ; Parts == ["fail"] ), !. + js_clause_terminal_parts(Parts), !. js_take_to_terminal([Line|Rest], [Line|More], After) :- js_take_to_terminal(Rest, More, After). js_take_to_terminal([], [], []). @@ -369,14 +387,17 @@ js_t4_terminal_line(Line) :- tokenize_line(Line, Parts), - ( Parts == ["proceed"] ; Parts == ["fail"] ). + js_clause_terminal_parts(Parts). + +% Last-goal Execute is a clause terminator (no Proceed after it). +% Indexed copies of Execute-terminated wrappers (parse_args/2, wrap_tail/1) +% were classified as multi_clause_1 because splitters only saw proceed/fail. +js_clause_terminal_parts(["proceed"]). +js_clause_terminal_parts(["fail"]). +js_clause_terminal_parts(["execute"|_]). wam_javascript_lowerable(PI, WamCode, Reason) :- - js_pi_key(PI, PredName), - % Execute of a *different* predicate cannot be a nested Runtime.run - % (cp=0 steals the query continuation; GP-PERF mixed-mode). Keep - % those wrappers on the interpreter; Call of a lowered helper is fine. - \+ js_wam_has_foreign_execute(WamCode, PredName), + js_pi_key(PI, _PredName), catch(build_emission_plan(WamCode, plan(Reason, _, Payload)), _, fail), % multi_clause_1 inlines clause 1 then Runtime.run from pc+1, which is % the caller's next instruction rather than the alt clause. Wrong-but- @@ -471,6 +492,34 @@ ; emit_multi_clause_function(PredName, FuncName, AltLabel, Payload, Code) ). +emit_multi_clause_n_function(PredName, FuncName, Clauses, Code) :- + js_t4_nil_cons_split(Clauses, NilRest, ConsClause), !, + with_output_to(string(NilBody), emit_t4_clause_body(NilRest, " ")), + with_output_to(string(ConsBody), emit_t4_clause_body(ConsClause, " ")), + with_output_to(string(Fallback), emit_js_t4_payload(Clauses)), + format(string(Code), +'// Lowered: ~w (T4 nil/cons dispatch; no snapshot on bound A1) +function ~w(program, state) { + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { +~w return true; + } + if (Runtime.term_is_cons(program, _a1)) { +~w return true; + } + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; +~w return false; +} +', [PredName, FuncName, NilBody, ConsBody, Fallback]). emit_multi_clause_n_function(PredName, FuncName, Clauses, Code) :- with_output_to(string(ClausesBody), emit_js_t4_payload(Clauses)), format(string(Code), @@ -490,25 +539,76 @@ } ', [PredName, FuncName, ClausesBody]). +emit_t4_clause_body(Clause, Ind) :- + ( Clause = [S|_], string(S) + -> emit_lines(Clause, Ind) + ; emit_struct_js(Clause, Ind) + ). + +%% js_t4_nil_cons_split(+Clauses, -NilRest, -ConsClause) +% Two-clause list recursion: clause 1 starts get_nil/get_constant [] on A1, +% clause 2 starts (optional allocate +) get_list A1. Bound A1 needs no +% T4 register snapshot — the heads are mutually exclusive. +js_t4_nil_cons_split(Clauses, NilRest, ConsClause) :- + member(C1, Clauses), + js_clause_skip_nil_a1(C1, NilRest), + member(ConsClause, Clauses), + js_clause_starts_list_a1(ConsClause), + !. + +js_clause_skip_nil_a1([Item|Rest], Rest) :- + js_item_is_nil_a1(Item), !. +js_clause_skip_nil_a1([Item|Rest0], [Item|Rest]) :- + js_item_is_skip_prefix(Item), + js_clause_skip_nil_a1(Rest0, Rest). + +js_clause_starts_list_a1([Item|_]) :- + js_item_is_list_a1(Item), !. +js_clause_starts_list_a1([Item|Rest]) :- + js_item_is_skip_prefix(Item), + js_clause_starts_list_a1(Rest). + +js_item_is_skip_prefix(line(["allocate"])) :- !. +js_item_is_skip_prefix(Line) :- + string(Line), tokenize_line(Line, ["allocate"]), !. + +js_item_is_nil_a1(line(["get_nil", A1])) :- js_is_a1(A1). +js_item_is_nil_a1(line(["get_constant", C, A1])) :- + js_is_a1(A1), js_is_nil_const(C). +js_item_is_nil_a1(Line) :- + string(Line), tokenize_line(Line, Parts), + js_item_is_nil_a1(line(Parts)). + +js_item_is_list_a1(line(["get_list", A1])) :- js_is_a1(A1). +js_item_is_list_a1(Line) :- + string(Line), tokenize_line(Line, Parts), + js_item_is_list_a1(line(Parts)). + +js_is_a1(A1) :- A1 == "A1" ; A1 == 'A1' ; A1 == "1" ; A1 == 1. + +js_is_nil_const(C) :- + atom_string(C, S), + ( S == "[]" ; S == "'[]'" ). + emit_js_t4_payload([]). emit_js_t4_payload([Clause|Rest]) :- format(" if ((function () {~n"), - ( Clause = [S|_], string(S) - -> emit_lines(Clause, " ") - ; emit_struct_js(Clause, " ") - ), + emit_t4_clause_body(Clause, " "), format(" return false;~n"), format(" })()) return true;~n"), - format(" while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; }~n"), - format(" state.regs = Runtime.copy_table(_t4_regs);~n"), - format(" state.var_counter = _t4_vc;~n"), - format(" state.stack = _t4_stack.slice();~n"), - format(" state.y_save = _t4_ysave.slice();~n"), - format(" state.mode = _t4_mode;~n"), - format(" state.build_stack = _t4_build.slice();~n"), - format(" state.read_stack = _t4_rstack.slice();~n"), - format(" state.read_args = _t4_rargs;~n"), - format(" state.read_cursor = _t4_rcur;~n"), + ( Rest == [] + -> true + ; format(" while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; }~n"), + format(" state.regs = Runtime.copy_table(_t4_regs);~n"), + format(" state.var_counter = _t4_vc;~n"), + format(" state.stack = _t4_stack.slice();~n"), + format(" state.y_save = _t4_ysave.slice();~n"), + format(" state.mode = _t4_mode;~n"), + format(" state.build_stack = _t4_build.slice();~n"), + format(" state.read_stack = _t4_rstack.slice();~n"), + format(" state.read_args = _t4_rargs;~n"), + format(" state.read_cursor = _t4_rcur;~n") + ), emit_js_t4_payload(Rest). emit_js_t4_clauses(Clauses) :- @@ -546,8 +646,25 @@ emit_struct_js(Else, Ind4), format("~w }~n", [Ind]), format("~w}~n", [Ind]). -% Condition may Allocate / unify / Call: restore a full machine snapshot. -% Trail + A-registers is not enough when the condition builds a structure. +% Condition may unify / put_structure but does not Call or Allocate: +% restore trail, A1-A16, X101-X160, mode/build/read — not the full +% register file, stack, or Y-save (those were the T4/ITE wall). +emit_struct_item_js(ite(Cond, Then, Else), Ind) :- + \+ js_ite_cond_needs_full_snap(Cond), !, + string_concat(Ind, " ", Ind4), + format("~w{~n", [Ind]), + format("~w const _ite_lite = Runtime.snapshot_lite(state);~n", [Ind]), + format("~w const _ite_cond = (function () {~n", [Ind]), + emit_struct_js(Cond, Ind4), + format("~w return true;~n", [Ind]), + format("~w })();~n", [Ind]), + format("~w if (_ite_cond) {~n", [Ind]), + emit_struct_js(Then, Ind4), + format("~w } else {~n", [Ind]), + format("~w Runtime.restore_lite(state, _ite_lite);~n", [Ind]), + emit_struct_js(Else, Ind4), + format("~w }~n", [Ind]), + format("~w}~n", [Ind]). emit_struct_item_js(ite(Cond, Then, Else), Ind) :- !, string_concat(Ind, " ", Ind4), format("~w{~n", [Ind]), @@ -797,15 +914,21 @@ tokenize_line(Line, Parts), ( Parts == [] -> true ; Parts = [F|_], sub_string(F, _, 1, 0, ":") -> true + ; ( Parts = ["call", PredArity] ; Parts = ["call", Pred, ArityStr] ) + -> ( Parts = ["call", PredArity] -> PA = PredArity + ; strip_arity_local(Pred, Name), format(string(PA), "~w/~w", [Name, ArityStr]) + ), + js_y_live_across(Rest, Live), + emit_call(PA, Ind, Live) ; emit_line_parts(Parts, Ind) ), emit_lines(Rest, Ind). emit_line_parts(["proceed"], I) :- !, format("~wreturn true;~n", [I]). emit_line_parts(["fail"], I) :- !, format("~wreturn false;~n", [I]). -emit_line_parts(["call", PredArity], I) :- !, emit_call(PredArity, I). +emit_line_parts(["call", PredArity], I) :- !, emit_call(PredArity, I, false). emit_line_parts(["call", Pred, ArityStr], I) :- !, - strip_arity_local(Pred, Name), format(string(PA), "~w/~w", [Name, ArityStr]), emit_call(PA, I). + strip_arity_local(Pred, Name), format(string(PA), "~w/~w", [Name, ArityStr]), emit_call(PA, I, false). emit_line_parts(["execute", PredArity], I) :- !, emit_execute(PredArity, I). emit_line_parts(["execute", Pred, ArityStr], I) :- !, strip_arity_local(Pred, Name), format(string(PA), "~w/~w", [Name, ArityStr]), emit_execute(PA, I). @@ -898,29 +1021,48 @@ wam_javascript_target:wam_parts_to_js(Parts, [], Lit), format("~wif (Runtime.step(program, state, ~w) !== true) return false;~n", [I, Lit]). -emit_call(PredArity, I) :- - wam_javascript_target:js_string_literal(PredArity, Q), +% Call of a JS WAM builtin (sub_string/5, …): first-solution, same as +% interpreter Call → try_builtin_fallback. Do not Y-save (interpreter +% Call of a builtin does not) and do not go through I.Call. +emit_call(PredArity, I, _Protect) :- parse_call_pred_arity(PredArity, PredName, Arity), + js_wam_builtin_functor(PredName), !, wam_javascript_target:js_string_literal(PredName, PQ), - format("~w{~n", [I]), + format("~wif (Runtime.op_builtin(program, state, ~w, ~w) !== true) return false;~n", + [I, PQ, Arity]). +emit_call(PredArity, I, Protect) :- + parse_call_pred_arity(PredArity, PredName, Arity), + atom_string(PredAtom, PredName), + js_lowered_func_name(PredAtom/Arity, FuncName), + wam_javascript_target:js_string_literal(PredArity, Q), + wam_javascript_target:js_string_literal(PredName, PQ), + % Direct JS call: the callee's Proceed is `return`, so Call does not + % touch cp/pc. typeof is false when mixed([subset]) left it interpreted. + format("~wif (typeof ~w === \"function\") {~n", [I, FuncName]), + ( Protect == true + -> % Caller's Y is live across this Call (parse_args/2 after + % default_registry). Match invoke_lowered_call: Y-snapshot + + % mode/build/read restore so intern write-mode cannot clobber Y. + format("~w Runtime.push_y_save(state);~n", [I]), + format("~w const _ok = Runtime.run_lowered_body(program, state, ~w);~n", [I, FuncName]), + format("~w Runtime.pop_y_save(state);~n", [I]), + format("~w if (_ok !== true) return false;~n", [I]) + ; format("~w if (~w(program, state) !== true) return false;~n", [I, FuncName]) + ), + format("~w} else {~n", [I]), format("~w const saved_cp = state.cp;~n", [I]), format("~w const saved_pc = state.pc;~n", [I]), - format("~w const _lf = (program.lowered_dispatch && program.lowered_dispatch[~w]) || ((typeof lowered_dispatch !== \"undefined\") ? lowered_dispatch[~w] : undefined);~n", [I, Q, Q]), + format("~w const target = program.labels[~w];~n", [I, Q]), format("~w let _ok = true;~n", [I]), - format("~w if (typeof _lf === \"function\") {~n", [I]), - format("~w _ok = _lf(program, state) === true;~n", [I]), - format("~w } else {~n", [I]), - format("~w const target = program.labels[~w];~n", [I, Q]), - format("~w if (target !== undefined && target !== null) {~n", [I]), - format("~w Runtime.push_y_save(state);~n", [I]), - format("~w state.cp = 0;~n", [I]), - format("~w state.pc = target;~n", [I]), - format("~w state.program = program;~n", [I]), - format("~w _ok = Runtime.run_isolated(program, state) === true;~n", [I]), - format("~w state.halt = false;~n", [I]), - format("~w } else if (Runtime.step(program, state, I.Call(~w, ~w)) !== true) {~n", [I, PQ, Arity]), - format("~w _ok = false;~n", [I]), - format("~w }~n", [I]), + format("~w if (target !== undefined && target !== null) {~n", [I]), + format("~w Runtime.push_y_save(state);~n", [I]), + format("~w state.cp = 0;~n", [I]), + format("~w state.pc = target;~n", [I]), + format("~w state.program = program;~n", [I]), + format("~w _ok = Runtime.run_isolated(program, state) === true;~n", [I]), + format("~w state.halt = false;~n", [I]), + format("~w } else if (Runtime.step(program, state, I.Call(~w, ~w)) !== true) {~n", [I, PQ, Arity]), + format("~w _ok = false;~n", [I]), format("~w }~n", [I]), format("~w state.cp = saved_cp;~n", [I]), format("~w state.pc = saved_pc;~n", [I]), @@ -928,23 +1070,56 @@ format("~w if (!_ok) return false;~n", [I]), format("~w}~n", [I]). +%% js_y_live_across(+LinesAfterCall, -Live) +% True when a Y register is read/written after Call before the frame +% is deallocated or the clause ends. Those Calls need a Y snapshot. +js_y_live_across([], false). +js_y_live_across([Line|Rest], Live) :- + tokenize_line(Line, Parts), + ( Parts == [] -> js_y_live_across(Rest, Live) + ; Parts = [F|_], sub_string(F, _, 1, 0, ":") -> js_y_live_across(Rest, Live) + ; ( Parts == ["deallocate"] ; Parts == ["proceed"] + ; Parts == ["fail"] ; Parts = ["execute"|_] ) + -> Live = false + ; js_parts_mention_y(Parts) + -> Live = true + ; js_y_live_across(Rest, Live) + ). + +js_parts_mention_y(Parts) :- + member(P, Parts), + ( sub_string(P, 0, 1, _, "Y") + ; sub_string(P, 0, 1, _, "y") + ). + emit_execute(PredArity, I) :- - wam_javascript_target:js_string_literal(PredArity, Q), parse_call_pred_arity(PredArity, PredName, Arity), wam_javascript_target:js_string_literal(PredName, PQ), + js_wam_builtin_functor(PredName), !, + % Last-goal Execute of a JS WAM builtin. JS return is Proceed — + % I.Execute would proceed_to_cp and steal/halt the query. + format("~wreturn Runtime.op_builtin(program, state, ~w, ~w) === true;~n", + [I, PQ, Arity]). +emit_execute(PredArity, I) :- + parse_call_pred_arity(PredArity, PredName, Arity), + atom_string(PredAtom, PredName), + js_lowered_func_name(PredAtom/Arity, FuncName), + wam_javascript_target:js_string_literal(PredArity, Q), + wam_javascript_target:js_string_literal(PredName, PQ), + % Lowered-to-lowered Execute: JS return IS Proceed. Do not proceed_to_cp + % and do not touch cp (the caller's continuation stays in state.cp). + format("~wif (typeof ~w === \"function\") return ~w(program, state) === true;~n", + [I, FuncName, FuncName]), format("~w{~n", [I]), - format("~w const _lf = (program.lowered_dispatch && program.lowered_dispatch[~w]) || ((typeof lowered_dispatch !== \"undefined\") ? lowered_dispatch[~w] : undefined);~n", [I, Q, Q]), - format("~w if (typeof _lf === \"function\") return _lf(program, state) === true;~n", [I]), format("~w const target = program.labels[~w];~n", [I, Q]), format("~w if (target !== undefined && target !== null) {~n", [I]), - format("~w state.pc = target;~n", [I]), - format("~w state.program = program;~n", [I]), - format("~w return Runtime.run_isolated(program, state) === true;~n", [I]), + % Interpreted user callee: run until THAT predicate Proceeds. Setting + % cp=0 inside execute_user_isolated makes Proceed halt the isolated + % interpreter instead of jumping the query continuation; the helper + % then restores the saved cp so this function's `return` is Proceed. + format("~w return Runtime.execute_user_isolated(program, state, target) === true;~n", [I]), format("~w }~n", [I]), - format("~w if (Runtime.step(program, state, I.Execute(~w, ~w)) !== true) return false;~n", [I, PQ, Arity]), - format("~w if (state.halt) return true;~n", [I]), - format("~w state.program = program;~n", [I]), - format("~w return Runtime.run_isolated(program, state) === true;~n", [I]), + format("~w return Runtime.op_builtin(program, state, ~w, ~w) === true;~n", [I, PQ, Arity]), format("~w}~n", [I]). parse_call_pred_arity(PredArity, PredName, Arity) :- @@ -1012,9 +1187,6 @@ %% wam_javascript_explain_lower(+PI, +WamCode, -Decision) % Decision = lower(Reason) | fallback(Why). Never fails. -wam_javascript_explain_lower(PI, WamCode, fallback('execute of a non-self callee (nested Runtime.run would steal CP)')) :- - js_pi_key(PI, Key), - js_wam_has_foreign_execute(WamCode, Key), !. wam_javascript_explain_lower(PI, WamCode, lower(Reason)) :- catch(wam_javascript_lowerable(PI, WamCode, Reason), _, fail), !. wam_javascript_explain_lower(_PI, WamCode, fallback(Why)) :- @@ -1041,20 +1213,38 @@ js_pi_key(Pred/Arity, Key) :- format(atom(Key), '~w/~w', [Pred, Arity]). -%% js_wam_has_foreign_execute(+WamCode, +SelfKey) -% True when some Execute targets a predicate other than SelfKey. -% Nested Runtime.run with cp=0 steals the query continuation -% (parse_args/2 Executes parse_args/3). Self-recursive last-goal -% Execute (T4 merge_flags_/3) is allowed. Execute of a JS WAM builtin -% is also rejected (that path aliased live ground terms). -js_wam_has_foreign_execute(WamCode, Self) :- +%% js_wam_has_builtin_execute(+WamCode, +SelfKey) +% True when some Execute targets a JS WAM builtin (sub_string/5, …). +% Not a fallback: emit_execute / emit_call emit Runtime.op_builtin. +% User-predicate Execute (self or other) preserves the caller's CP. +js_wam_has_builtin_execute(WamCode, Self) :- atom_string(Self, SelfS), atom_string(WamCode, S), split_string(S, "\n", "", Lines), member(Line, Lines), tokenize_line(Line, Parts), js_execute_target(Parts, TargetS), - TargetS \== SelfS. + TargetS \== SelfS, + js_execute_is_wam_builtin(TargetS). + +js_execute_is_wam_builtin(TargetS) :- + js_execute_functor(TargetS, Name), + js_wam_builtin_functor(Name). + +js_execute_functor(TargetS, Name) :- + ( sub_string(TargetS, B, 1, After, "/"), + sub_string(TargetS, _, After, 0, ArStr), + number_string(_, ArStr) + -> sub_string(TargetS, 0, B, _, Name) + ; Name = TargetS + ). + +% ISO / JS WAM builtins that appear as last-goal Execute in wrappers. +% User predicates that merely share a name are not expected in this tree. +js_wam_builtin_functor("sub_string"). +js_wam_builtin_functor("sub_atom"). +js_wam_builtin_functor(sub_string). +js_wam_builtin_functor(sub_atom). js_execute_target(["execute", PA], TargetS) :- atom_string(PA, TargetS). @@ -1069,7 +1259,10 @@ Items \== [], forall(member(I, Items), js_ite_pure_test_item(I)). -js_ite_pure_test_item(ite(_, _, _)) :- !, fail. +js_ite_pure_test_item(ite(C, T, E)) :- !, + js_ite_pure_test_cond(C), + ( T == [] -> true ; js_ite_pure_test_cond(T) ), + ( E == [] -> true ; js_ite_pure_test_cond(E) ). js_ite_pure_test_item(builtin_call(Op, _)) :- js_pure_compare_builtin(Op). js_ite_pure_test_item(line(Parts)) :- @@ -1082,3 +1275,20 @@ memberchk(S, ["==/2", "\\==/2", "=:=/2", "=\\=/2", ">/2", "=/2", "=", "<", ">=", "=<"]). + +%% js_ite_cond_needs_full_snap(+Structured) +% Call / Execute / Allocate in the condition can push CPs or Y frames; +% those still need snapshot_machine. Unifying put_structure / =/2 do not. +js_ite_cond_needs_full_snap(Items) :- + member(I, Items), + js_ite_item_full_snap(I). + +js_ite_item_full_snap(ite(C, T, E)) :- + ( js_ite_cond_needs_full_snap(C) + ; js_ite_cond_needs_full_snap(T) + ; js_ite_cond_needs_full_snap(E) + ). +js_ite_item_full_snap(line(["call"|_])). +js_ite_item_full_snap(line(["execute"|_])). +js_ite_item_full_snap(line(["allocate"])). +js_ite_item_full_snap(line(["deallocate"])). diff --git a/templates/targets/javascript_wam/runtime.js.mustache b/templates/targets/javascript_wam/runtime.js.mustache index 8590efd45..d69f6eb33 100644 --- a/templates/targets/javascript_wam/runtime.js.mustache +++ b/templates/targets/javascript_wam/runtime.js.mustache @@ -540,6 +540,53 @@ function term_is_ground(state, v, seen) { Runtime.term_is_ground = term_is_ground; +Runtime.term_is_nil = function (program, v) { + if (!v || typeof v !== "object") return false; + if (v.tag !== "atom") return false; + return Runtime.string_of(program.intern_table, v.id) === "[]"; +}; + +Runtime.term_is_cons = function (program, v) { + if (!v || typeof v !== "object" || v.tag !== "struct") return false; + if ((v.args || []).length !== 2) return false; + return is_cons_fid(program, v.fid); +}; + +Runtime.snapshot_lite = function (state) { + const x = {}; + const r = state.regs; + for (let i = 101; i <= 160; i++) { + if (r[i] !== undefined) x[i] = r[i]; + } + return { + trail_len: state.trail.length, + var_counter: state.var_counter, + mode: state.mode, + build_stack: state.build_stack.slice(), + read_stack: (state.read_stack || []).slice(), + read_args: state.read_args, + read_cursor: state.read_cursor, + a: Runtime.capture_a_regs(state, 16), + x: x + }; +}; + +Runtime.restore_lite = function (state, snap) { + undo_trail(state, snap.trail_len); + state.var_counter = snap.var_counter; + state.mode = snap.mode; + state.build_stack = snap.build_stack || []; + state.read_stack = (snap.read_stack || []).slice(); + if (snap.read_args !== undefined) state.read_args = snap.read_args; + if (snap.read_cursor !== undefined) state.read_cursor = snap.read_cursor; + Runtime.restore_a_regs(state, snap.a); + const r = state.regs; + for (let i = 101; i <= 160; i++) delete r[i]; + const x = snap.x || {}; + const xk = Object.keys(x); + for (let i = 0; i < xk.length; i++) r[xk[i]] = x[xk[i]]; +}; + // Mixed-mode: an interpreted Call/Execute whose target has a lowered // function must run that function, not the bytecode (otherwise helpers // stay on the slow path). Call pushes Y (convention from A2); Execute @@ -587,6 +634,7 @@ function run_lowered_body(program, state, fn) { state.halt = false; return ok === true; } +Runtime.run_lowered_body = run_lowered_body; function invoke_lowered_call(program, state, fn) { const retPc = state.pc + 1; @@ -3814,6 +3862,26 @@ Runtime.run_isolated = function (program, state) { return ok === true; }; +// Lowered last-goal Execute of an *interpreted* user predicate. +// WAM Execute does not modify CP; the callee's Proceed returns to the +// CP that was live at the Execute. A lowered frame's Proceed is +// `return true` from JS, so the isolated interpreter must NOT resume +// at that CP (that would steal the query continuation — GP-PERF round 1 +// corpus test 1). Setting cp=0 makes the callee's Proceed halt the +// isolated run; restoring the saved CP makes this function's caller +// (the lowered wrapper, or invoke_lowered_execute) the actual Proceed. +Runtime.execute_user_isolated = function (program, state, target) { + const saved_cp = state.cp; + state.cp = 0; + state.pc = target; + state.program = program; + state.halt = false; + const ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + state.cp = saved_cp; + return ok === true; +}; + Runtime.collect_run = function (program, state, onSolution) { state.program = program; state.halt = false; diff --git a/tests/test_wam_javascript_lowered.pl b/tests/test_wam_javascript_lowered.pl index 2933a34e2..5dbeee73c 100644 --- a/tests/test_wam_javascript_lowered.pl +++ b/tests/test_wam_javascript_lowered.pl @@ -36,7 +36,13 @@ :- dynamic user:probe_memo/0. :- dynamic user:wrap_tail/1. :- dynamic user:wrap_helper/1. -:- dynamic user:wrap_sub/3. +:- dynamic user:probe_wrap_sub/0. +:- dynamic user:wrap_entry/1. +:- dynamic user:after_call/1. +:- dynamic user:probe_cont_exec/0. +:- dynamic user:probe_nested_exec/0. +:- dynamic user:call_sub/3. +:- dynamic user:probe_call_sub/0. install_lowered_preds :- retractall(user:hello/1), @@ -64,6 +70,13 @@ retractall(user:wrap_tail/1), retractall(user:wrap_helper/1), retractall(user:wrap_sub/3), + retractall(user:probe_wrap_sub/0), + retractall(user:wrap_entry/1), + retractall(user:after_call/1), + retractall(user:probe_cont_exec/0), + retractall(user:probe_nested_exec/0), + retractall(user:call_sub/3), + retractall(user:probe_call_sub/0), % T4+ITE list recursion (first_char_index/4 shape). assertz(user:char_idx([], _, _, -1)), assertz((user:char_idx([C|Cs], T, I, Index) :- @@ -84,12 +97,21 @@ Y = g(a, [1, 2, 3]), X == Y, write(ok), nl)), - % Last-goal Execute of a different *user* predicate: now lowers via - % emit_execute's lowered-fn / run_isolated path. + % Last-goal Execute of a different *user* predicate: lowers via + % emit_execute (lowered-fn tail call, or execute_user_isolated). assertz(user:wrap_helper(ok)), assertz((user:wrap_tail(X) :- wrap_helper(X))), - % Last-goal Execute of a JS WAM builtin: must stay interpreted. - assertz((user:wrap_sub(S, N, Sub) :- sub_string(S, 0, N, _, Sub))). + % Nested Execute + Call-then-continue (corpus test 1 shape). + assertz((user:wrap_entry(X) :- wrap_tail(X))), + assertz((user:after_call(X) :- wrap_entry(X), X == ok)), + assertz((user:probe_cont_exec :- after_call(X), write(X), nl)), + assertz((user:probe_nested_exec :- wrap_entry(X), write(X), nl, X == ok)), + % Last-goal Execute of a JS WAM builtin: lowers via op_builtin return. + assertz((user:wrap_sub(S, N, Sub) :- sub_string(S, 0, N, _, Sub))), + assertz((user:probe_wrap_sub :- wrap_sub("abcd", 2, S), write(S), nl, S == "ab")), + % Call (not Execute) of sub_string/5 then continue — corpus starts_with/2 shape. + assertz((user:call_sub(S, N, Sub) :- sub_string(S, 0, N, _, Sub), true)), + assertz((user:probe_call_sub :- call_sub("abcd", 2, S), write(S), nl, S == "ab")). read_generated_js(Dir, Text) :- directory_file_path(Dir, 'js', JsDir), @@ -209,10 +231,15 @@ [emit_mode(functions)], Dir), read_generated_js(Dir, Code), assertion(sub_string(Code, _, _, _, "function lowered_char_idx_4")), - assertion(sub_string(Code, _, _, _, "T4 all-clauses inline")), + assertion((sub_string(Code, _, _, _, "T4 nil/cons dispatch") + ; sub_string(Code, _, _, _, "T4 all-clauses inline"))), assertion(sub_string(Code, _, _, _, "Runtime.op_get_list")), assertion(sub_string(Code, _, _, _, "Runtime.op_builtin")), - assertion(sub_string(Code, _, _, _, "capture_a_regs")), + assertion((sub_string(Code, _, _, _, "capture_a_regs") + ; sub_string(Code, _, _, _, "snapshot_lite"))), + assertion(sub_string(Code, _, _, _, "term_is_nil")), + assertion(sub_string(Code, _, _, _, + "if (lowered_char_idx_4(program, state) !== true)")), run_node_args(Dir, ['probe_char_idx/0'], Exit, Out), assertion(Exit =:= 0), assertion(node_succeeded(Out)), @@ -240,12 +267,38 @@ assertion(node_succeeded(Out2)), assertion(sub_string(Out2, _, _, _, "ok")). -test(execute_builtin_stays_interpreted, [setup(install_lowered_preds)]) :- +test(execute_builtin_lowers, [setup(install_lowered_preds)]) :- compile_predicate_to_wam_text(wrap_sub/3, [ite_use_y_level(true), inline_bagof_setof(true)], Wam), - wam_javascript_explain_lower(user:wrap_sub/3, Wam, Decision), - assertion(Decision = fallback(_)), - \+ wam_javascript_lowerable(user:wrap_sub/3, Wam, _). + wam_javascript_lowerable(user:wrap_sub/3, Wam, Reason), + assertion(Reason == deterministic), + Dir = 'output/js_wam_lowered_exec_builtin', + make_directory_path(Dir), + write_wam_javascript_project( + [user:wrap_sub/3, user:probe_wrap_sub/0], + [emit_mode(mixed)], Dir), + read_generated_js(Dir, Code), + assertion(sub_string(Code, _, _, _, "function lowered_wrap_sub_3")), + assertion(sub_string(Code, _, _, _, "op_builtin")), + run_node_args(Dir, ['probe_wrap_sub/0'], Exit, Out), + assertion(Exit =:= 0), + assertion(node_succeeded(Out)), + assertion(sub_string(Out, _, _, _, "ab")). + +test(call_builtin_op_builtin, [setup(install_lowered_preds)]) :- + Dir = 'output/js_wam_lowered_call_builtin', + make_directory_path(Dir), + write_wam_javascript_project( + [user:call_sub/3, user:probe_call_sub/0], + [emit_mode(mixed)], Dir), + read_generated_js(Dir, Code), + assertion(sub_string(Code, _, _, _, "function lowered_call_sub_3")), + assertion(sub_string(Code, _, _, _, "op_builtin")), + assertion(\+ sub_string(Code, _, _, _, 'lowered_dispatch["sub_string/5"]')), + run_node_args(Dir, ['probe_call_sub/0'], Exit, Out), + assertion(Exit =:= 0), + assertion(node_succeeded(Out)), + assertion(sub_string(Out, _, _, _, "ab")). test(mixed_auto_lowers_eligible, [setup(install_lowered_preds)]) :- Dir = 'output/js_wam_lowered_mixed_auto', @@ -256,10 +309,62 @@ read_generated_js(Dir, Code), assertion(sub_string(Code, _, _, _, "function lowered_hello_1")), assertion(sub_string(Code, _, _, _, "function lowered_wrap_helper_1")), - assertion(\+ sub_string(Code, _, _, _, "function lowered_wrap_sub_3")), - assertion(sub_string(Code, _, _, _, "wamjs lower fallback: wrap_sub/3")), + assertion(sub_string(Code, _, _, _, "function lowered_wrap_tail_1")), + assertion(sub_string(Code, _, _, _, "function lowered_wrap_sub_3")), + assertion(\+ sub_string(Code, _, _, _, "wamjs lower fallback: wrap_sub/3")), run_node_args(Dir, ['hello/1', 'world'], Exit, Out), assertion(Exit =:= 0), assertion(node_succeeded(Out)). +test(execute_of_user_lowers, [setup(install_lowered_preds)]) :- + compile_predicate_to_wam_text(wrap_tail/1, + [ite_use_y_level(true), inline_bagof_setof(true)], Wam), + wam_javascript_lowerable(user:wrap_tail/1, Wam, Reason), + assertion((Reason == deterministic ; Reason == multi_clause_n)). + +test(execute_user_continuation_integrity, [setup(install_lowered_preds)]) :- + % Nested Execute (wrap_entry → wrap_tail → wrap_helper) plus + % Call-then-continue (after_call). This is the shape that broke + % corpus test 1 when Execute set cp=0 without restoring it. + Dir = 'output/js_wam_lowered_exec_user', + make_directory_path(Dir), + write_wam_javascript_project( + [user:wrap_helper/1, user:wrap_tail/1, user:wrap_entry/1, + user:after_call/1, user:probe_cont_exec/0, user:probe_nested_exec/0], + [emit_mode(mixed)], Dir), + read_generated_js(Dir, Code), + assertion(sub_string(Code, _, _, _, "function lowered_wrap_tail_1")), + assertion(sub_string(Code, _, _, _, "function lowered_wrap_entry_1")), + assertion(sub_string(Code, _, _, _, "function lowered_after_call_1")), + assertion(sub_string(Code, _, _, _, + "return lowered_wrap_tail_1(program, state) === true") + ; sub_string(Code, _, _, _, "execute_user_isolated") + ; sub_string(Code, _, _, _, "return _lf(program, state) === true")), + run_node_args(Dir, ['probe_nested_exec/0'], NExit, NOut), + assertion(NExit =:= 0), + assertion(node_succeeded(NOut)), + assertion(sub_string(NOut, _, _, _, "ok")), + run_node_args(Dir, ['probe_cont_exec/0'], CExit, COut), + assertion(CExit =:= 0), + assertion(node_succeeded(COut)), + assertion(sub_string(COut, _, _, _, "ok")). + +test(execute_user_interpreted_callee, [setup(install_lowered_preds)]) :- + % wrap_helper stays interpreted; wrap_tail lowers and Execute must + % isolate without stealing the Call-then-continue CP. + Dir = 'output/js_wam_lowered_exec_isolated', + make_directory_path(Dir), + write_wam_javascript_project( + [user:wrap_helper/1, user:wrap_tail/1, user:wrap_entry/1, + user:after_call/1, user:probe_cont_exec/0], + [emit_mode(mixed([wrap_tail/1, wrap_entry/1, after_call/1, probe_cont_exec/0]))], Dir), + read_generated_js(Dir, Code), + assertion(sub_string(Code, _, _, _, "function lowered_wrap_tail_1")), + assertion(\+ sub_string(Code, _, _, _, "function lowered_wrap_helper_1")), + assertion(sub_string(Code, _, _, _, "execute_user_isolated")), + run_node_args(Dir, ['probe_cont_exec/0'], Exit, Out), + assertion(Exit =:= 0), + assertion(node_succeeded(Out)), + assertion(sub_string(Out, _, _, _, "ok")). + :- end_tests(js_wam_lowered_standalone). From e3284a572f2ea92506c1b57d82f2f97be92bdb7e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 1 Sep 2026 13:43:19 +0000 Subject: [PATCH 2/4] Call lowered callees as direct JS functions. Skip the per-Call dispatch-table lookup and cp/pc save when the callee is a hoisted lowered function. Call/Execute of sub_string/5 is op_builtin (same first-solution as the interpreter). Profile counts live on the inner function so UW_PROFILE still sees recursive Calls. Co-authored-by: johns243a --- .../targets/wam_javascript_lowered_emitter.pl | 27 +++++++++++++++---- .../targets/wam_javascript_target.pl | 11 +++----- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/unifyweaver/targets/wam_javascript_lowered_emitter.pl b/src/unifyweaver/targets/wam_javascript_lowered_emitter.pl index d74455bd3..1aeef1338 100644 --- a/src/unifyweaver/targets/wam_javascript_lowered_emitter.pl +++ b/src/unifyweaver/targets/wam_javascript_lowered_emitter.pl @@ -481,15 +481,32 @@ js_lowered_func_name(Pred/Arity, FuncName), build_emission_plan(WamCode, plan(Mode, AltLabel, Payload)), ( Mode == deterministic - -> emit_deterministic_function(PredName, FuncName, Payload, Code) + -> emit_deterministic_function(PredName, FuncName, Payload, Code0) ; Mode == ite - -> emit_ite_function(PredName, FuncName, Payload, Code) + -> emit_ite_function(PredName, FuncName, Payload, Code0) ; Mode == clause_chain -> Payload = chain_payload(Guards, Clause1Lines), - emit_clause_chain_function(PredName, FuncName, AltLabel, Guards, Clause1Lines, Options, Code) + emit_clause_chain_function(PredName, FuncName, AltLabel, Guards, Clause1Lines, Options, Code0) ; Mode == multi_clause_n - -> emit_multi_clause_n_function(PredName, FuncName, Payload, Code) - ; emit_multi_clause_function(PredName, FuncName, AltLabel, Payload, Code) + -> emit_multi_clause_n_function(PredName, FuncName, Payload, Code0) + ; emit_multi_clause_function(PredName, FuncName, AltLabel, Payload, Code0) + ), + js_inject_prof_enter(PredName, FuncName, Code0, Code). + +%% Direct Call/Execute skips lowered_dispatch, so the call counter lives +%% on the inner function (one falsy check when UW_PROFILE is off). +js_inject_prof_enter(PredName, FuncName, Code0, Code) :- + wam_javascript_target:js_string_literal(PredName, Q), + format(string(Old), "function ~w(program, state) {", [FuncName]), + format(string(New), + "function ~w(program, state) {~n if (Runtime._prof) Runtime.prof_lowered_call(~w);", + [FuncName, Q]), + ( sub_string(Code0, B, _, A, Old) + -> sub_string(Code0, 0, B, _, Pref), + sub_string(Code0, _, A, 0, Suff), + string_concat(Pref, New, T), + string_concat(T, Suff, Code) + ; Code = Code0 ). emit_multi_clause_n_function(PredName, FuncName, Clauses, Code) :- diff --git a/src/unifyweaver/targets/wam_javascript_target.pl b/src/unifyweaver/targets/wam_javascript_target.pl index a3d2c0729..531b87e99 100644 --- a/src/unifyweaver/targets/wam_javascript_target.pl +++ b/src/unifyweaver/targets/wam_javascript_target.pl @@ -561,9 +561,9 @@ catch(wam_javascript_lowerable(Pred, WamText, _), _, fail), catch(lower_predicate_to_javascript(Pred, WamText, [], lowered(_, FuncName, LoweredJs)), _, fail) - -> format(string(DispatchLine), - 'lowered_dispatch[~w] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call(~w); return ~w(program, state); };', - [KeyQ, KeyQ, FuncName]), + -> format(string(DispatchLine), + 'lowered_dispatch[~w] = function (program, state) { return ~w(program, state); };', + [KeyQ, FuncName]), NewLoweredAcc = [LoweredJs, DispatchLine|LoweredAcc], emit_js_lowered_wrapper(P, Arity, FuncName, Wrapper) ; ( SkipLower \== true, @@ -710,8 +710,6 @@ emit_js_lowered_wrapper(Pred, Arity, FuncName, Code) :- pred_arg_strings(Arity, ArgDecl, ArgList), js_pred_name(Pred, Name), - format(string(MainKey), '~w/~w', [Pred, Arity]), - js_string_literal(MainKey, KeyQ), format(string(Code), 'function ~w(~w) { const state = Runtime.new_state(); @@ -721,11 +719,10 @@ } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call(~w); return ~w(shared_program, state) === true; } M.~w = ~w; -', [Name, ArgDecl, ArgList, Arity, KeyQ, FuncName, Name, Name]). +', [Name, ArgDecl, ArgList, Arity, FuncName, Name, Name]). pred_arg_strings(0, '', '[]') :- !. pred_arg_strings(Arity, ArgDecl, ArgList) :- From 737d77a5f6b4ae163f24f34809e679c647c8e781 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 1 Sep 2026 13:43:22 +0000 Subject: [PATCH 3/4] Regenerate examples/cli_args/wamjs mixed-mode JS. All 43 argparser predicates lower (no fallback comments). Direct JS Call/Execute, nil/cons T4, lite ITE, and execute_user_isolated are in the emitted runtime. Co-authored-by: johns243a --- .../cli_args/wamjs/js/generated_program.js | 6896 ++++++++++------- examples/cli_args/wamjs/js/wam_runtime.js | 68 + 2 files changed, 4347 insertions(+), 2617 deletions(-) diff --git a/examples/cli_args/wamjs/js/generated_program.js b/examples/cli_args/wamjs/js/generated_program.js index 20444ade7..9fa419057 100644 --- a/examples/cli_args/wamjs/js/generated_program.js +++ b/examples/cli_args/wamjs/js/generated_program.js @@ -731,7 +731,7 @@ const shared_instructions = [ I.GetVariable(202, 3), I.GetVariable(206, 4), I.GetLevel(207), - I.TryMeElse("L_ite_else_19"), + I.TryMeElse("L_ite_else_17"), I.PutValue(201, 1), I.PutValue(204, 2), I.BuiltinCall("==/2", 2), @@ -739,7 +739,7 @@ const shared_instructions = [ I.PutValue(206, 1), I.PutValue(202, 2), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_19"), + I.Jump("L_ite_cont_17"), I.TrustMe(), I.PutVariable(205, 1), I.PutStructure(10, 2, 2), @@ -789,7 +789,7 @@ const shared_instructions = [ I.GetVariable(206, 3), I.GetVariable(201, 4), I.GetLevel(208), - I.TryMeElse("L_ite_else_21"), + I.TryMeElse("L_ite_else_19"), I.PutValue(202, 1), I.PutValue(205, 2), I.BuiltinCall("==/2", 2), @@ -802,7 +802,7 @@ const shared_instructions = [ I.SetValue(202), I.SetValue(206), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_21"), + I.Jump("L_ite_cont_19"), I.TrustMe(), I.PutValue(201, 1), I.PutStructure(5, 2, 2), @@ -825,7 +825,7 @@ const shared_instructions = [ I.GetVariable(203, 3), I.GetVariable(204, 4), I.GetLevel(205), - I.TryMeElse("L_ite_else_23"), + I.TryMeElse("L_ite_else_21"), I.PutValue(202, 1), I.PutConstant(V.String("__proto__"), 2), I.BuiltinCall("==/2", 2), @@ -833,7 +833,7 @@ const shared_instructions = [ I.PutValue(204, 1), I.PutValue(201, 2), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_23"), + I.Jump("L_ite_cont_21"), I.TrustMe(), I.PutValue(201, 1), I.PutValue(202, 2), @@ -858,7 +858,7 @@ const shared_instructions = [ I.Allocate(), I.GetVariable(203, 1), I.GetLevel(204), - I.TryMeElse("L_ite_else_25"), + I.TryMeElse("L_ite_else_23"), I.PutVariable(201, 1), I.Call("global_options", 1), I.PutValue(201, 1), @@ -867,7 +867,7 @@ const shared_instructions = [ I.Call("pair_lookup", 3), I.Cut(204), I.BuiltinCall("true/0", 0), - I.Jump("L_ite_cont_25"), + I.Jump("L_ite_cont_23"), I.TrustMe(), I.PutValue(203, 1), I.Call("js_object_prototype_key", 1), @@ -896,7 +896,7 @@ const shared_instructions = [ I.PutVariable(201, 2), I.BuiltinCall("char_code/2", 2), I.GetLevel(202), - I.TryMeElse("L_ite_else_27"), + I.TryMeElse("L_ite_else_25"), I.PutValue(201, 1), I.PutConstant(V.Int(97), 2), I.BuiltinCall(">=/2", 2), @@ -905,7 +905,7 @@ const shared_instructions = [ I.BuiltinCall("==/2", 2), @@ -928,10 +928,10 @@ const shared_instructions = [ I.BuiltinCall("==/2", 2), @@ -940,10 +940,10 @@ const shared_instructions = [ I.BuiltinCall("==/2", 2), @@ -952,7 +952,7 @@ const shared_instructions = [ I.BuiltinCall("==/2", 2), @@ -1791,7 +1791,7 @@ const shared_instructions = [ I.PutStructure(19, 2, 1), I.SetValue(203), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_89"), + I.Jump("L_ite_cont_87"), I.TrustMe(), I.PutValue(204, 1), I.PutConstant(V.Int(2), 2), @@ -1849,7 +1849,7 @@ const shared_instructions = [ I.GetVariable(207, 7), I.GetVariable(208, 8), I.GetLevel(214), - I.TryMeElse("L_ite_else_91"), + I.TryMeElse("L_ite_else_89"), I.PutValue(209, 1), I.PutConstant(V.Atom(0), 2), I.BuiltinCall("==/2", 2), @@ -1865,10 +1865,10 @@ const shared_instructions = [ I.PutValue(207, 7), I.PutValue(208, 8), I.Call("strict_loop", 8), - I.Jump("L_ite_cont_91"), + I.Jump("L_ite_cont_89"), I.TrustMe(), I.GetLevel(215), - I.TryMeElse("L_ite_else_92"), + I.TryMeElse("L_ite_else_90"), I.PutValue(201, 1), I.PutConstant(V.String("--"), 2), I.BuiltinCall("==/2", 2), @@ -1882,18 +1882,18 @@ const shared_instructions = [ I.PutValue(207, 7), I.PutValue(208, 8), I.Call("strict_loop", 8), - I.Jump("L_ite_cont_92"), + I.Jump("L_ite_cont_90"), I.TrustMe(), I.GetLevel(216), - I.TryMeElse("L_ite_else_93"), + I.TryMeElse("L_ite_else_91"), I.GetLevel(217), - I.TryMeElse("L_ite_else_94"), + I.TryMeElse("L_ite_else_92"), I.PutValue(201, 1), I.PutConstant(V.String("--"), 2), I.Call("starts_with", 2), I.Cut(217), I.BuiltinCall("fail/0", 0), - I.Jump("L_ite_cont_94"), + I.Jump("L_ite_cont_92"), I.TrustMe(), I.BuiltinCall("true/0", 0), I.Cut(216), @@ -1908,14 +1908,14 @@ const shared_instructions = [ I.PutValue(207, 7), I.PutValue(208, 8), I.Call("strict_loop", 8), - I.Jump("L_ite_cont_93"), + I.Jump("L_ite_cont_91"), I.TrustMe(), I.PutValue(201, 1), I.PutVariable(210, 2), I.PutVariable(211, 3), I.Call("split_flag_token", 3), I.GetLevel(217), - I.TryMeElse("L_ite_else_95"), + I.TryMeElse("L_ite_else_93"), I.PutValue(203, 1), I.PutValue(210, 2), I.PutVariable(212, 3), @@ -1933,7 +1933,7 @@ const shared_instructions = [ I.PutValue(207, 10), I.PutValue(208, 11), I.Call("strict_option", 11), - I.Jump("L_ite_cont_95"), + I.Jump("L_ite_cont_93"), I.TrustMe(), I.PutConstant(V.String("unknown option --"), 1), I.PutValue(210, 2), @@ -1964,20 +1964,20 @@ const shared_instructions = [ I.GetVariable(213, 10), I.GetVariable(214, 11), I.GetLevel(225), - I.TryMeElse("L_ite_else_101"), + I.TryMeElse("L_ite_else_99"), I.PutValue(216, 1), I.PutConstant(V.Atom(12), 2), I.BuiltinCall("==/2", 2), I.Cut(225), I.GetLevel(226), - I.TryMeElse("L_ite_else_102"), + I.TryMeElse("L_ite_else_100"), I.PutValue(203, 1), I.PutStructure(19, 2, 1), I.SetVariable(201), I.BuiltinCall("=/2", 2), I.Cut(226), I.GetLevel(227), - I.TryMeElse("L_ite_else_103"), + I.TryMeElse("L_ite_else_101"), I.PutValue(201, 1), I.PutConstant(V.String("false"), 2), I.BuiltinCall("==/2", 2), @@ -1985,12 +1985,12 @@ const shared_instructions = [ I.PutVariable(202, 1), I.PutConstant(V.Atom(7), 2), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_103"), + I.Jump("L_ite_cont_101"), I.TrustMe(), I.PutVariable(202, 1), I.PutConstant(V.Atom(0), 2), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_102"), + I.Jump("L_ite_cont_100"), I.TrustMe(), I.PutVariable(202, 1), I.PutConstant(V.Atom(0), 2), @@ -2009,10 +2009,10 @@ const shared_instructions = [ I.PutValue(213, 7), I.PutValue(214, 8), I.Call("strict_loop", 8), - I.Jump("L_ite_cont_101"), + I.Jump("L_ite_cont_99"), I.TrustMe(), I.GetLevel(226), - I.TryMeElse("L_ite_else_104"), + I.TryMeElse("L_ite_else_102"), I.PutValue(203, 1), I.PutStructure(19, 2, 1), I.SetVariable(204), @@ -2032,19 +2032,19 @@ const shared_instructions = [ I.PutValue(213, 7), I.PutValue(214, 8), I.Call("strict_loop", 8), - I.Jump("L_ite_cont_104"), + I.Jump("L_ite_cont_102"), I.TrustMe(), I.PutValue(208, 1), I.PutVariable(215, 2), I.Call("next_value", 2), I.GetLevel(227), - I.TryMeElse("L_ite_else_105"), + I.TryMeElse("L_ite_else_103"), I.PutValue(216, 1), I.PutConstant(V.Atom(13), 2), I.BuiltinCall("==/2", 2), I.Cut(227), I.GetLevel(228), - I.TryMeElse("L_ite_else_106"), + I.TryMeElse("L_ite_else_104"), I.PutValue(215, 1), I.PutStructure(19, 2, 1), I.SetVariable(217), @@ -2069,7 +2069,7 @@ const shared_instructions = [ I.PutValue(213, 7), I.PutValue(214, 8), I.Call("strict_loop", 8), - I.Jump("L_ite_cont_106"), + I.Jump("L_ite_cont_104"), I.TrustMe(), I.PutConstant(V.String("--"), 1), I.PutValue(206, 2), @@ -2089,10 +2089,10 @@ const shared_instructions = [ I.PutStructure(8, 2, 1), I.SetValue(221), I.BuiltinCall("=/2", 2), - I.Jump("L_ite_cont_105"), + I.Jump("L_ite_cont_103"), I.TrustMe(), I.GetLevel(228), - I.TryMeElse("L_ite_else_107"), + I.TryMeElse("L_ite_else_105"), I.PutValue(215, 1), I.PutStructure(19, 2, 1), I.SetVariable(222), @@ -2117,7 +2117,7 @@ const shared_instructions = [ I.PutValue(213, 7), I.PutValue(214, 8), I.Call("strict_loop", 8), - I.Jump("L_ite_cont_107"), + I.Jump("L_ite_cont_105"), I.TrustMe(), I.PutValue(205, 1), I.PutValue(206, 2), @@ -2141,13 +2141,13 @@ const shared_instructions = [ I.UnifyVariable(201), I.UnifyVariable(203), I.GetLevel(204), - I.TryMeElse("L_ite_else_115"), + I.TryMeElse("L_ite_else_113"), I.PutValue(202, 1), I.PutValue(201, 2), I.BuiltinCall("==/2", 2), I.Cut(204), I.BuiltinCall("true/0", 0), - I.Jump("L_ite_cont_115"), + I.Jump("L_ite_cont_113"), I.TrustMe(), I.PutValue(202, 1), I.PutValue(203, 2), @@ -2211,97 +2211,97 @@ const shared_labels = { "substring_from/3": 2126, "strip_brackets/2": 2112, "string_member/2": 2093, - "L_ite_else_115": 2106, - "L_ite_cont_115": 2110, + "L_ite_else_113": 2106, + "L_ite_cont_113": 2110, "strict_option/11": 1909, - "L_ite_else_103": 1944, - "L_ite_cont_103": 1948, - "L_ite_else_102": 1949, - "L_ite_cont_102": 1953, - "L_ite_else_101": 1968, - "L_ite_else_104": 1991, - "L_ite_else_106": 2028, - "L_ite_cont_106": 2047, - "L_ite_else_105": 2048, - "L_ite_else_107": 2076, - "L_ite_cont_107": 2091, + "L_ite_else_101": 1944, + "L_ite_cont_101": 1948, + "L_ite_else_100": 1949, + "L_ite_cont_100": 1953, + "L_ite_else_99": 1968, + "L_ite_else_102": 1991, + "L_ite_else_104": 2028, + "L_ite_cont_104": 2047, + "L_ite_else_103": 2048, + "L_ite_else_105": 2076, "L_ite_cont_105": 2091, - "L_ite_cont_104": 2091, - "L_ite_cont_101": 2091, + "L_ite_cont_103": 2091, + "L_ite_cont_102": 2091, + "L_ite_cont_99": 2091, "strict_loop/8": 1783, "L_strict_loop_8_2": 1794, "L_strict_loop_8_2_body": 1795, - "L_ite_else_91": 1824, - "L_ite_else_92": 1841, - "L_ite_else_94": 1852, - "L_ite_cont_94": 1854, - "L_ite_else_93": 1867, - "L_ite_else_95": 1892, - "L_ite_cont_95": 1907, + "L_ite_else_89": 1824, + "L_ite_else_90": 1841, + "L_ite_else_92": 1852, + "L_ite_cont_92": 1854, + "L_ite_else_91": 1867, + "L_ite_else_93": 1892, "L_ite_cont_93": 1907, - "L_ite_cont_92": 1907, "L_ite_cont_91": 1907, + "L_ite_cont_90": 1907, + "L_ite_cont_89": 1907, "starts_with/2": 1760, "split_flag_token/3": 1718, - "L_ite_else_89": 1750, - "L_ite_cont_89": 1758, + "L_ite_else_87": 1750, + "L_ite_cont_87": 1758, "schema_for/5": 1677, - "L_ite_else_87": 1709, - "L_ite_cont_87": 1716, + "L_ite_else_85": 1709, + "L_ite_cont_85": 1716, "scan_leading_globals/4": 1566, "L_scan_leading_globals_4_2": 1573, "L_scan_leading_globals_4_2_body": 1574, - "L_ite_else_81": 1617, - "L_ite_else_82": 1644, - "L_ite_cont_82": 1655, - "L_ite_cont_81": 1655, - "L_ite_else_80": 1656, - "L_ite_cont_80": 1665, - "L_ite_else_79": 1666, - "L_ite_cont_79": 1675, + "L_ite_else_79": 1617, + "L_ite_else_80": 1644, + "L_ite_cont_80": 1655, + "L_ite_cont_79": 1655, + "L_ite_else_78": 1656, + "L_ite_cont_78": 1665, + "L_ite_else_77": 1666, + "L_ite_cont_77": 1675, "registry_entry/3": 1541, - "L_ite_else_77": 1556, - "L_ite_cont_77": 1564, + "L_ite_else_75": 1556, + "L_ite_cont_75": 1564, "parse_strict/4": 1481, - "L_ite_else_73": 1509, - "L_ite_else_74": 1529, - "L_ite_cont_74": 1539, - "L_ite_cont_73": 1539, + "L_ite_else_71": 1509, + "L_ite_else_72": 1529, + "L_ite_cont_72": 1539, + "L_ite_cont_71": 1539, "parse_lenient/3": 1466, "parse_args/3": 1336, - "L_ite_else_62": 1360, - "L_ite_cont_62": 1362, - "L_ite_else_63": 1376, - "L_ite_cont_63": 1380, - "L_ite_else_65": 1413, - "L_ite_cont_65": 1422, - "L_ite_else_66": 1445, - "L_ite_cont_66": 1454, - "L_ite_else_64": 1455, - "L_ite_cont_64": 1459, - "L_ite_else_61": 1460, - "L_ite_cont_61": 1464, + "L_ite_else_60": 1360, + "L_ite_cont_60": 1362, + "L_ite_else_61": 1376, + "L_ite_cont_61": 1380, + "L_ite_else_63": 1413, + "L_ite_cont_63": 1422, + "L_ite_else_64": 1445, + "L_ite_cont_64": 1454, + "L_ite_else_62": 1455, + "L_ite_cont_62": 1459, + "L_ite_else_59": 1460, + "L_ite_cont_59": 1464, "parse_args/2": 1326, "pair_lookup/3": 1300, - "L_ite_else_59": 1319, - "L_ite_cont_59": 1324, + "L_ite_else_57": 1319, + "L_ite_cont_57": 1324, "option_kind/3": 1263, - "L_ite_else_55": 1278, - "L_ite_else_56": 1292, - "L_ite_cont_56": 1298, - "L_ite_cont_55": 1298, + "L_ite_else_53": 1278, + "L_ite_else_54": 1292, + "L_ite_cont_54": 1298, + "L_ite_cont_53": 1298, "nth0_default/4": 1222, - "L_ite_else_52": 1245, - "L_ite_cont_52": 1256, - "L_ite_else_51": 1257, - "L_ite_cont_51": 1261, + "L_ite_else_50": 1245, + "L_ite_cont_50": 1256, + "L_ite_else_49": 1257, + "L_ite_cont_49": 1261, "next_value/2": 1185, "L_next_value_2_2": 1190, "L_next_value_2_2_body": 1191, - "L_ite_else_48": 1208, - "L_ite_cont_48": 1210, - "L_ite_else_47": 1216, - "L_ite_cont_47": 1220, + "L_ite_else_46": 1208, + "L_ite_cont_46": 1210, + "L_ite_else_45": 1216, + "L_ite_cont_45": 1220, "merge_flags_/3": 1159, "L_merge_flags__3_2": 1165, "L_merge_flags__3_2_body": 1166, @@ -2310,57 +2310,57 @@ const shared_labels = { "long_flag_tail/1": 1107, "L_long_flag_tail_1_2": 1111, "L_long_flag_tail_1_2_body": 1112, - "L_ite_else_45": 1124, - "L_ite_cont_45": 1129, + "L_ite_else_43": 1124, + "L_ite_cont_43": 1129, "lenient_result/2": 1097, "lenient_loop/5": 997, "L_lenient_loop_5_2": 1005, "L_lenient_loop_5_2_body": 1006, - "L_ite_else_38": 1043, - "L_ite_else_40": 1058, - "L_ite_cont_40": 1060, - "L_ite_else_39": 1073, - "L_ite_cont_39": 1085, - "L_ite_cont_38": 1085, - "L_ite_else_37": 1086, - "L_ite_cont_37": 1095, + "L_ite_else_36": 1043, + "L_ite_else_38": 1058, + "L_ite_cont_38": 1060, + "L_ite_else_37": 1073, + "L_ite_cont_37": 1085, + "L_ite_cont_36": 1085, + "L_ite_else_35": 1086, + "L_ite_cont_35": 1095, "legacy_flag_tail/1": 983, "L_legacy_flag_tail_1_2": 987, "L_legacy_flag_tail_1_2_body": 988, "last_element/2": 962, - "L_ite_else_35": 977, - "L_ite_cont_35": 981, + "L_ite_else_33": 977, + "L_ite_cont_33": 981, "js_object_prototype_keys/1": 925, "js_object_prototype_key/1": 917, "js_flag_char/1": 873, - "L_ite_else_29": 887, - "L_ite_else_30": 899, - "L_ite_else_31": 911, - "L_ite_cont_31": 915, - "L_ite_cont_30": 915, + "L_ite_else_27": 887, + "L_ite_else_28": 899, + "L_ite_else_29": 911, "L_ite_cont_29": 915, + "L_ite_cont_28": 915, + "L_ite_cont_27": 915, "js_alpha/1": 850, - "L_ite_else_27": 864, - "L_ite_cont_27": 871, + "L_ite_else_25": 864, + "L_ite_cont_25": 871, "is_long_flag/1": 831, "is_global_key/1": 813, - "L_ite_else_25": 826, - "L_ite_cont_25": 829, + "L_ite_else_23": 826, + "L_ite_cont_23": 829, "global_options/1": 800, "flags_set/4": 777, - "L_ite_else_23": 792, - "L_ite_cont_23": 798, + "L_ite_else_21": 792, + "L_ite_cont_21": 798, "flags_put/4": 723, "L_flags_put_4_2": 735, "L_flags_put_4_2_body": 736, - "L_ite_else_21": 761, - "L_ite_cont_21": 775, + "L_ite_else_19": 761, + "L_ite_cont_19": 775, "first_equals_index/2": 711, "first_char_index/4": 673, "L_first_char_index_4_2": 680, "L_first_char_index_4_2_body": 681, - "L_ite_else_19": 698, - "L_ite_cont_19": 709, + "L_ite_else_17": 698, + "L_ite_cont_17": 709, "drop_brackets/2": 636, "L_drop_brackets_2_2": 641, "L_drop_brackets_2_2_body": 642, @@ -2457,10 +2457,59 @@ Runtime.resolve_program(shared_program); const lowered_dispatch = {}; -// wamjs lower fallback: substring_range/4 fallback(execute of a non-self callee (nested Runtime.run would steal CP)) -// wamjs lower fallback: substring_from/3 fallback(execute of a non-self callee (nested Runtime.run would steal CP)) +// Lowered: substring_range/4 (deterministic) +function lowered_substring_range_4(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("substring_range/4"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 106, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 4)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_structure(program, state, 11, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 106) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_builtin(program, state, "is/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } + Runtime.put_reg(state, 5, Runtime.get_reg(state, 205)); + if (Runtime.op_deallocate(state) !== true) return false; + return Runtime.op_builtin(program, state, "sub_string", 5) === true; + return true; +} + +lowered_dispatch["substring_range/4"] = function (program, state) { return lowered_substring_range_4(program, state); }; +// Lowered: substring_from/3 (deterministic) +function lowered_substring_from_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("substring_from/3"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 202, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 203, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } + if (Runtime.op_builtin(program, state, "string_length/2", 2) !== true) return false; + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_structure(program, state, 11, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 201) !== true) return false; + if (Runtime.op_unify_value(program, state, 203) !== true) return false; + if (Runtime.op_builtin(program, state, "is/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 4, V.Int(0)); + Runtime.put_reg(state, 5, Runtime.get_reg(state, 205)); + if (Runtime.op_deallocate(state) !== true) return false; + return Runtime.op_builtin(program, state, "sub_string", 5) === true; + return true; +} + +lowered_dispatch["substring_from/3"] = function (program, state) { return lowered_substring_from_3(program, state); }; // Lowered: strip_brackets/2 (deterministic) function lowered_strip_brackets_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("strip_brackets/2"); if (Runtime.op_allocate(state) !== true) return false; Runtime.put_reg(state, 104, Runtime.get_reg(state, 1)); Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); @@ -2469,25 +2518,25 @@ function lowered_strip_brackets_2(program, state) { if (Runtime.op_builtin(program, state, "string_chars/2", 2) !== true) return false; Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 2, v); } - { + if (typeof lowered_drop_brackets_2 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_drop_brackets_2); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["drop_brackets/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["drop_brackets/2"] : undefined); + const target = program.labels["drop_brackets/2"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["drop_brackets/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("drop_brackets", 2)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("drop_brackets", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -2502,9 +2551,10 @@ function lowered_strip_brackets_2(program, state) { return true; } -lowered_dispatch["strip_brackets/2"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("strip_brackets/2"); return lowered_strip_brackets_2(program, state); }; +lowered_dispatch["strip_brackets/2"] = function (program, state) { return lowered_strip_brackets_2(program, state); }; // Lowered: string_member/2 (if-then-else / negation / once) function lowered_string_member_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("string_member/2"); if (Runtime.op_allocate(state) !== true) return false; Runtime.put_reg(state, 202, Runtime.get_reg(state, 1)); if (Runtime.op_get_list(program, state, 2, 5) !== true) return false; @@ -2527,25 +2577,22 @@ function lowered_string_member_2(program, state) { Runtime.restore_a_regs(state, _ite_args); Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); - { + if (typeof lowered_string_member_2 === "function") { + if (lowered_string_member_2(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["string_member/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["string_member/2"] : undefined); + const target = program.labels["string_member/2"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["string_member/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("string_member", 2)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("string_member", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -2559,9 +2606,10 @@ function lowered_string_member_2(program, state) { return true; } -lowered_dispatch["string_member/2"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("string_member/2"); return lowered_string_member_2(program, state); }; +lowered_dispatch["string_member/2"] = function (program, state) { return lowered_string_member_2(program, state); }; // Lowered: strict_option/11 (if-then-else / negation / once) function lowered_strict_option_11(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("strict_option/11"); if (Runtime.op_allocate(state) !== true) return false; Runtime.put_reg(state, 216, Runtime.get_reg(state, 1)); Runtime.put_reg(state, 206, Runtime.get_reg(state, 2)); @@ -2587,8 +2635,7 @@ function lowered_strict_option_11(program, state) { if (_ite_cond) { if (Runtime.op_get_level(state, 226) !== true) return false; { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; + const _ite_lite = Runtime.snapshot_lite(state); const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; @@ -2620,8 +2667,7 @@ function lowered_strict_option_11(program, state) { } } } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.restore_lite(state, _ite_lite); { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 1, v); } Runtime.put_reg(state, 2, V.Atom(0)); if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; @@ -2631,25 +2677,22 @@ function lowered_strict_option_11(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 202)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 4, v); } - { + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_set/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_set/4"] : undefined); + const target = program.labels["flags_set/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["flags_set/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -2664,25 +2707,22 @@ function lowered_strict_option_11(program, state) { Runtime.put_reg(state, 6, Runtime.get_reg(state, 212)); Runtime.put_reg(state, 7, Runtime.get_reg(state, 213)); Runtime.put_reg(state, 8, Runtime.get_reg(state, 214)); - { + if (typeof lowered_strict_loop_8 === "function") { + if (lowered_strict_loop_8(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["strict_loop/8"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["strict_loop/8"] : undefined); + const target = program.labels["strict_loop/8"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["strict_loop/8"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -2694,8 +2734,7 @@ function lowered_strict_option_11(program, state) { Runtime.restore_a_regs(state, _ite_args); if (Runtime.op_get_level(state, 226) !== true) return false; { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; + const _ite_lite = Runtime.snapshot_lite(state); const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; @@ -2708,25 +2747,22 @@ function lowered_strict_option_11(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 204)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 4, v); } - { + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_set/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_set/4"] : undefined); + const target = program.labels["flags_set/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["flags_set/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -2741,25 +2777,22 @@ function lowered_strict_option_11(program, state) { Runtime.put_reg(state, 6, Runtime.get_reg(state, 212)); Runtime.put_reg(state, 7, Runtime.get_reg(state, 213)); Runtime.put_reg(state, 8, Runtime.get_reg(state, 214)); - { + if (typeof lowered_strict_loop_8 === "function") { + if (lowered_strict_loop_8(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["strict_loop/8"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["strict_loop/8"] : undefined); + const target = program.labels["strict_loop/8"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["strict_loop/8"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -2767,29 +2800,25 @@ function lowered_strict_option_11(program, state) { if (!_ok) return false; } } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.restore_lite(state, _ite_lite); Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 215, v); Runtime.put_reg(state, 2, v); } - { + if (typeof lowered_next_value_2 === "function") { + if (lowered_next_value_2(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["next_value/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["next_value/2"] : undefined); + const target = program.labels["next_value/2"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["next_value/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("next_value", 2)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("next_value", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -2809,8 +2838,7 @@ function lowered_strict_option_11(program, state) { if (_ite_cond) { if (Runtime.op_get_level(state, 228) !== true) return false; { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; + const _ite_lite = Runtime.snapshot_lite(state); const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 215)); if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; @@ -2823,25 +2851,22 @@ function lowered_strict_option_11(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 217)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 4, v); } - { + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_set/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_set/4"] : undefined); + const target = program.labels["flags_set/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["flags_set/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -2861,25 +2886,22 @@ function lowered_strict_option_11(program, state) { Runtime.put_reg(state, 6, Runtime.get_reg(state, 212)); Runtime.put_reg(state, 7, Runtime.get_reg(state, 213)); Runtime.put_reg(state, 8, Runtime.get_reg(state, 214)); - { + if (typeof lowered_strict_loop_8 === "function") { + if (lowered_strict_loop_8(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["strict_loop/8"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["strict_loop/8"] : undefined); + const target = program.labels["strict_loop/8"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["strict_loop/8"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -2887,8 +2909,7 @@ function lowered_strict_option_11(program, state) { if (!_ok) return false; } } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.restore_lite(state, _ite_lite); Runtime.put_reg(state, 1, V.String("--")); Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 220, v); Runtime.put_reg(state, 3, v); } @@ -2914,8 +2935,7 @@ function lowered_strict_option_11(program, state) { Runtime.restore_a_regs(state, _ite_args); if (Runtime.op_get_level(state, 228) !== true) return false; { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; + const _ite_lite = Runtime.snapshot_lite(state); const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 215)); if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; @@ -2928,25 +2948,22 @@ function lowered_strict_option_11(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 222)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 4, v); } - { + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_set/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_set/4"] : undefined); + const target = program.labels["flags_set/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["flags_set/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -2966,25 +2983,22 @@ function lowered_strict_option_11(program, state) { Runtime.put_reg(state, 6, Runtime.get_reg(state, 212)); Runtime.put_reg(state, 7, Runtime.get_reg(state, 213)); Runtime.put_reg(state, 8, Runtime.get_reg(state, 214)); - { + if (typeof lowered_strict_loop_8 === "function") { + if (lowered_strict_loop_8(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["strict_loop/8"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["strict_loop/8"] : undefined); + const target = program.labels["strict_loop/8"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["strict_loop/8"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -2992,31 +3006,27 @@ function lowered_strict_option_11(program, state) { if (!_ok) return false; } } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.restore_lite(state, _ite_lite); Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); Runtime.put_reg(state, 3, V.Atom(0)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 4, v); } - { + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_set/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_set/4"] : undefined); + const target = program.labels["flags_set/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["flags_set/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3031,25 +3041,22 @@ function lowered_strict_option_11(program, state) { Runtime.put_reg(state, 6, Runtime.get_reg(state, 212)); Runtime.put_reg(state, 7, Runtime.get_reg(state, 213)); Runtime.put_reg(state, 8, Runtime.get_reg(state, 214)); - { + if (typeof lowered_strict_loop_8 === "function") { + if (lowered_strict_loop_8(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["strict_loop/8"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["strict_loop/8"] : undefined); + const target = program.labels["strict_loop/8"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["strict_loop/8"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3069,21 +3076,12 @@ function lowered_strict_option_11(program, state) { return true; } -lowered_dispatch["strict_option/11"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("strict_option/11"); return lowered_strict_option_11(program, state); }; -// Lowered: strict_loop/8 (T4 all-clauses inline) +lowered_dispatch["strict_option/11"] = function (program, state) { return lowered_strict_option_11(program, state); }; +// Lowered: strict_loop/8 (T4 nil/cons dispatch; no snapshot on bound A1) function lowered_strict_loop_8(program, state) { - const _t4_trail = state.trail.length; - const _t4_regs = Runtime.copy_table(state.regs); - const _t4_vc = state.var_counter; - const _t4_stack = state.stack.slice(); - const _t4_ysave = (state.y_save || []).slice(); - const _t4_mode = state.mode; - const _t4_build = state.build_stack.slice(); - const _t4_rstack = (state.read_stack || []).slice(); - const _t4_rargs = state.read_args; - const _t4_rcur = state.read_cursor; - if ((function () { - if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; + if (Runtime._prof) Runtime.prof_lowered_call("strict_loop/8"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); Runtime.put_reg(state, 103, Runtime.get_reg(state, 4)); @@ -3092,19 +3090,9 @@ function lowered_strict_loop_8(program, state) { if (Runtime.op_get_value(program, state, 104, 7) !== true) return false; if (Runtime.op_get_constant(program, state, 8, V.Atom(9)) !== true) return false; return true; - return false; - })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; - if ((function () { + return true; + } + if (Runtime.term_is_cons(program, _a1)) { if (Runtime.op_allocate(state) !== true) return false; if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; if (Runtime.op_unify_variable(state, 201) !== true) return false; @@ -3137,25 +3125,22 @@ function lowered_strict_loop_8(program, state) { Runtime.put_reg(state, 6, Runtime.get_reg(state, 206)); Runtime.put_reg(state, 7, Runtime.get_reg(state, 207)); Runtime.put_reg(state, 8, Runtime.get_reg(state, 208)); - { + if (typeof lowered_strict_loop_8 === "function") { + if (lowered_strict_loop_8(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["strict_loop/8"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["strict_loop/8"] : undefined); + const target = program.labels["strict_loop/8"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["strict_loop/8"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3184,25 +3169,22 @@ function lowered_strict_loop_8(program, state) { Runtime.put_reg(state, 6, Runtime.get_reg(state, 206)); Runtime.put_reg(state, 7, Runtime.get_reg(state, 207)); Runtime.put_reg(state, 8, Runtime.get_reg(state, 208)); - { + if (typeof lowered_strict_loop_8 === "function") { + if (lowered_strict_loop_8(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["strict_loop/8"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["strict_loop/8"] : undefined); + const target = program.labels["strict_loop/8"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["strict_loop/8"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3224,25 +3206,22 @@ function lowered_strict_loop_8(program, state) { const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); Runtime.put_reg(state, 2, V.String("--")); - { + if (typeof lowered_starts_with_2 === "function") { + if (lowered_starts_with_2(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["starts_with/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["starts_with/2"] : undefined); + const target = program.labels["starts_with/2"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["starts_with/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3272,25 +3251,22 @@ function lowered_strict_loop_8(program, state) { Runtime.put_reg(state, 6, Runtime.get_reg(state, 206)); Runtime.put_reg(state, 7, Runtime.get_reg(state, 207)); Runtime.put_reg(state, 8, Runtime.get_reg(state, 208)); - { + if (typeof lowered_strict_loop_8 === "function") { + if (lowered_strict_loop_8(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["strict_loop/8"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["strict_loop/8"] : undefined); + const target = program.labels["strict_loop/8"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["strict_loop/8"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3303,25 +3279,22 @@ function lowered_strict_loop_8(program, state) { Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 210, v); Runtime.put_reg(state, 2, v); } { const v = Runtime.new_var(state); Runtime.put_reg(state, 211, v); Runtime.put_reg(state, 3, v); } - { + if (typeof lowered_split_flag_token_3 === "function") { + if (lowered_split_flag_token_3(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["split_flag_token/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["split_flag_token/3"] : undefined); + const target = program.labels["split_flag_token/3"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["split_flag_token/3"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("split_flag_token", 3)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("split_flag_token", 3)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3336,25 +3309,22 @@ function lowered_strict_loop_8(program, state) { Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 210)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 212, v); Runtime.put_reg(state, 3, v); } - { + if (typeof lowered_option_kind_3 === "function") { + if (lowered_option_kind_3(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["option_kind/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["option_kind/3"] : undefined); + const target = program.labels["option_kind/3"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["option_kind/3"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("option_kind", 3)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("option_kind", 3)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3375,25 +3345,22 @@ function lowered_strict_loop_8(program, state) { Runtime.put_reg(state, 9, Runtime.get_reg(state, 206)); Runtime.put_reg(state, 10, Runtime.get_reg(state, 207)); Runtime.put_reg(state, 11, Runtime.get_reg(state, 208)); - { + if (typeof lowered_strict_option_11 === "function") { + if (lowered_strict_option_11(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["strict_option/11"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["strict_option/11"] : undefined); + const target = program.labels["strict_option/11"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["strict_option/11"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("strict_option", 11)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strict_option", 11)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3427,6 +3394,28 @@ function lowered_strict_loop_8(program, state) { } if (Runtime.op_deallocate(state) !== true) return false; return true; + return true; + } + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 103, Runtime.get_reg(state, 4)); + Runtime.put_reg(state, 104, Runtime.get_reg(state, 5)); + if (Runtime.op_get_value(program, state, 103, 6) !== true) return false; + if (Runtime.op_get_value(program, state, 104, 7) !== true) return false; + if (Runtime.op_get_constant(program, state, 8, V.Atom(9)) !== true) return false; + return true; return false; })()) return true; while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } @@ -3439,153 +3428,46 @@ function lowered_strict_loop_8(program, state) { state.read_stack = _t4_rstack.slice(); state.read_args = _t4_rargs; state.read_cursor = _t4_rcur; - return false; -} - -lowered_dispatch["strict_loop/8"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("strict_loop/8"); return lowered_strict_loop_8(program, state); }; -// Lowered: starts_with/2 (deterministic) -function lowered_starts_with_2(program, state) { - if (Runtime.op_allocate(state) !== true) return false; - Runtime.put_reg(state, 202, Runtime.get_reg(state, 1)); - Runtime.put_reg(state, 206, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } - if (Runtime.op_builtin(program, state, "string_length/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 2, v); } - if (Runtime.op_builtin(program, state, "string_length/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); - if (Runtime.op_builtin(program, state, ">=/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); - Runtime.put_reg(state, 2, V.Int(0)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } - { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 5, v); } - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["sub_string/5"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["sub_string/5"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["sub_string/5"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("sub_string", 5)) !== true) { - _ok = false; - } - } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); - if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; - if (Runtime.op_deallocate(state) !== true) return false; - return true; - return true; -} - -lowered_dispatch["starts_with/2"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("starts_with/2"); return lowered_starts_with_2(program, state); }; -// Lowered: split_flag_token/3 (if-then-else / negation / once) -function lowered_split_flag_token_3(program, state) { - if (Runtime.op_allocate(state) !== true) return false; - Runtime.put_reg(state, 204, Runtime.get_reg(state, 1)); - Runtime.put_reg(state, 205, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 206, Runtime.get_reg(state, 3)); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["first_equals_index/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["first_equals_index/2"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["first_equals_index/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("first_equals_index", 2)) !== true) { - _ok = false; - } - } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - if (Runtime.op_get_level(state, 207) !== true) return false; - { - const _ite_trail = state.trail.length; - const _ite_args = Runtime.capture_a_regs(state, 8); - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, V.Int(0)); - if (Runtime.op_builtin(program, state, ">=/2", 2) !== true) return false; - return true; - })(); - if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); - Runtime.put_reg(state, 2, V.Int(2)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 4, Runtime.get_reg(state, 205)); - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["substring_range/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["substring_range/4"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["substring_range/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("substring_range", 4)) !== true) { - _ok = false; - } - } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 1, v); } - if (Runtime.op_put_structure(program, state, 10, 2, 2) !== true) return false; - if (Runtime.op_unify_value(program, state, 201) !== true) return false; - if (Runtime.op_unify_constant(program, state, V.Int(1)) !== true) return false; - if (Runtime.op_builtin(program, state, "is/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 3, v); } - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["substring_from/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["substring_from/3"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + Runtime.put_reg(state, 209, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 203, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 204, Runtime.get_reg(state, 4)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 5)); + Runtime.put_reg(state, 206, Runtime.get_reg(state, 6)); + Runtime.put_reg(state, 207, Runtime.get_reg(state, 7)); + Runtime.put_reg(state, 208, Runtime.get_reg(state, 8)); + if (Runtime.op_get_level(state, 214) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 209)); + Runtime.put_reg(state, 2, V.Atom(0)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, V.Atom(0)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + if (Runtime.op_put_structure(program, state, 5, 4, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 201) !== true) return false; + if (Runtime.op_unify_value(program, state, 204) !== true) return false; + Runtime.put_reg(state, 5, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 6, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 7, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 8, Runtime.get_reg(state, 208)); + if (typeof lowered_strict_loop_8 === "function") { + if (lowered_strict_loop_8(program, state) !== true) return false; } else { - const target = program.labels["substring_from/3"]; + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["strict_loop/8"]; + let _ok = true; if (target !== undefined && target !== null) { Runtime.push_y_save(state); state.cp = 0; @@ -3593,44 +3475,421 @@ function lowered_split_flag_token_3(program, state) { state.program = program; _ok = Runtime.run_isolated(program, state) === true; state.halt = false; - } else if (Runtime.step(program, state, I.Call("substring_from", 3)) !== true) { + } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { _ok = false; } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); - if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; - if (Runtime.op_unify_value(program, state, 203) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } else { - Runtime.undo_trail(state, _ite_trail); - Runtime.restore_a_regs(state, _ite_args); + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + if (Runtime.op_get_level(state, 215) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, V.String("--")); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, V.Atom(0)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 5, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 6, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 7, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 8, Runtime.get_reg(state, 208)); + if (typeof lowered_strict_loop_8 === "function") { + if (lowered_strict_loop_8(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["strict_loop/8"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + if (Runtime.op_get_level(state, 216) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + if (Runtime.op_get_level(state, 217) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, V.String("--")); + if (typeof lowered_starts_with_2 === "function") { + if (lowered_starts_with_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["starts_with/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + if (Runtime.op_builtin(program, state, "fail/0", 0) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; + } + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 209)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + if (Runtime.op_put_structure(program, state, 5, 4, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 201) !== true) return false; + if (Runtime.op_unify_value(program, state, 204) !== true) return false; + Runtime.put_reg(state, 5, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 6, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 7, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 8, Runtime.get_reg(state, 208)); + if (typeof lowered_strict_loop_8 === "function") { + if (lowered_strict_loop_8(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["strict_loop/8"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 210, v); Runtime.put_reg(state, 2, v); } + { const v = Runtime.new_var(state); Runtime.put_reg(state, 211, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_split_flag_token_3 === "function") { + if (lowered_split_flag_token_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["split_flag_token/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("split_flag_token", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + if (Runtime.op_get_level(state, 217) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 210)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 212, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_option_kind_3 === "function") { + if (lowered_option_kind_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["option_kind/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("option_kind", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 212)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 210)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 211)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 5, Runtime.get_reg(state, 209)); + Runtime.put_reg(state, 6, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 7, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 8, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 9, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 10, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 11, Runtime.get_reg(state, 208)); + if (typeof lowered_strict_option_11 === "function") { + if (lowered_strict_option_11(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["strict_option/11"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strict_option", 11)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, V.String("unknown option --")); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 210)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 213, v); Runtime.put_reg(state, 3, v); } + if (Runtime.op_builtin(program, state, "string_concat/3", 3) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); + if (Runtime.op_put_structure(program, state, 8, 2, 1) !== true) return false; + if (Runtime.op_unify_value(program, state, 213) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + } + } + } + } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return false; + })()) return true; + return false; +} + +lowered_dispatch["strict_loop/8"] = function (program, state) { return lowered_strict_loop_8(program, state); }; +// Lowered: starts_with/2 (deterministic) +function lowered_starts_with_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("starts_with/2"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 202, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 206, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } + if (Runtime.op_builtin(program, state, "string_length/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 2, v); } + if (Runtime.op_builtin(program, state, "string_length/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + if (Runtime.op_builtin(program, state, ">=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, V.Int(0)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } + { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 5, v); } + if (Runtime.op_builtin(program, state, "sub_string", 5) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 206)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; +} + +lowered_dispatch["starts_with/2"] = function (program, state) { return lowered_starts_with_2(program, state); }; +// Lowered: split_flag_token/3 (if-then-else / negation / once) +function lowered_split_flag_token_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("split_flag_token/3"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 204, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 206, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } + if (typeof lowered_first_equals_index_2 === "function") { + if (lowered_first_equals_index_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["first_equals_index/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("first_equals_index", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + if (Runtime.op_get_level(state, 207) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, V.Int(0)); + if (Runtime.op_builtin(program, state, ">=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, V.Int(2)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 205)); + if (typeof lowered_substring_range_4 === "function") { + if (lowered_substring_range_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["substring_range/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("substring_range", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_structure(program, state, 10, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 201) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Int(1)) !== true) return false; + if (Runtime.op_builtin(program, state, "is/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_substring_from_3 === "function") { + if (lowered_substring_from_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["substring_from/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("substring_from", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; + if (Runtime.op_unify_value(program, state, 203) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); Runtime.put_reg(state, 2, V.Int(2)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); - { + if (typeof lowered_substring_from_3 === "function") { + if (lowered_substring_from_3(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["substring_from/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["substring_from/3"] : undefined); + const target = program.labels["substring_from/3"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["substring_from/3"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("substring_from", 3)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("substring_from", 3)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3647,9 +3906,10 @@ function lowered_split_flag_token_3(program, state) { return true; } -lowered_dispatch["split_flag_token/3"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("split_flag_token/3"); return lowered_split_flag_token_3(program, state); }; +lowered_dispatch["split_flag_token/3"] = function (program, state) { return lowered_split_flag_token_3(program, state); }; // Lowered: schema_for/5 (if-then-else / negation / once) function lowered_schema_for_5(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("schema_for/5"); if (Runtime.op_allocate(state) !== true) return false; Runtime.put_reg(state, 107, Runtime.get_reg(state, 1)); Runtime.put_reg(state, 201, Runtime.get_reg(state, 2)); @@ -3659,25 +3919,22 @@ function lowered_schema_for_5(program, state) { Runtime.put_reg(state, 1, Runtime.get_reg(state, 108)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 107)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 3, v); } - { + if (typeof lowered_registry_entry_3 === "function") { + if (lowered_registry_entry_3(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["registry_entry/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["registry_entry/3"] : undefined); + const target = program.labels["registry_entry/3"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["registry_entry/3"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("registry_entry", 3)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("registry_entry", 3)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3686,8 +3943,7 @@ function lowered_schema_for_5(program, state) { } if (Runtime.op_get_level(state, 207) !== true) return false; { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; + const _ite_lite = Runtime.snapshot_lite(state); const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); if (Runtime.op_put_structure(program, state, 15, 2, 1) !== true) return false; @@ -3706,15 +3962,111 @@ function lowered_schema_for_5(program, state) { Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 204)); - { + if (typeof lowered_action_entry_3 === "function") { + if (lowered_action_entry_3(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["action_entry/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["action_entry/3"] : undefined); + const target = program.labels["action_entry/3"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("action_entry", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, V.Atom(0)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_lite(state, _ite_lite); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, V.Atom(7)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; +} + +lowered_dispatch["schema_for/5"] = function (program, state) { return lowered_schema_for_5(program, state); }; +// Lowered: scan_leading_globals/4 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_scan_leading_globals_4(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("scan_leading_globals/4"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + if (Runtime.op_get_constant(program, state, 3, V.Atom(2)) !== true) return false; + if (Runtime.op_get_value(program, state, 101, 4) !== true) return false; + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 210) !== true) return false; + if (Runtime.op_unify_variable(state, 211) !== true) return false; + Runtime.put_reg(state, 213, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 209, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 212, Runtime.get_reg(state, 4)); + if (Runtime.op_get_level(state, 214) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 210)); + Runtime.put_reg(state, 2, V.String("--")); + if (typeof lowered_starts_with_2 === "function") { + if (lowered_starts_with_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["starts_with/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 210)); + Runtime.put_reg(state, 2, V.String("--")); + if (Runtime.op_builtin(program, state, "\\==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 210)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_split_flag_token_3 === "function") { + if (lowered_split_flag_token_3(program, state) !== true) return false; } else { - const target = program.labels["action_entry/3"]; + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["split_flag_token/3"]; + let _ok = true; if (target !== undefined && target !== null) { Runtime.push_y_save(state); state.cp = 0; @@ -3722,37 +4074,290 @@ function lowered_schema_for_5(program, state) { state.program = program; _ok = Runtime.run_isolated(program, state) === true; state.halt = false; - } else if (Runtime.step(program, state, I.Call("action_entry", 3)) !== true) { + } else if (Runtime.step(program, state, I.Call("split_flag_token", 3)) !== true) { _ok = false; } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + if (Runtime.op_get_level(state, 215) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (typeof lowered_is_global_key_1 === "function") { + if (lowered_is_global_key_1(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["is_global_key/1"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("is_global_key", 1)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + if (Runtime.op_get_level(state, 216) !== true) return false; + { + const _ite_lite = Runtime.snapshot_lite(state); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 213)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["flags_set/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 211)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 209)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 212)); + if (typeof lowered_scan_leading_globals_4 === "function") { + if (lowered_scan_leading_globals_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["scan_leading_globals/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("scan_leading_globals", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } else { + Runtime.restore_lite(state, _ite_lite); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 211)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 2, v); } + if (typeof lowered_next_value_2 === "function") { + if (lowered_next_value_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["next_value/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("next_value", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + if (Runtime.op_get_level(state, 217) !== true) return false; + { + const _ite_lite = Runtime.snapshot_lite(state); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; + if (Runtime.op_unify_variable(state, 206) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 213)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 206)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["flags_set/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 211)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 207) !== true) return false; + if (Runtime.op_unify_variable(state, 208) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 209)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 212)); + if (typeof lowered_scan_leading_globals_4 === "function") { + if (lowered_scan_leading_globals_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["scan_leading_globals/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("scan_leading_globals", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } else { + Runtime.restore_lite(state, _ite_lite); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 213)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 3, V.Atom(0)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["flags_set/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 211)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 209)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 212)); + if (typeof lowered_scan_leading_globals_4 === "function") { + if (lowered_scan_leading_globals_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["scan_leading_globals/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("scan_leading_globals", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } + } + } + } + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 209)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 210) !== true) return false; + if (Runtime.op_unify_value(program, state, 211) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 212)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 213)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 209)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 210) !== true) return false; + if (Runtime.op_unify_value(program, state, 211) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 212)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 213)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); - Runtime.put_reg(state, 2, V.Atom(0)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); - Runtime.put_reg(state, 2, V.Atom(7)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; } - if (Runtime.op_deallocate(state) !== true) return false; - return true; - return true; -} - -lowered_dispatch["schema_for/5"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("schema_for/5"); return lowered_schema_for_5(program, state); }; -// Lowered: scan_leading_globals/4 (T4 all-clauses inline) -function lowered_scan_leading_globals_4(program, state) { const _t4_trail = state.trail.length; const _t4_regs = Runtime.copy_table(state.regs); const _t4_vc = state.var_counter; @@ -3796,25 +4401,22 @@ function lowered_scan_leading_globals_4(program, state) { const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 210)); Runtime.put_reg(state, 2, V.String("--")); - { + if (typeof lowered_starts_with_2 === "function") { + if (lowered_starts_with_2(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["starts_with/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["starts_with/2"] : undefined); + const target = program.labels["starts_with/2"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["starts_with/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3830,25 +4432,22 @@ function lowered_scan_leading_globals_4(program, state) { Runtime.put_reg(state, 1, Runtime.get_reg(state, 210)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 3, v); } - { + if (typeof lowered_split_flag_token_3 === "function") { + if (lowered_split_flag_token_3(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["split_flag_token/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["split_flag_token/3"] : undefined); + const target = program.labels["split_flag_token/3"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["split_flag_token/3"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("split_flag_token", 3)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("split_flag_token", 3)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3861,25 +4460,22 @@ function lowered_scan_leading_globals_4(program, state) { const _ite_cps = state.cps.length; const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - { + if (typeof lowered_is_global_key_1 === "function") { + if (lowered_is_global_key_1(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["is_global_key/1"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["is_global_key/1"] : undefined); + const target = program.labels["is_global_key/1"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["is_global_key/1"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("is_global_key", 1)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("is_global_key", 1)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3891,8 +4487,7 @@ function lowered_scan_leading_globals_4(program, state) { if (_ite_cond) { if (Runtime.op_get_level(state, 216) !== true) return false; { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; + const _ite_lite = Runtime.snapshot_lite(state); const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; @@ -3905,25 +4500,22 @@ function lowered_scan_leading_globals_4(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 201)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } - { + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_set/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_set/4"] : undefined); + const target = program.labels["flags_set/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["flags_set/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3934,25 +4526,22 @@ function lowered_scan_leading_globals_4(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 209)); Runtime.put_reg(state, 4, Runtime.get_reg(state, 212)); - { + if (typeof lowered_scan_leading_globals_4 === "function") { + if (lowered_scan_leading_globals_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["scan_leading_globals/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["scan_leading_globals/4"] : undefined); + const target = program.labels["scan_leading_globals/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["scan_leading_globals/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("scan_leading_globals", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("scan_leading_globals", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3960,29 +4549,25 @@ function lowered_scan_leading_globals_4(program, state) { if (!_ok) return false; } } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.restore_lite(state, _ite_lite); Runtime.put_reg(state, 1, Runtime.get_reg(state, 211)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 2, v); } - { + if (typeof lowered_next_value_2 === "function") { + if (lowered_next_value_2(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["next_value/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["next_value/2"] : undefined); + const target = program.labels["next_value/2"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["next_value/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("next_value", 2)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("next_value", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -3991,8 +4576,7 @@ function lowered_scan_leading_globals_4(program, state) { } if (Runtime.op_get_level(state, 217) !== true) return false; { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; + const _ite_lite = Runtime.snapshot_lite(state); const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; @@ -4005,25 +4589,22 @@ function lowered_scan_leading_globals_4(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 201)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 206)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } - { + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_set/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_set/4"] : undefined); + const target = program.labels["flags_set/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["flags_set/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -4039,25 +4620,22 @@ function lowered_scan_leading_globals_4(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 209)); Runtime.put_reg(state, 4, Runtime.get_reg(state, 212)); - { + if (typeof lowered_scan_leading_globals_4 === "function") { + if (lowered_scan_leading_globals_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["scan_leading_globals/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["scan_leading_globals/4"] : undefined); + const target = program.labels["scan_leading_globals/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["scan_leading_globals/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("scan_leading_globals", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("scan_leading_globals", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -4065,31 +4643,27 @@ function lowered_scan_leading_globals_4(program, state) { if (!_ok) return false; } } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.restore_lite(state, _ite_lite); Runtime.put_reg(state, 1, Runtime.get_reg(state, 213)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 201)); Runtime.put_reg(state, 3, V.Atom(0)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } - { + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_set/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_set/4"] : undefined); + const target = program.labels["flags_set/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["flags_set/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -4100,25 +4674,22 @@ function lowered_scan_leading_globals_4(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 209)); Runtime.put_reg(state, 4, Runtime.get_reg(state, 212)); - { + if (typeof lowered_scan_leading_globals_4 === "function") { + if (lowered_scan_leading_globals_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["scan_leading_globals/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["scan_leading_globals/4"] : undefined); + const target = program.labels["scan_leading_globals/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["scan_leading_globals/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("scan_leading_globals", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("scan_leading_globals", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -4159,22 +4730,13 @@ function lowered_scan_leading_globals_4(program, state) { return true; return false; })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; return false; } -lowered_dispatch["scan_leading_globals/4"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("scan_leading_globals/4"); return lowered_scan_leading_globals_4(program, state); }; +lowered_dispatch["scan_leading_globals/4"] = function (program, state) { return lowered_scan_leading_globals_4(program, state); }; // Lowered: registry_entry/3 (if-then-else / negation / once) function lowered_registry_entry_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("registry_entry/3"); if (Runtime.op_allocate(state) !== true) return false; Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); Runtime.put_reg(state, 203, Runtime.get_reg(state, 2)); @@ -4185,73 +4747,562 @@ function lowered_registry_entry_3(program, state) { const _ite_cps = state.cps.length; const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 3, v); } + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_pair_lookup_3 === "function") { + if (lowered_pair_lookup_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["pair_lookup/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("pair_lookup", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + if (typeof lowered_js_object_prototype_key_1 === "function") { + if (lowered_js_object_prototype_key_1(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["js_object_prototype_key/1"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("js_object_prototype_key", 1)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + if (Runtime.op_put_structure(program, state, 6, 2, 2) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Atom(2)) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Atom(2)) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; +} + +lowered_dispatch["registry_entry/3"] = function (program, state) { return lowered_registry_entry_3(program, state); }; +// Lowered: parse_strict/4 (if-then-else / negation / once) +function lowered_parse_strict_4(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("parse_strict/4"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 112, Runtime.get_reg(state, 1)); + if (Runtime.op_get_structure(program, state, 6, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 113) !== true) return false; + if (Runtime.op_unify_variable(state, 204) !== true) return false; + Runtime.put_reg(state, 208, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 207, Runtime.get_reg(state, 4)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 112)); + Runtime.put_reg(state, 2, V.Atom(7)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 113)); + Runtime.put_reg(state, 4, V.Atom(2)); + Runtime.put_reg(state, 5, V.Atom(2)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 6, v); } + { const v = Runtime.new_var(state); Runtime.put_reg(state, 211, v); Runtime.put_reg(state, 7, v); } + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 8, v); } + if (typeof lowered_strict_loop_8 === "function") { + if (lowered_strict_loop_8(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["strict_loop/8"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + if (Runtime.op_get_level(state, 212) !== true) return false; + { + const _ite_lite = Runtime.snapshot_lite(state); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (Runtime.op_put_structure(program, state, 8, 2, 1) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 207)); + if (Runtime.op_put_structure(program, state, 8, 2, 1) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_lite(state, _ite_lite); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 209, v); Runtime.put_reg(state, 2, v); } + if (Runtime.op_builtin(program, state, "reverse/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 209)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_check_arity_3 === "function") { + if (lowered_check_arity_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["check_arity/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("check_arity", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + if (Runtime.op_get_level(state, 213) !== true) return false; + { + const _ite_lite = Runtime.snapshot_lite(state); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + if (Runtime.op_put_structure(program, state, 8, 2, 1) !== true) return false; + if (Runtime.op_unify_variable(state, 206) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 207)); + if (Runtime.op_put_structure(program, state, 8, 2, 1) !== true) return false; + if (Runtime.op_unify_value(program, state, 206) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_lite(state, _ite_lite); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 209)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 210, v); Runtime.put_reg(state, 3, v); } + if (Runtime.op_builtin(program, state, "append/3", 3) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 207)); + if (Runtime.op_put_structure(program, state, 9, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 210) !== true) return false; + if (Runtime.op_unify_value(program, state, 211) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; +} + +lowered_dispatch["parse_strict/4"] = function (program, state) { return lowered_parse_strict_4(program, state); }; +// Lowered: parse_lenient/3 (deterministic) +function lowered_parse_lenient_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("parse_lenient/3"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 103, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 104, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 103)); + Runtime.put_reg(state, 2, V.Atom(2)); + Runtime.put_reg(state, 3, V.Atom(2)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 4, v); } + Runtime.put_reg(state, 5, Runtime.get_reg(state, 104)); + if (typeof lowered_lenient_loop_5 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_lenient_loop_5); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["lenient_loop/5"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_builtin(program, state, "reverse/2", 2) !== true) return false; + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; +} + +lowered_dispatch["parse_lenient/3"] = function (program, state) { return lowered_parse_lenient_3(program, state); }; +// Lowered: parse_args/3 (if-then-else / negation / once) +function lowered_parse_args_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("parse_args/3"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 220, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 206, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 221, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 220)); + Runtime.put_reg(state, 2, V.Atom(2)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 3, v); } + { const v = Runtime.new_var(state); Runtime.put_reg(state, 217, v); Runtime.put_reg(state, 4, v); } + if (typeof lowered_scan_leading_globals_4 === "function") { + if (lowered_scan_leading_globals_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["scan_leading_globals/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("scan_leading_globals", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + if (Runtime.op_get_level(state, 222) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 204) !== true) return false; + if (Runtime.op_unify_variable(state, 210) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + if (Runtime.op_get_level(state, 223) !== true) return false; { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["pair_lookup/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["pair_lookup/3"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["pair_lookup/3"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, V.String("--")); + if (typeof lowered_starts_with_2 === "function") { + if (lowered_starts_with_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["starts_with/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; state.halt = false; - } else if (Runtime.step(program, state, I.Call("pair_lookup", 3)) !== true) { - _ok = false; + if (!_ok) return false; } + return true; + })(); + if (_ite_cond) { + if (Runtime.op_builtin(program, state, "fail/0", 0) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; } return true; })(); if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + if (Runtime.op_get_level(state, 224) !== true) return false; + { + const _ite_lite = Runtime.snapshot_lite(state); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 210)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_lite(state, _ite_lite); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 1, v); } + Runtime.put_reg(state, 2, V.Atom(20)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + if (Runtime.op_get_level(state, 225) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 206)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 4, v); } + { const v = Runtime.new_var(state); Runtime.put_reg(state, 208, v); Runtime.put_reg(state, 5, v); } + if (typeof lowered_schema_for_5 === "function") { + if (lowered_schema_for_5(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["schema_for/5"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("schema_for", 5)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + if (Runtime.op_get_level(state, 226) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); + Runtime.put_reg(state, 2, V.Atom(0)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; + if (Runtime.op_unify_variable(state, 209) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 210)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 211) !== true) return false; + if (Runtime.op_unify_variable(state, 212) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + { const v = Runtime.new_var(state); Runtime.put_reg(state, 213, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_list(program, state, 2, 5) !== true) return false; + if (Runtime.op_unify_value(program, state, 204) !== true) return false; + if (Runtime.op_unify_variable(state, 128) !== true) return false; + if (Runtime.op_put_structure(program, state, 5, 128, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 209) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Atom(2)) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 212, v); Runtime.put_reg(state, 1, v); } + Runtime.put_reg(state, 2, Runtime.get_reg(state, 210)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + { const v = Runtime.new_var(state); Runtime.put_reg(state, 213, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_list(program, state, 2, 5) !== true) return false; + if (Runtime.op_unify_value(program, state, 204) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Atom(2)) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 212)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 213)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 214, v); Runtime.put_reg(state, 4, v); } + if (typeof lowered_parse_strict_4 === "function") { + if (lowered_parse_strict_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["parse_strict/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("parse_strict", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + if (Runtime.op_get_level(state, 227) !== true) return false; + { + const _ite_lite = Runtime.snapshot_lite(state); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 214)); + if (Runtime.op_put_structure(program, state, 9, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 215) !== true) return false; + if (Runtime.op_unify_variable(state, 216) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 217)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 216)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 218, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_merge_flags_3 === "function") { + if (lowered_merge_flags_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["merge_flags/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("merge_flags", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 221)); + if (Runtime.op_put_structure(program, state, 9, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 215) !== true) return false; + if (Runtime.op_unify_value(program, state, 218) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_lite(state, _ite_lite); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 214)); + if (Runtime.op_put_structure(program, state, 8, 2, 1) !== true) return false; + if (Runtime.op_unify_variable(state, 219) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 221)); + if (Runtime.op_put_structure(program, state, 22, 2, 1) !== true) return false; + if (Runtime.op_unify_value(program, state, 219) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 220)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 221)); + if (typeof lowered_lenient_result_2 === "function") { + if (lowered_lenient_result_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["lenient_result/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("lenient_result", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } + } } else { Runtime.restore_machine(state, _ite_snap); while (state.cps.length > _ite_cps) state.cps.pop(); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); - { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 220)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 221)); + if (typeof lowered_lenient_result_2 === "function") { + if (lowered_lenient_result_2(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["js_object_prototype_key/1"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["js_object_prototype_key/1"] : undefined); + const target = program.labels["lenient_result/2"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["js_object_prototype_key/1"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("js_object_prototype_key", 1)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("lenient_result", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; state.halt = false; if (!_ok) return false; } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); - if (Runtime.op_put_structure(program, state, 6, 2, 2) !== true) return false; - if (Runtime.op_unify_constant(program, state, V.Atom(2)) !== true) return false; - if (Runtime.op_unify_constant(program, state, V.Atom(2)) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; } } if (Runtime.op_deallocate(state) !== true) return false; @@ -4259,253 +5310,210 @@ function lowered_registry_entry_3(program, state) { return true; } -lowered_dispatch["registry_entry/3"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("registry_entry/3"); return lowered_registry_entry_3(program, state); }; -// Lowered: parse_strict/4 (if-then-else / negation / once) -function lowered_parse_strict_4(program, state) { +lowered_dispatch["parse_args/3"] = function (program, state) { return lowered_parse_args_3(program, state); }; +// Lowered: parse_args/2 (deterministic) +function lowered_parse_args_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("parse_args/2"); if (Runtime.op_allocate(state) !== true) return false; - Runtime.put_reg(state, 112, Runtime.get_reg(state, 1)); - if (Runtime.op_get_structure(program, state, 6, 2, 2) !== true) return false; - if (Runtime.op_unify_variable(state, 113) !== true) return false; - if (Runtime.op_unify_variable(state, 204) !== true) return false; - Runtime.put_reg(state, 208, Runtime.get_reg(state, 3)); - Runtime.put_reg(state, 207, Runtime.get_reg(state, 4)); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 112)); - Runtime.put_reg(state, 2, V.Atom(7)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 113)); - Runtime.put_reg(state, 4, V.Atom(2)); - Runtime.put_reg(state, 5, V.Atom(2)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 6, v); } - { const v = Runtime.new_var(state); Runtime.put_reg(state, 211, v); Runtime.put_reg(state, 7, v); } - { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 8, v); } - { + Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 203, Runtime.get_reg(state, 2)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 1, v); } + if (typeof lowered_default_registry_1 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_default_registry_1); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["strict_loop/8"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["strict_loop/8"] : undefined); + const target = program.labels["default_registry/1"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["strict_loop/8"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("strict_loop", 8)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("default_registry", 1)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; state.halt = false; if (!_ok) return false; } - if (Runtime.op_get_level(state, 212) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_parse_args_3 === "function") return lowered_parse_args_3(program, state) === true; { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; + const target = program.labels["parse_args/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "parse_args", 3) === true; + } + return true; +} + +lowered_dispatch["parse_args/2"] = function (program, state) { return lowered_parse_args_2(program, state); }; +// Lowered: pair_lookup/3 (if-then-else / negation / once) +function lowered_pair_lookup_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("pair_lookup/3"); + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_get_structure(program, state, 11, 106, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + Runtime.put_reg(state, 204, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 3)); + if (Runtime.op_get_level(state, 206) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - if (Runtime.op_put_structure(program, state, 8, 2, 1) !== true) return false; - if (Runtime.op_unify_variable(state, 202) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; return true; })(); if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 207)); - if (Runtime.op_put_structure(program, state, 8, 2, 1) !== true) return false; - if (Runtime.op_unify_value(program, state, 202) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 209, v); Runtime.put_reg(state, 2, v); } - if (Runtime.op_builtin(program, state, "reverse/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 209)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 3, v); } - { + Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); + if (typeof lowered_pair_lookup_3 === "function") { + if (lowered_pair_lookup_3(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["check_arity/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["check_arity/3"] : undefined); + const target = program.labels["pair_lookup/3"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["check_arity/3"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("check_arity", 3)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("pair_lookup", 3)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; state.halt = false; if (!_ok) return false; } - if (Runtime.op_get_level(state, 213) !== true) return false; - { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); - if (Runtime.op_put_structure(program, state, 8, 2, 1) !== true) return false; - if (Runtime.op_unify_variable(state, 206) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - return true; - })(); - if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 207)); - if (Runtime.op_put_structure(program, state, 8, 2, 1) !== true) return false; - if (Runtime.op_unify_value(program, state, 206) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 209)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 210, v); Runtime.put_reg(state, 3, v); } - if (Runtime.op_builtin(program, state, "append/3", 3) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 207)); - if (Runtime.op_put_structure(program, state, 9, 2, 2) !== true) return false; - if (Runtime.op_unify_value(program, state, 210) !== true) return false; - if (Runtime.op_unify_value(program, state, 211) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } - } - } - } - if (Runtime.op_deallocate(state) !== true) return false; - return true; - return true; -} - -lowered_dispatch["parse_strict/4"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("parse_strict/4"); return lowered_parse_strict_4(program, state); }; -// Lowered: parse_lenient/3 (deterministic) -function lowered_parse_lenient_3(program, state) { - if (Runtime.op_allocate(state) !== true) return false; - Runtime.put_reg(state, 103, Runtime.get_reg(state, 1)); - Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 104, Runtime.get_reg(state, 3)); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 103)); - Runtime.put_reg(state, 2, V.Atom(2)); - Runtime.put_reg(state, 3, V.Atom(2)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 4, v); } - Runtime.put_reg(state, 5, Runtime.get_reg(state, 104)); - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["lenient_loop/5"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["lenient_loop/5"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["lenient_loop/5"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { - _ok = false; - } } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); - if (Runtime.op_builtin(program, state, "reverse/2", 2) !== true) return false; if (Runtime.op_deallocate(state) !== true) return false; return true; return true; } -lowered_dispatch["parse_lenient/3"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("parse_lenient/3"); return lowered_parse_lenient_3(program, state); }; -// Lowered: parse_args/3 (if-then-else / negation / once) -function lowered_parse_args_3(program, state) { +lowered_dispatch["pair_lookup/3"] = function (program, state) { return lowered_pair_lookup_3(program, state); }; +// Lowered: option_kind/3 (if-then-else / negation / once) +function lowered_option_kind_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("option_kind/3"); if (Runtime.op_allocate(state) !== true) return false; - Runtime.put_reg(state, 220, Runtime.get_reg(state, 1)); - Runtime.put_reg(state, 206, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 221, Runtime.get_reg(state, 3)); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 220)); - Runtime.put_reg(state, 2, V.Atom(2)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 3, v); } - { const v = Runtime.new_var(state); Runtime.put_reg(state, 217, v); Runtime.put_reg(state, 4, v); } - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["scan_leading_globals/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["scan_leading_globals/4"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["scan_leading_globals/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("scan_leading_globals", 4)) !== true) { - _ok = false; - } - } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - if (Runtime.op_get_level(state, 222) !== true) return false; + Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 204, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 206, Runtime.get_reg(state, 3)); + if (Runtime.op_get_level(state, 207) !== true) return false; { const _ite_snap = Runtime.snapshot_machine(state); const _ite_cps = state.cps.length; const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; - if (Runtime.op_unify_variable(state, 204) !== true) return false; - if (Runtime.op_unify_variable(state, 210) !== true) return false; + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_pair_lookup_3 === "function") { + if (lowered_pair_lookup_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["pair_lookup/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("pair_lookup", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - if (Runtime.op_get_level(state, 223) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + if (Runtime.op_get_level(state, 208) !== true) return false; { const _ite_snap = Runtime.snapshot_machine(state); const _ite_cps = state.cps.length; const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); - Runtime.put_reg(state, 2, V.String("--")); - { + { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 1, v); } + if (typeof lowered_global_options_1 === "function") { + if (lowered_global_options_1(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["starts_with/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["starts_with/2"] : undefined); + const target = program.labels["global_options/1"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["starts_with/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("global_options", 1)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_pair_lookup_3 === "function") { + if (lowered_pair_lookup_3(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["pair_lookup/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("pair_lookup", 3)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -4515,60 +5523,167 @@ function lowered_parse_args_3(program, state) { return true; })(); if (_ite_cond) { - if (Runtime.op_builtin(program, state, "fail/0", 0) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; } else { Runtime.restore_machine(state, _ite_snap); while (state.cps.length > _ite_cps) state.cps.pop(); - if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + if (typeof lowered_js_object_prototype_key_1 === "function") { + if (lowered_js_object_prototype_key_1(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["js_object_prototype_key/1"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("js_object_prototype_key", 1)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, V.Atom(21)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; } } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; +} + +lowered_dispatch["option_kind/3"] = function (program, state) { return lowered_option_kind_3(program, state); }; +// Lowered: nth0_default/4 (if-then-else / negation / once) +function lowered_nth0_default_4(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("nth0_default/4"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 202, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 201, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 207, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 206, Runtime.get_reg(state, 4)); + if (Runtime.op_get_level(state, 208) !== true) return false; + { + const _ite_lite = Runtime.snapshot_lite(state); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_unify_variable(state, 205) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; return true; })(); if (_ite_cond) { - if (Runtime.op_get_level(state, 224) !== true) return false; + if (Runtime.op_get_level(state, 209) !== true) return false; { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 210)); - if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; - if (Runtime.op_unify_variable(state, 202) !== true) return false; - if (Runtime.op_unify_variable(state, 203) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, V.Int(0)); + if (Runtime.op_builtin(program, state, "=:=/2", 2) !== true) return false; return true; })(); if (_ite_cond) { - { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 1, v); } - if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; - if (Runtime.op_unify_value(program, state, 202) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 1, v); } - Runtime.put_reg(state, 2, V.Atom(20)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } - } - if (Runtime.op_get_level(state, 225) !== true) return false; - { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; - const _ite_cond = (function () { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_structure(program, state, 10, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Int(-1)) !== true) return false; + if (Runtime.op_builtin(program, state, "is/2", 2) !== true) return false; Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 206)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 207, v); Runtime.put_reg(state, 4, v); } - { const v = Runtime.new_var(state); Runtime.put_reg(state, 208, v); Runtime.put_reg(state, 5, v); } - { + Runtime.put_reg(state, 3, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 206)); + if (typeof lowered_nth0_default_4 === "function") { + if (lowered_nth0_default_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["schema_for/5"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["schema_for/5"] : undefined); + const target = program.labels["nth0_default/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("nth0_default", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } + } + } else { + Runtime.restore_lite(state, _ite_lite); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; +} + +lowered_dispatch["nth0_default/4"] = function (program, state) { return lowered_nth0_default_4(program, state); }; +// Lowered: next_value/2 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_next_value_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("next_value/2"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + if (Runtime.op_get_constant(program, state, 2, V.Atom(20)) !== true) return false; + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); + if (Runtime.op_get_level(state, 203) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, V.String("--")); + if (Runtime.op_builtin(program, state, "\\==/2", 2) !== true) return false; + if (Runtime.op_get_level(state, 204) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (typeof lowered_is_long_flag_1 === "function") { + if (lowered_is_long_flag_1(program, state) !== true) return false; } else { - const target = program.labels["schema_for/5"]; + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["is_long_flag/1"]; + let _ok = true; if (target !== undefined && target !== null) { Runtime.push_y_save(state); state.cp = 0; @@ -4576,72 +5691,96 @@ function lowered_parse_args_3(program, state) { state.program = program; _ok = Runtime.run_isolated(program, state) === true; state.halt = false; - } else if (Runtime.step(program, state, I.Call("schema_for", 5)) !== true) { + } else if (Runtime.step(program, state, I.Call("is_long_flag", 1)) !== true) { _ok = false; } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - return true; - })(); - if (_ite_cond) { - if (Runtime.op_get_level(state, 226) !== true) return false; - { - const _ite_trail = state.trail.length; - const _ite_args = Runtime.capture_a_regs(state, 8); - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); - Runtime.put_reg(state, 2, V.Atom(0)); - if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; - return true; - })(); - if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); - if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; - if (Runtime.op_unify_variable(state, 209) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 210)); - if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; - if (Runtime.op_unify_variable(state, 211) !== true) return false; - if (Runtime.op_unify_variable(state, 212) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - { const v = Runtime.new_var(state); Runtime.put_reg(state, 213, v); Runtime.put_reg(state, 1, v); } - if (Runtime.op_put_list(program, state, 2, 5) !== true) return false; - if (Runtime.op_unify_value(program, state, 204) !== true) return false; - if (Runtime.op_unify_variable(state, 128) !== true) return false; - if (Runtime.op_put_structure(program, state, 5, 128, 2) !== true) return false; - if (Runtime.op_unify_value(program, state, 209) !== true) return false; - if (Runtime.op_unify_constant(program, state, V.Atom(2)) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } else { - Runtime.undo_trail(state, _ite_trail); - Runtime.restore_a_regs(state, _ite_args); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 212, v); Runtime.put_reg(state, 1, v); } - Runtime.put_reg(state, 2, Runtime.get_reg(state, 210)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - { const v = Runtime.new_var(state); Runtime.put_reg(state, 213, v); Runtime.put_reg(state, 1, v); } - if (Runtime.op_put_list(program, state, 2, 5) !== true) return false; - if (Runtime.op_unify_value(program, state, 204) !== true) return false; - if (Runtime.op_unify_constant(program, state, V.Atom(2)) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } + return true; + })(); + if (_ite_cond) { + if (Runtime.op_builtin(program, state, "fail/0", 0) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 212)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 213)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 214, v); Runtime.put_reg(state, 4, v); } - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["parse_strict/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["parse_strict/4"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; + if (Runtime.op_unify_value(program, state, 201) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, V.Atom(20)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; + } + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; + if (Runtime.op_get_constant(program, state, 2, V.Atom(20)) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); + if (Runtime.op_get_level(state, 203) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, V.String("--")); + if (Runtime.op_builtin(program, state, "\\==/2", 2) !== true) return false; + if (Runtime.op_get_level(state, 204) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (typeof lowered_is_long_flag_1 === "function") { + if (lowered_is_long_flag_1(program, state) !== true) return false; } else { - const target = program.labels["parse_strict/4"]; + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["is_long_flag/1"]; + let _ok = true; if (target !== undefined && target !== null) { Runtime.push_y_save(state); state.cp = 0; @@ -4649,120 +5788,327 @@ function lowered_parse_args_3(program, state) { state.program = program; _ok = Runtime.run_isolated(program, state) === true; state.halt = false; - } else if (Runtime.step(program, state, I.Call("parse_strict", 4)) !== true) { + } else if (Runtime.step(program, state, I.Call("is_long_flag", 1)) !== true) { _ok = false; } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - if (Runtime.op_get_level(state, 227) !== true) return false; - { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 214)); - if (Runtime.op_put_structure(program, state, 9, 2, 2) !== true) return false; - if (Runtime.op_unify_variable(state, 215) !== true) return false; - if (Runtime.op_unify_variable(state, 216) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - return true; - })(); - if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 217)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 216)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 218, v); Runtime.put_reg(state, 3, v); } - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["merge_flags/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["merge_flags/3"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["merge_flags/3"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("merge_flags", 3)) !== true) { - _ok = false; - } - } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 221)); - if (Runtime.op_put_structure(program, state, 9, 2, 2) !== true) return false; - if (Runtime.op_unify_value(program, state, 215) !== true) return false; - if (Runtime.op_unify_value(program, state, 218) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 214)); - if (Runtime.op_put_structure(program, state, 8, 2, 1) !== true) return false; - if (Runtime.op_unify_variable(state, 219) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 221)); - if (Runtime.op_put_structure(program, state, 22, 2, 1) !== true) return false; - if (Runtime.op_unify_value(program, state, 219) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } + return true; + })(); + if (_ite_cond) { + if (Runtime.op_builtin(program, state, "fail/0", 0) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; } + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; + if (Runtime.op_unify_value(program, state, 201) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, V.Atom(20)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return false; + })()) return true; + return false; +} + +lowered_dispatch["next_value/2"] = function (program, state) { return lowered_next_value_2(program, state); }; +// Lowered: merge_flags_/3 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_merge_flags__3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("merge_flags_/3"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + if (Runtime.op_get_value(program, state, 101, 3) !== true) return false; + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_get_structure(program, state, 11, 104, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + Runtime.put_reg(state, 107, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 203, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 107)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 105)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 106)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 4, v); } + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["flags_set/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_merge_flags__3 === "function") return lowered_merge_flags__3(program, state) === true; + { + const target = program.labels["merge_flags_/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "merge_flags_", 3) === true; + } + return true; + } + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + if (Runtime.op_get_value(program, state, 101, 3) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 104) !== true) return false; + if (Runtime.op_get_structure(program, state, 11, 104, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 105) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + Runtime.put_reg(state, 107, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 203, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 107)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 105)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 106)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 4, v); } + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["flags_set/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_merge_flags__3 === "function") return lowered_merge_flags__3(program, state) === true; + { + const target = program.labels["merge_flags_/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "merge_flags_", 3) === true; + } + return false; + })()) return true; + return false; +} + +lowered_dispatch["merge_flags_/3"] = function (program, state) { return lowered_merge_flags__3(program, state); }; +// Lowered: merge_flags/3 (deterministic) +function lowered_merge_flags_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("merge_flags/3"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 103, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 102)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 101)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 103)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_merge_flags__3 === "function") return lowered_merge_flags__3(program, state) === true; + { + const target = program.labels["merge_flags_/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "merge_flags_", 3) === true; + } + return true; +} + +lowered_dispatch["merge_flags/3"] = function (program, state) { return lowered_merge_flags_3(program, state); }; +// Lowered: looks_like_legacy_flag/1 (deterministic) +function lowered_looks_like_legacy_flag_1(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("looks_like_legacy_flag/1"); + if (Runtime.op_allocate(state) !== true) return false; + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } + if (Runtime.op_builtin(program, state, "string_chars/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Atom(11)) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_put_structure(program, state, 5, 106, 2) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Atom(11)) !== true) return false; + if (Runtime.op_unify_variable(state, 107) !== true) return false; + if (Runtime.op_put_structure(program, state, 5, 107, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + if (typeof lowered_js_alpha_1 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_js_alpha_1); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["js_alpha/1"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("js_alpha", 1)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_legacy_flag_tail_1 === "function") return lowered_legacy_flag_tail_1(program, state) === true; + { + const target = program.labels["legacy_flag_tail/1"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "legacy_flag_tail", 1) === true; + } + return true; +} + +lowered_dispatch["looks_like_legacy_flag/1"] = function (program, state) { return lowered_looks_like_legacy_flag_1(program, state); }; +// Lowered: long_flag_tail/1 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_long_flag_tail_1(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("long_flag_tail/1"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_get_level(state, 203) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, V.Atom(18)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (typeof lowered_js_flag_char_1 === "function") { + if (lowered_js_flag_char_1(program, state) !== true) return false; } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 220)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 221)); - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["lenient_result/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["lenient_result/2"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["lenient_result/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("lenient_result", 2)) !== true) { - _ok = false; - } - } - state.cp = saved_cp; - state.pc = saved_pc; + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["js_flag_char/1"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; state.halt = false; - if (!_ok) return false; + } else if (Runtime.step(program, state, I.Call("js_flag_char", 1)) !== true) { + _ok = false; } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; } - } - } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 220)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 221)); - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["lenient_result/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["lenient_result/2"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + if (typeof lowered_long_flag_tail_1 === "function") { + if (lowered_long_flag_tail_1(program, state) !== true) return false; } else { - const target = program.labels["lenient_result/2"]; + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["long_flag_tail/1"]; + let _ok = true; if (target !== undefined && target !== null) { Runtime.push_y_save(state); state.cp = 0; @@ -4770,64 +6116,96 @@ function lowered_parse_args_3(program, state) { state.program = program; _ok = Runtime.run_isolated(program, state) === true; state.halt = false; - } else if (Runtime.step(program, state, I.Call("lenient_result", 2)) !== true) { + } else if (Runtime.step(program, state, I.Call("long_flag_tail", 1)) !== true) { _ok = false; } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; } } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; } - if (Runtime.op_deallocate(state) !== true) return false; - return true; - return true; -} - -lowered_dispatch["parse_args/3"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("parse_args/3"); return lowered_parse_args_3(program, state); }; -// wamjs lower fallback: parse_args/2 fallback(execute of a non-self callee (nested Runtime.run would steal CP)) -// Lowered: pair_lookup/3 (if-then-else / negation / once) -function lowered_pair_lookup_3(program, state) { - if (Runtime.op_allocate(state) !== true) return false; - if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; - if (Runtime.op_unify_variable(state, 106) !== true) return false; - if (Runtime.op_get_structure(program, state, 11, 106, 2) !== true) return false; - if (Runtime.op_unify_variable(state, 201) !== true) return false; - if (Runtime.op_unify_variable(state, 202) !== true) return false; - if (Runtime.op_unify_variable(state, 203) !== true) return false; - Runtime.put_reg(state, 204, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 205, Runtime.get_reg(state, 3)); - if (Runtime.op_get_level(state, 206) !== true) return false; - { - const _ite_trail = state.trail.length; - const _ite_args = Runtime.capture_a_regs(state, 8); - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); - if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; - return true; - })(); - if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } else { - Runtime.undo_trail(state, _ite_trail); - Runtime.restore_a_regs(state, _ite_args); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["pair_lookup/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["pair_lookup/3"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_get_level(state, 203) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, V.Atom(18)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (typeof lowered_js_flag_char_1 === "function") { + if (lowered_js_flag_char_1(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["js_flag_char/1"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("js_flag_char", 1)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + if (typeof lowered_long_flag_tail_1 === "function") { + if (lowered_long_flag_tail_1(program, state) !== true) return false; } else { - const target = program.labels["pair_lookup/3"]; + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["long_flag_tail/1"]; + let _ok = true; if (target !== undefined && target !== null) { Runtime.push_y_save(state); state.cp = 0; @@ -4835,46 +6213,83 @@ function lowered_pair_lookup_3(program, state) { state.program = program; _ok = Runtime.run_isolated(program, state) === true; state.halt = false; - } else if (Runtime.step(program, state, I.Call("pair_lookup", 3)) !== true) { + } else if (Runtime.step(program, state, I.Call("long_flag_tail", 1)) !== true) { _ok = false; } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; } } - } - if (Runtime.op_deallocate(state) !== true) return false; - return true; - return true; + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return false; + })()) return true; + return false; } -lowered_dispatch["pair_lookup/3"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("pair_lookup/3"); return lowered_pair_lookup_3(program, state); }; -// Lowered: option_kind/3 (if-then-else / negation / once) -function lowered_option_kind_3(program, state) { +lowered_dispatch["long_flag_tail/1"] = function (program, state) { return lowered_long_flag_tail_1(program, state); }; +// Lowered: lenient_result/2 (deterministic) +function lowered_lenient_result_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("lenient_result/2"); if (Runtime.op_allocate(state) !== true) return false; - Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); - Runtime.put_reg(state, 204, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 206, Runtime.get_reg(state, 3)); - if (Runtime.op_get_level(state, 207) !== true) return false; + Runtime.put_reg(state, 101, Runtime.get_reg(state, 1)); + if (Runtime.op_get_structure(program, state, 9, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 101)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 102)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 103)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_parse_lenient_3 === "function") return lowered_parse_lenient_3(program, state) === true; { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 3, v); } - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["pair_lookup/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["pair_lookup/3"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; + const target = program.labels["parse_lenient/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "parse_lenient", 3) === true; + } + return true; +} + +lowered_dispatch["lenient_result/2"] = function (program, state) { return lowered_lenient_result_2(program, state); }; +// Lowered: lenient_loop/5 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_lenient_loop_5(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("lenient_loop/5"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); + if (Runtime.op_get_value(program, state, 101, 4) !== true) return false; + if (Runtime.op_get_value(program, state, 102, 5) !== true) return false; + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 208) !== true) return false; + if (Runtime.op_unify_variable(state, 207) !== true) return false; + Runtime.put_reg(state, 209, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 210, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 211, Runtime.get_reg(state, 4)); + Runtime.put_reg(state, 212, Runtime.get_reg(state, 5)); + if (Runtime.op_get_level(state, 213) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); + Runtime.put_reg(state, 2, V.String("--")); + if (typeof lowered_starts_with_2 === "function") { + if (lowered_starts_with_2(program, state) !== true) return false; } else { - const target = program.labels["pair_lookup/3"]; + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["starts_with/2"]; + let _ok = true; if (target !== undefined && target !== null) { Runtime.push_y_save(state); state.cp = 0; @@ -4882,186 +6297,64 @@ function lowered_option_kind_3(program, state) { state.program = program; _ok = Runtime.run_isolated(program, state) === true; state.halt = false; - } else if (Runtime.step(program, state, I.Call("pair_lookup", 3)) !== true) { + } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { _ok = false; } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - return true; - })(); - if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); - if (Runtime.op_get_level(state, 208) !== true) return false; - { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; - const _ite_cond = (function () { - { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 1, v); } - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["global_options/1"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["global_options/1"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["global_options/1"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("global_options", 1)) !== true) { - _ok = false; - } - } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 3, v); } - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["pair_lookup/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["pair_lookup/3"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["pair_lookup/3"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("pair_lookup", 3)) !== true) { - _ok = false; - } - } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - return true; - })(); - if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["js_object_prototype_key/1"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["js_object_prototype_key/1"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["js_object_prototype_key/1"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("js_object_prototype_key", 1)) !== true) { - _ok = false; - } - } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); - Runtime.put_reg(state, 2, V.Atom(21)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } - } - } - } - if (Runtime.op_deallocate(state) !== true) return false; - return true; - return true; -} - -lowered_dispatch["option_kind/3"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("option_kind/3"); return lowered_option_kind_3(program, state); }; -// Lowered: nth0_default/4 (if-then-else / negation / once) -function lowered_nth0_default_4(program, state) { - if (Runtime.op_allocate(state) !== true) return false; - Runtime.put_reg(state, 202, Runtime.get_reg(state, 1)); - Runtime.put_reg(state, 201, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 207, Runtime.get_reg(state, 3)); - Runtime.put_reg(state, 206, Runtime.get_reg(state, 4)); - if (Runtime.op_get_level(state, 208) !== true) return false; - { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; - if (Runtime.op_unify_variable(state, 203) !== true) return false; - if (Runtime.op_unify_variable(state, 205) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - return true; - })(); - if (_ite_cond) { - if (Runtime.op_get_level(state, 209) !== true) return false; - { - const _ite_trail = state.trail.length; - const _ite_args = Runtime.capture_a_regs(state, 8); - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); - Runtime.put_reg(state, 2, V.Int(0)); - if (Runtime.op_builtin(program, state, "=:=/2", 2) !== true) return false; - return true; - })(); - if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 2, v); } + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 3, v); } + if (typeof lowered_split_flag_token_3 === "function") { + if (lowered_split_flag_token_3(program, state) !== true) return false; } else { - Runtime.undo_trail(state, _ite_trail); - Runtime.restore_a_regs(state, _ite_args); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 1, v); } - if (Runtime.op_put_structure(program, state, 10, 2, 2) !== true) return false; - if (Runtime.op_unify_value(program, state, 202) !== true) return false; - if (Runtime.op_unify_constant(program, state, V.Int(-1)) !== true) return false; - if (Runtime.op_builtin(program, state, "is/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 207)); - Runtime.put_reg(state, 4, Runtime.get_reg(state, 206)); - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["nth0_default/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["nth0_default/4"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["split_flag_token/3"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("split_flag_token", 3)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + if (Runtime.op_get_level(state, 214) !== true) return false; + { + const _ite_lite = Runtime.snapshot_lite(state); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 210)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 202)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; } else { - const target = program.labels["nth0_default/4"]; + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["flags_set/4"]; + let _ok = true; if (target !== undefined && target !== null) { Runtime.push_y_save(state); state.cp = 0; @@ -5069,373 +6362,245 @@ function lowered_nth0_default_4(program, state) { state.program = program; _ok = Runtime.run_isolated(program, state) === true; state.halt = false; - } else if (Runtime.step(program, state, I.Call("nth0_default", 4)) !== true) { + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { _ok = false; } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - } - } - } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 207)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } - } - if (Runtime.op_deallocate(state) !== true) return false; - return true; - return true; -} - -lowered_dispatch["nth0_default/4"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("nth0_default/4"); return lowered_nth0_default_4(program, state); }; -// Lowered: next_value/2 (T4 all-clauses inline) -function lowered_next_value_2(program, state) { - const _t4_trail = state.trail.length; - const _t4_regs = Runtime.copy_table(state.regs); - const _t4_vc = state.var_counter; - const _t4_stack = state.stack.slice(); - const _t4_ysave = (state.y_save || []).slice(); - const _t4_mode = state.mode; - const _t4_build = state.build_stack.slice(); - const _t4_rstack = (state.read_stack || []).slice(); - const _t4_rargs = state.read_args; - const _t4_rcur = state.read_cursor; - if ((function () { - if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; - if (Runtime.op_get_constant(program, state, 2, V.Atom(20)) !== true) return false; - return true; - return false; - })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; - if ((function () { - if (Runtime.op_allocate(state) !== true) return false; - if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; - if (Runtime.op_unify_variable(state, 201) !== true) return false; - if (Runtime.op_unify_variable(state, 103) !== true) return false; - Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); - if (Runtime.op_get_level(state, 203) !== true) return false; - { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, V.String("--")); - if (Runtime.op_builtin(program, state, "\\==/2", 2) !== true) return false; - if (Runtime.op_get_level(state, 204) !== true) return false; - { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 209)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 211)); + Runtime.put_reg(state, 5, Runtime.get_reg(state, 212)); + if (typeof lowered_lenient_loop_5 === "function") { + if (lowered_lenient_loop_5(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["is_long_flag/1"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["is_long_flag/1"] : undefined); + const target = program.labels["lenient_loop/5"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } else { + Runtime.restore_lite(state, _ite_lite); + if (Runtime.op_get_level(state, 215) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 207)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 205) !== true) return false; + if (Runtime.op_unify_variable(state, 206) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + if (Runtime.op_get_level(state, 216) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); + if (typeof lowered_looks_like_legacy_flag_1 === "function") { + if (lowered_looks_like_legacy_flag_1(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["looks_like_legacy_flag/1"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("looks_like_legacy_flag", 1)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + if (Runtime.op_builtin(program, state, "fail/0", 0) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; + } + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 210)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["flags_set/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 209)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 211)); + Runtime.put_reg(state, 5, Runtime.get_reg(state, 212)); + if (typeof lowered_lenient_loop_5 === "function") { + if (lowered_lenient_loop_5(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["lenient_loop/5"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } } else { - const target = program.labels["is_long_flag/1"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 210)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 3, V.Atom(0)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["flags_set/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 207)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 209)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 211)); + Runtime.put_reg(state, 5, Runtime.get_reg(state, 212)); + if (typeof lowered_lenient_loop_5 === "function") { + if (lowered_lenient_loop_5(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["lenient_loop/5"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; state.halt = false; - } else if (Runtime.step(program, state, I.Call("is_long_flag", 1)) !== true) { - _ok = false; + if (!_ok) return false; } } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; } - return true; - })(); - if (_ite_cond) { - if (Runtime.op_builtin(program, state, "fail/0", 0) !== true) return false; - } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); - if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; } } - return true; - })(); - if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); - if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; - if (Runtime.op_unify_value(program, state, 201) !== true) return false; - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; } else { Runtime.restore_machine(state, _ite_snap); while (state.cps.length > _ite_cps) state.cps.pop(); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); - Runtime.put_reg(state, 2, V.Atom(20)); - if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; - } - } - if (Runtime.op_deallocate(state) !== true) return false; - return true; - return false; - })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; - return false; -} - -lowered_dispatch["next_value/2"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("next_value/2"); return lowered_next_value_2(program, state); }; -// Lowered: merge_flags_/3 (T4 all-clauses inline) -function lowered_merge_flags__3(program, state) { - const _t4_trail = state.trail.length; - const _t4_regs = Runtime.copy_table(state.regs); - const _t4_vc = state.var_counter; - const _t4_stack = state.stack.slice(); - const _t4_ysave = (state.y_save || []).slice(); - const _t4_mode = state.mode; - const _t4_build = state.build_stack.slice(); - const _t4_rstack = (state.read_stack || []).slice(); - const _t4_rargs = state.read_args; - const _t4_rcur = state.read_cursor; - if ((function () { - if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; - Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); - if (Runtime.op_get_value(program, state, 101, 3) !== true) return false; - return true; - return false; - })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; - if ((function () { - if (Runtime.op_allocate(state) !== true) return false; - if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; - if (Runtime.op_unify_variable(state, 104) !== true) return false; - if (Runtime.op_get_structure(program, state, 11, 104, 2) !== true) return false; - if (Runtime.op_unify_variable(state, 105) !== true) return false; - if (Runtime.op_unify_variable(state, 106) !== true) return false; - if (Runtime.op_unify_variable(state, 201) !== true) return false; - Runtime.put_reg(state, 107, Runtime.get_reg(state, 2)); - Runtime.put_reg(state, 203, Runtime.get_reg(state, 3)); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 107)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 105)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 106)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 4, v); } - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_set/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_set/4"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["flags_set/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { - _ok = false; - } - } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); - if (Runtime.op_deallocate(state) !== true) return false; - { - const _lf = (program.lowered_dispatch && program.lowered_dispatch["merge_flags_/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["merge_flags_/3"] : undefined); - if (typeof _lf === "function") return _lf(program, state) === true; - const target = program.labels["merge_flags_/3"]; - if (target !== undefined && target !== null) { - state.pc = target; - state.program = program; - return Runtime.run_isolated(program, state) === true; - } - if (Runtime.step(program, state, I.Execute("merge_flags_", 3)) !== true) return false; - if (state.halt) return true; - state.program = program; - return Runtime.run_isolated(program, state) === true; - } - return false; - })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; - return false; -} - -lowered_dispatch["merge_flags_/3"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("merge_flags_/3"); return lowered_merge_flags__3(program, state); }; -// wamjs lower fallback: merge_flags/3 fallback(execute of a non-self callee (nested Runtime.run would steal CP)) -// wamjs lower fallback: looks_like_legacy_flag/1 fallback(execute of a non-self callee (nested Runtime.run would steal CP)) -// Lowered: long_flag_tail/1 (T4 all-clauses inline) -function lowered_long_flag_tail_1(program, state) { - const _t4_trail = state.trail.length; - const _t4_regs = Runtime.copy_table(state.regs); - const _t4_vc = state.var_counter; - const _t4_stack = state.stack.slice(); - const _t4_ysave = (state.y_save || []).slice(); - const _t4_mode = state.mode; - const _t4_build = state.build_stack.slice(); - const _t4_rstack = (state.read_stack || []).slice(); - const _t4_rargs = state.read_args; - const _t4_rcur = state.read_cursor; - if ((function () { - if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; - return true; - return false; - })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; - if ((function () { - if (Runtime.op_allocate(state) !== true) return false; - if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; - if (Runtime.op_unify_variable(state, 201) !== true) return false; - if (Runtime.op_unify_variable(state, 202) !== true) return false; - if (Runtime.op_get_level(state, 203) !== true) return false; - { - const _ite_trail = state.trail.length; - const _ite_args = Runtime.capture_a_regs(state, 8); - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, V.Atom(18)); - if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; - return true; - })(); - if (_ite_cond) { - if (Runtime.op_builtin(program, state, "true/0", 0) !== true) return false; - } else { - Runtime.undo_trail(state, _ite_trail); - Runtime.restore_a_regs(state, _ite_args); - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["js_flag_char/1"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["js_flag_char/1"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["js_flag_char/1"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("js_flag_char", 1)) !== true) { - _ok = false; - } - } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } - Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); - { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 207)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 208) !== true) return false; + if (Runtime.op_unify_value(program, state, 209) !== true) return false; + Runtime.put_reg(state, 3, Runtime.get_reg(state, 210)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 211)); + Runtime.put_reg(state, 5, Runtime.get_reg(state, 212)); + if (typeof lowered_lenient_loop_5 === "function") { + if (lowered_lenient_loop_5(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["long_flag_tail/1"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["long_flag_tail/1"] : undefined); + const target = program.labels["lenient_loop/5"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["long_flag_tail/1"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("long_flag_tail", 1)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; state.halt = false; if (!_ok) return false; - } - } - } - if (Runtime.op_deallocate(state) !== true) return false; - return true; - return false; - })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; - return false; -} - -lowered_dispatch["long_flag_tail/1"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("long_flag_tail/1"); return lowered_long_flag_tail_1(program, state); }; -// wamjs lower fallback: lenient_result/2 fallback(execute of a non-self callee (nested Runtime.run would steal CP)) -// Lowered: lenient_loop/5 (T4 all-clauses inline) -function lowered_lenient_loop_5(program, state) { + } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; + } const _t4_trail = state.trail.length; const _t4_regs = Runtime.copy_table(state.regs); const _t4_vc = state.var_counter; @@ -5481,25 +6646,22 @@ function lowered_lenient_loop_5(program, state) { const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); Runtime.put_reg(state, 2, V.String("--")); - { + if (typeof lowered_starts_with_2 === "function") { + if (lowered_starts_with_2(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["starts_with/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["starts_with/2"] : undefined); + const target = program.labels["starts_with/2"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["starts_with/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -5512,25 +6674,22 @@ function lowered_lenient_loop_5(program, state) { Runtime.put_reg(state, 1, Runtime.get_reg(state, 208)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 203, v); Runtime.put_reg(state, 2, v); } { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 3, v); } - { + if (typeof lowered_split_flag_token_3 === "function") { + if (lowered_split_flag_token_3(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["split_flag_token/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["split_flag_token/3"] : undefined); + const target = program.labels["split_flag_token/3"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["split_flag_token/3"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("split_flag_token", 3)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("split_flag_token", 3)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -5539,8 +6698,7 @@ function lowered_lenient_loop_5(program, state) { } if (Runtime.op_get_level(state, 214) !== true) return false; { - const _ite_snap = Runtime.snapshot_machine(state); - const _ite_cps = state.cps.length; + const _ite_lite = Runtime.snapshot_lite(state); const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); if (Runtime.op_put_structure(program, state, 19, 2, 1) !== true) return false; @@ -5553,25 +6711,22 @@ function lowered_lenient_loop_5(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 202)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } - { + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_set/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_set/4"] : undefined); + const target = program.labels["flags_set/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["flags_set/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -5583,25 +6738,22 @@ function lowered_lenient_loop_5(program, state) { Runtime.put_reg(state, 3, Runtime.get_reg(state, 204)); Runtime.put_reg(state, 4, Runtime.get_reg(state, 211)); Runtime.put_reg(state, 5, Runtime.get_reg(state, 212)); - { + if (typeof lowered_lenient_loop_5 === "function") { + if (lowered_lenient_loop_5(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["lenient_loop/5"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["lenient_loop/5"] : undefined); + const target = program.labels["lenient_loop/5"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["lenient_loop/5"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -5609,8 +6761,7 @@ function lowered_lenient_loop_5(program, state) { if (!_ok) return false; } } else { - Runtime.restore_machine(state, _ite_snap); - while (state.cps.length > _ite_cps) state.cps.pop(); + Runtime.restore_lite(state, _ite_lite); if (Runtime.op_get_level(state, 215) !== true) return false; { const _ite_snap = Runtime.snapshot_machine(state); @@ -5627,25 +6778,22 @@ function lowered_lenient_loop_5(program, state) { const _ite_cps = state.cps.length; const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 205)); - { + if (typeof lowered_looks_like_legacy_flag_1 === "function") { + if (lowered_looks_like_legacy_flag_1(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["looks_like_legacy_flag/1"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["looks_like_legacy_flag/1"] : undefined); + const target = program.labels["looks_like_legacy_flag/1"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["looks_like_legacy_flag/1"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("looks_like_legacy_flag", 1)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("looks_like_legacy_flag", 1)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -5669,25 +6817,22 @@ function lowered_lenient_loop_5(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } - { + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_set/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_set/4"] : undefined); + const target = program.labels["flags_set/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["flags_set/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -5699,25 +6844,22 @@ function lowered_lenient_loop_5(program, state) { Runtime.put_reg(state, 3, Runtime.get_reg(state, 204)); Runtime.put_reg(state, 4, Runtime.get_reg(state, 211)); Runtime.put_reg(state, 5, Runtime.get_reg(state, 212)); - { + if (typeof lowered_lenient_loop_5 === "function") { + if (lowered_lenient_loop_5(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["lenient_loop/5"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["lenient_loop/5"] : undefined); + const target = program.labels["lenient_loop/5"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["lenient_loop/5"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -5731,25 +6873,22 @@ function lowered_lenient_loop_5(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); Runtime.put_reg(state, 3, V.Atom(0)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } - { + if (typeof lowered_flags_set_4 === "function") { + if (lowered_flags_set_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_set/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_set/4"] : undefined); + const target = program.labels["flags_set/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["flags_set/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_set", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -5761,25 +6900,22 @@ function lowered_lenient_loop_5(program, state) { Runtime.put_reg(state, 3, Runtime.get_reg(state, 204)); Runtime.put_reg(state, 4, Runtime.get_reg(state, 211)); Runtime.put_reg(state, 5, Runtime.get_reg(state, 212)); - { + if (typeof lowered_lenient_loop_5 === "function") { + if (lowered_lenient_loop_5(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["lenient_loop/5"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["lenient_loop/5"] : undefined); + const target = program.labels["lenient_loop/5"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["lenient_loop/5"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -5800,25 +6936,22 @@ function lowered_lenient_loop_5(program, state) { Runtime.put_reg(state, 3, Runtime.get_reg(state, 210)); Runtime.put_reg(state, 4, Runtime.get_reg(state, 211)); Runtime.put_reg(state, 5, Runtime.get_reg(state, 212)); - { + if (typeof lowered_lenient_loop_5 === "function") { + if (lowered_lenient_loop_5(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["lenient_loop/5"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["lenient_loop/5"] : undefined); + const target = program.labels["lenient_loop/5"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["lenient_loop/5"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("lenient_loop", 5)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -5831,22 +6964,58 @@ function lowered_lenient_loop_5(program, state) { return true; return false; })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; return false; } -lowered_dispatch["lenient_loop/5"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("lenient_loop/5"); return lowered_lenient_loop_5(program, state); }; -// Lowered: legacy_flag_tail/1 (T4 all-clauses inline) +lowered_dispatch["lenient_loop/5"] = function (program, state) { return lowered_lenient_loop_5(program, state); }; +// Lowered: legacy_flag_tail/1 (T4 nil/cons dispatch; no snapshot on bound A1) function lowered_legacy_flag_tail_1(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("legacy_flag_tail/1"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 102) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 102)); + if (typeof lowered_js_flag_char_1 === "function") { + if (lowered_js_flag_char_1(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["js_flag_char/1"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("js_flag_char", 1)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_legacy_flag_tail_1 === "function") return lowered_legacy_flag_tail_1(program, state) === true; + { + const target = program.labels["legacy_flag_tail/1"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "legacy_flag_tail", 1) === true; + } + return true; + } const _t4_trail = state.trail.length; const _t4_regs = Runtime.copy_table(state.regs); const _t4_vc = state.var_counter; @@ -5878,25 +7047,22 @@ function lowered_legacy_flag_tail_1(program, state) { if (Runtime.op_unify_variable(state, 102) !== true) return false; if (Runtime.op_unify_variable(state, 201) !== true) return false; Runtime.put_reg(state, 1, Runtime.get_reg(state, 102)); - { + if (typeof lowered_js_flag_char_1 === "function") { + if (lowered_js_flag_char_1(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["js_flag_char/1"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["js_flag_char/1"] : undefined); + const target = program.labels["js_flag_char/1"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["js_flag_char/1"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("js_flag_char", 1)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("js_flag_char", 1)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -5905,38 +7071,23 @@ function lowered_legacy_flag_tail_1(program, state) { } Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_legacy_flag_tail_1 === "function") return lowered_legacy_flag_tail_1(program, state) === true; { - const _lf = (program.lowered_dispatch && program.lowered_dispatch["legacy_flag_tail/1"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["legacy_flag_tail/1"] : undefined); - if (typeof _lf === "function") return _lf(program, state) === true; const target = program.labels["legacy_flag_tail/1"]; if (target !== undefined && target !== null) { - state.pc = target; - state.program = program; - return Runtime.run_isolated(program, state) === true; + return Runtime.execute_user_isolated(program, state, target) === true; } - if (Runtime.step(program, state, I.Execute("legacy_flag_tail", 1)) !== true) return false; - if (state.halt) return true; - state.program = program; - return Runtime.run_isolated(program, state) === true; + return Runtime.op_builtin(program, state, "legacy_flag_tail", 1) === true; } return false; })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; return false; } -lowered_dispatch["legacy_flag_tail/1"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("legacy_flag_tail/1"); return lowered_legacy_flag_tail_1(program, state); }; +lowered_dispatch["legacy_flag_tail/1"] = function (program, state) { return lowered_legacy_flag_tail_1(program, state); }; // Lowered: last_element/2 (if-then-else / negation / once) function lowered_last_element_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("last_element/2"); if (Runtime.op_allocate(state) !== true) return false; if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; if (Runtime.op_unify_variable(state, 201) !== true) return false; @@ -5961,25 +7112,22 @@ function lowered_last_element_2(program, state) { Runtime.restore_a_regs(state, _ite_args); Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); - { + if (typeof lowered_last_element_2 === "function") { + if (lowered_last_element_2(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["last_element/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["last_element/2"] : undefined); + const target = program.labels["last_element/2"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["last_element/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("last_element", 2)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("last_element", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -5993,9 +7141,10 @@ function lowered_last_element_2(program, state) { return true; } -lowered_dispatch["last_element/2"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("last_element/2"); return lowered_last_element_2(program, state); }; +lowered_dispatch["last_element/2"] = function (program, state) { return lowered_last_element_2(program, state); }; // Lowered: js_object_prototype_keys/1 (deterministic ground fact; interned after first success) function lowered_js_object_prototype_keys_1(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("js_object_prototype_keys/1"); const _gk = "js_object_prototype_keys/1"; const _gm = program.ground_memo || (program.ground_memo = Object.create(null)); const _cached = _gm[_gk]; @@ -6057,10 +7206,56 @@ function lowered_js_object_prototype_keys_1(program, state) { return true; } -lowered_dispatch["js_object_prototype_keys/1"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("js_object_prototype_keys/1"); return lowered_js_object_prototype_keys_1(program, state); }; -// wamjs lower fallback: js_object_prototype_key/1 fallback(execute of a non-self callee (nested Runtime.run would steal CP)) +lowered_dispatch["js_object_prototype_keys/1"] = function (program, state) { return lowered_js_object_prototype_keys_1(program, state); }; +// Lowered: js_object_prototype_key/1 (deterministic) +function lowered_js_object_prototype_key_1(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("js_object_prototype_key/1"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 1, v); } + if (typeof lowered_js_object_prototype_keys_1 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_js_object_prototype_keys_1); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["js_object_prototype_keys/1"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("js_object_prototype_keys", 1)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_string_member_2 === "function") return lowered_string_member_2(program, state) === true; + { + const target = program.labels["string_member/2"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "string_member", 2) === true; + } + return true; +} + +lowered_dispatch["js_object_prototype_key/1"] = function (program, state) { return lowered_js_object_prototype_key_1(program, state); }; // Lowered: js_flag_char/1 (if-then-else / negation / once) function lowered_js_flag_char_1(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("js_flag_char/1"); if (Runtime.op_allocate(state) !== true) return false; { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } if (Runtime.op_builtin(program, state, "char_code/2", 2) !== true) return false; @@ -6132,9 +7327,10 @@ function lowered_js_flag_char_1(program, state) { return true; } -lowered_dispatch["js_flag_char/1"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("js_flag_char/1"); return lowered_js_flag_char_1(program, state); }; +lowered_dispatch["js_flag_char/1"] = function (program, state) { return lowered_js_flag_char_1(program, state); }; // Lowered: js_alpha/1 (if-then-else / negation / once) function lowered_js_alpha_1(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("js_alpha/1"); if (Runtime.op_allocate(state) !== true) return false; { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } if (Runtime.op_builtin(program, state, "char_code/2", 2) !== true) return false; @@ -6169,10 +7365,67 @@ function lowered_js_alpha_1(program, state) { return true; } -lowered_dispatch["js_alpha/1"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("js_alpha/1"); return lowered_js_alpha_1(program, state); }; -// wamjs lower fallback: is_long_flag/1 fallback(execute of a non-self callee (nested Runtime.run would steal CP)) +lowered_dispatch["js_alpha/1"] = function (program, state) { return lowered_js_alpha_1(program, state); }; +// Lowered: is_long_flag/1 (deterministic) +function lowered_is_long_flag_1(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("is_long_flag/1"); + if (Runtime.op_allocate(state) !== true) return false; + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } + if (Runtime.op_builtin(program, state, "string_chars/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Atom(11)) !== true) return false; + if (Runtime.op_unify_variable(state, 106) !== true) return false; + if (Runtime.op_put_structure(program, state, 5, 106, 2) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Atom(11)) !== true) return false; + if (Runtime.op_unify_variable(state, 107) !== true) return false; + if (Runtime.op_put_structure(program, state, 5, 107, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + if (typeof lowered_js_alpha_1 === "function") { + Runtime.push_y_save(state); + const _ok = Runtime.run_lowered_body(program, state, lowered_js_alpha_1); + Runtime.pop_y_save(state); + if (_ok !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["js_alpha/1"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("js_alpha", 1)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_long_flag_tail_1 === "function") return lowered_long_flag_tail_1(program, state) === true; + { + const target = program.labels["long_flag_tail/1"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "long_flag_tail", 1) === true; + } + return true; +} + +lowered_dispatch["is_long_flag/1"] = function (program, state) { return lowered_is_long_flag_1(program, state); }; // Lowered: is_global_key/1 (if-then-else / negation / once) function lowered_is_global_key_1(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("is_global_key/1"); if (Runtime.op_allocate(state) !== true) return false; Runtime.put_reg(state, 203, Runtime.get_reg(state, 1)); if (Runtime.op_get_level(state, 204) !== true) return false; @@ -6181,25 +7434,22 @@ function lowered_is_global_key_1(program, state) { const _ite_cps = state.cps.length; const _ite_cond = (function () { { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 1, v); } - { + if (typeof lowered_global_options_1 === "function") { + if (lowered_global_options_1(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["global_options/1"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["global_options/1"] : undefined); + const target = program.labels["global_options/1"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["global_options/1"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("global_options", 1)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("global_options", 1)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -6209,25 +7459,22 @@ function lowered_is_global_key_1(program, state) { Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 3, v); } - { + if (typeof lowered_pair_lookup_3 === "function") { + if (lowered_pair_lookup_3(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["pair_lookup/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["pair_lookup/3"] : undefined); + const target = program.labels["pair_lookup/3"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["pair_lookup/3"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("pair_lookup", 3)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("pair_lookup", 3)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -6242,25 +7489,22 @@ function lowered_is_global_key_1(program, state) { Runtime.restore_machine(state, _ite_snap); while (state.cps.length > _ite_cps) state.cps.pop(); Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); - { + if (typeof lowered_js_object_prototype_key_1 === "function") { + if (lowered_js_object_prototype_key_1(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["js_object_prototype_key/1"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["js_object_prototype_key/1"] : undefined); + const target = program.labels["js_object_prototype_key/1"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["js_object_prototype_key/1"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("js_object_prototype_key", 1)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("js_object_prototype_key", 1)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -6274,9 +7518,10 @@ function lowered_is_global_key_1(program, state) { return true; } -lowered_dispatch["is_global_key/1"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("is_global_key/1"); return lowered_is_global_key_1(program, state); }; +lowered_dispatch["is_global_key/1"] = function (program, state) { return lowered_is_global_key_1(program, state); }; // Lowered: global_options/1 (deterministic ground fact; interned after first success) function lowered_global_options_1(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("global_options/1"); const _gk = "global_options/1"; const _gm = program.ground_memo || (program.ground_memo = Object.create(null)); const _cached = _gm[_gk]; @@ -6314,9 +7559,10 @@ function lowered_global_options_1(program, state) { return true; } -lowered_dispatch["global_options/1"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("global_options/1"); return lowered_global_options_1(program, state); }; +lowered_dispatch["global_options/1"] = function (program, state) { return lowered_global_options_1(program, state); }; // Lowered: flags_set/4 (if-then-else / negation / once) function lowered_flags_set_4(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("flags_set/4"); if (Runtime.op_allocate(state) !== true) return false; Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); @@ -6343,15 +7589,104 @@ function lowered_flags_set_4(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 203)); Runtime.put_reg(state, 4, Runtime.get_reg(state, 204)); - { + if (typeof lowered_flags_put_4 === "function") { + if (lowered_flags_put_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_put/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_put/4"] : undefined); + const target = program.labels["flags_put/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_put", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; +} + +lowered_dispatch["flags_set/4"] = function (program, state) { return lowered_flags_set_4(program, state); }; +// Lowered: flags_put/4 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_flags_put_4(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("flags_put/4"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); + if (Runtime.op_get_list(program, state, 4, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 103) !== true) return false; + if (Runtime.op_get_structure(program, state, 11, 103, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 101) !== true) return false; + if (Runtime.op_unify_value(program, state, 102) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Atom(2)) !== true) return false; + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 108) !== true) return false; + if (Runtime.op_get_structure(program, state, 11, 108, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + if (Runtime.op_unify_variable(state, 204) !== true) return false; + Runtime.put_reg(state, 205, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 206, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 201, Runtime.get_reg(state, 4)); + if (Runtime.op_get_level(state, 208) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 110) !== true) return false; + if (Runtime.op_unify_value(program, state, 204) !== true) return false; + if (Runtime.op_put_structure(program, state, 11, 110, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_unify_value(program, state, 206) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_variable(state, 110) !== true) return false; + if (Runtime.op_unify_variable(state, 207) !== true) return false; + if (Runtime.op_put_structure(program, state, 11, 110, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_unify_value(program, state, 203) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 207)); + if (typeof lowered_flags_put_4 === "function") { + if (lowered_flags_put_4(program, state) !== true) return false; } else { + const saved_cp = state.cp; + const saved_pc = state.pc; const target = program.labels["flags_put/4"]; + let _ok = true; if (target !== undefined && target !== null) { Runtime.push_y_save(state); state.cp = 0; @@ -6362,22 +7697,17 @@ function lowered_flags_set_4(program, state) { } else if (Runtime.step(program, state, I.Call("flags_put", 4)) !== true) { _ok = false; } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; } } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; } - if (Runtime.op_deallocate(state) !== true) return false; - return true; - return true; -} - -lowered_dispatch["flags_set/4"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("flags_set/4"); return lowered_flags_set_4(program, state); }; -// Lowered: flags_put/4 (T4 all-clauses inline) -function lowered_flags_put_4(program, state) { const _t4_trail = state.trail.length; const _t4_regs = Runtime.copy_table(state.regs); const _t4_vc = state.var_counter; @@ -6456,25 +7786,22 @@ function lowered_flags_put_4(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 205)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 206)); Runtime.put_reg(state, 4, Runtime.get_reg(state, 207)); - { + if (typeof lowered_flags_put_4 === "function") { + if (lowered_flags_put_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["flags_put/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["flags_put/4"] : undefined); + const target = program.labels["flags_put/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["flags_put/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("flags_put", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("flags_put", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -6487,23 +7814,109 @@ function lowered_flags_put_4(program, state) { return true; return false; })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; return false; } -lowered_dispatch["flags_put/4"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("flags_put/4"); return lowered_flags_put_4(program, state); }; -// wamjs lower fallback: first_equals_index/2 fallback(execute of a non-self callee (nested Runtime.run would steal CP)) -// Lowered: first_char_index/4 (T4 all-clauses inline) +lowered_dispatch["flags_put/4"] = function (program, state) { return lowered_flags_put_4(program, state); }; +// Lowered: first_equals_index/2 (deterministic) +function lowered_first_equals_index_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("first_equals_index/2"); + if (Runtime.op_allocate(state) !== true) return false; + Runtime.put_reg(state, 103, Runtime.get_reg(state, 1)); + Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 103)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } + if (Runtime.op_builtin(program, state, "string_chars/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, V.Atom(18)); + Runtime.put_reg(state, 3, V.Int(0)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 202)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_first_char_index_4 === "function") return lowered_first_char_index_4(program, state) === true; + { + const target = program.labels["first_char_index/4"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "first_char_index", 4) === true; + } + return true; +} + +lowered_dispatch["first_equals_index/2"] = function (program, state) { return lowered_first_equals_index_2(program, state); }; +// Lowered: first_char_index/4 (T4 nil/cons dispatch; no snapshot on bound A1) function lowered_first_char_index_4(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("first_char_index/4"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 102, Runtime.get_reg(state, 3)); + if (Runtime.op_get_constant(program, state, 4, V.Int(-1)) !== true) return false; + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + Runtime.put_reg(state, 204, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 202, Runtime.get_reg(state, 3)); + Runtime.put_reg(state, 206, Runtime.get_reg(state, 4)); + if (Runtime.op_get_level(state, 207) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_structure(program, state, 10, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Int(1)) !== true) return false; + if (Runtime.op_builtin(program, state, "is/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 206)); + if (typeof lowered_first_char_index_4 === "function") { + if (lowered_first_char_index_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["first_char_index/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("first_char_index", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return true; + } const _t4_trail = state.trail.length; const _t4_regs = Runtime.copy_table(state.regs); const _t4_vc = state.var_counter; @@ -6545,75 +7958,217 @@ function lowered_first_char_index_4(program, state) { const _ite_trail = state.trail.length; const _ite_args = Runtime.capture_a_regs(state, 8); const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); - if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_structure(program, state, 10, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Int(1)) !== true) return false; + if (Runtime.op_builtin(program, state, "is/2", 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); + Runtime.put_reg(state, 4, Runtime.get_reg(state, 206)); + if (typeof lowered_first_char_index_4 === "function") { + if (lowered_first_char_index_4(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["first_char_index/4"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("first_char_index", 4)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + } + } + if (Runtime.op_deallocate(state) !== true) return false; + return true; + return false; + })()) return true; + return false; +} + +lowered_dispatch["first_char_index/4"] = function (program, state) { return lowered_first_char_index_4(program, state); }; +// Lowered: drop_brackets/2 (T4 nil/cons dispatch; no snapshot on bound A1) +function lowered_drop_brackets_2(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("drop_brackets/2"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + if (Runtime.op_get_constant(program, state, 2, V.Atom(2)) !== true) return false; + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + Runtime.put_reg(state, 201, Runtime.get_reg(state, 2)); + if (Runtime.op_get_level(state, 205) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, V.Atom(16)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, V.Atom(17)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + } + } + return true; + })(); + if (_ite_cond) { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 2, v); } + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 204) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_drop_brackets_2 === "function") return lowered_drop_brackets_2(program, state) === true; + { + const target = program.labels["drop_brackets/2"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "drop_brackets", 2) === true; + } + return true; + } + const _t4_trail = state.trail.length; + const _t4_regs = Runtime.copy_table(state.regs); + const _t4_vc = state.var_counter; + const _t4_stack = state.stack.slice(); + const _t4_ysave = (state.y_save || []).slice(); + const _t4_mode = state.mode; + const _t4_build = state.build_stack.slice(); + const _t4_rstack = (state.read_stack || []).slice(); + const _t4_rargs = state.read_args; + const _t4_rcur = state.read_cursor; + if ((function () { + if (Runtime.op_get_constant(program, state, 1, V.Atom(2)) !== true) return false; + if (Runtime.op_get_constant(program, state, 2, V.Atom(2)) !== true) return false; + return true; + return false; + })()) return true; + while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } + state.regs = Runtime.copy_table(_t4_regs); + state.var_counter = _t4_vc; + state.stack = _t4_stack.slice(); + state.y_save = _t4_ysave.slice(); + state.mode = _t4_mode; + state.build_stack = _t4_build.slice(); + state.read_stack = _t4_rstack.slice(); + state.read_args = _t4_rargs; + state.read_cursor = _t4_rcur; + if ((function () { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 202) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + Runtime.put_reg(state, 201, Runtime.get_reg(state, 2)); + if (Runtime.op_get_level(state, 205) !== true) return false; + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + { + const _ite_trail = state.trail.length; + const _ite_args = Runtime.capture_a_regs(state, 8); + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, V.Atom(16)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + return true; + })(); + if (_ite_cond) { + } else { + Runtime.undo_trail(state, _ite_trail); + Runtime.restore_a_regs(state, _ite_args); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 2, V.Atom(17)); + if (Runtime.op_builtin(program, state, "==/2", 2) !== true) return false; + } + } return true; })(); if (_ite_cond) { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 206)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 2, v); } if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; } else { Runtime.undo_trail(state, _ite_trail); Runtime.restore_a_regs(state, _ite_args); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 1, v); } - if (Runtime.op_put_structure(program, state, 10, 2, 2) !== true) return false; + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + if (Runtime.op_put_structure(program, state, 5, 2, 2) !== true) return false; if (Runtime.op_unify_value(program, state, 202) !== true) return false; - if (Runtime.op_unify_constant(program, state, V.Int(1)) !== true) return false; - if (Runtime.op_builtin(program, state, "is/2", 2) !== true) return false; - Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); - Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); - Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); - Runtime.put_reg(state, 4, Runtime.get_reg(state, 206)); - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["first_char_index/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["first_char_index/4"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["first_char_index/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("first_char_index", 4)) !== true) { - _ok = false; - } - } - state.cp = saved_cp; - state.pc = saved_pc; - state.halt = false; - if (!_ok) return false; - } + if (Runtime.op_unify_variable(state, 204) !== true) return false; + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; } } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); if (Runtime.op_deallocate(state) !== true) return false; - return true; + if (typeof lowered_drop_brackets_2 === "function") return lowered_drop_brackets_2(program, state) === true; + { + const target = program.labels["drop_brackets/2"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "drop_brackets", 2) === true; + } return false; })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; return false; } -lowered_dispatch["first_char_index/4"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("first_char_index/4"); return lowered_first_char_index_4(program, state); }; -// wamjs lower fallback: drop_brackets/2 fallback(multi_clause_1 would keep interpreter CPs; T4+ITE did not match) +lowered_dispatch["drop_brackets/2"] = function (program, state) { return lowered_drop_brackets_2(program, state); }; // Lowered: default_registry/1 (deterministic ground fact; interned after first success) function lowered_default_registry_1(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("default_registry/1"); const _gk = "default_registry/1"; const _gm = program.ground_memo || (program.ground_memo = Object.create(null)); const _cached = _gm[_gk]; @@ -7119,9 +8674,123 @@ function lowered_default_registry_1(program, state) { return true; } -lowered_dispatch["default_registry/1"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("default_registry/1"); return lowered_default_registry_1(program, state); }; -// Lowered: count_required/3 (T4 all-clauses inline) +lowered_dispatch["default_registry/1"] = function (program, state) { return lowered_default_registry_1(program, state); }; +// Lowered: count_required/3 (T4 nil/cons dispatch; no snapshot on bound A1) function lowered_count_required_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("count_required/3"); + const _a1 = Runtime.deref(state, Runtime.get_reg(state, 1)); + if (Runtime.term_is_nil(program, _a1)) { + Runtime.put_reg(state, 101, Runtime.get_reg(state, 2)); + if (Runtime.op_get_value(program, state, 101, 3) !== true) return false; + return true; + return true; + } + if (Runtime.term_is_cons(program, _a1)) { + if (Runtime.op_allocate(state) !== true) return false; + if (Runtime.op_get_list(program, state, 1, 5) !== true) return false; + if (Runtime.op_unify_variable(state, 201) !== true) return false; + if (Runtime.op_unify_variable(state, 203) !== true) return false; + Runtime.put_reg(state, 202, Runtime.get_reg(state, 2)); + Runtime.put_reg(state, 205, Runtime.get_reg(state, 3)); + if (Runtime.op_get_level(state, 206) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, V.String("[")); + if (typeof lowered_starts_with_2 === "function") { + if (lowered_starts_with_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["starts_with/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 1, v); } + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + if (Runtime.op_get_level(state, 207) !== true) return false; + { + const _ite_snap = Runtime.snapshot_machine(state); + const _ite_cps = state.cps.length; + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); + Runtime.put_reg(state, 2, V.String("...")); + if (typeof lowered_starts_with_2 === "function") { + if (lowered_starts_with_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["starts_with/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { + _ok = false; + } + state.cp = saved_cp; + state.pc = saved_pc; + state.halt = false; + if (!_ok) return false; + } + return true; + })(); + if (_ite_cond) { + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 1, v); } + Runtime.put_reg(state, 2, Runtime.get_reg(state, 202)); + if (Runtime.op_builtin(program, state, "=/2", 2) !== true) return false; + } else { + Runtime.restore_machine(state, _ite_snap); + while (state.cps.length > _ite_cps) state.cps.pop(); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 1, v); } + if (Runtime.op_put_structure(program, state, 10, 2, 2) !== true) return false; + if (Runtime.op_unify_value(program, state, 202) !== true) return false; + if (Runtime.op_unify_constant(program, state, V.Int(1)) !== true) return false; + if (Runtime.op_builtin(program, state, "is/2", 2) !== true) return false; + } + } + } + } + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); + Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); + if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_count_required_3 === "function") return lowered_count_required_3(program, state) === true; + { + const target = program.labels["count_required/3"]; + if (target !== undefined && target !== null) { + return Runtime.execute_user_isolated(program, state, target) === true; + } + return Runtime.op_builtin(program, state, "count_required", 3) === true; + } + return true; + } const _t4_trail = state.trail.length; const _t4_regs = Runtime.copy_table(state.regs); const _t4_vc = state.var_counter; @@ -7163,25 +8832,22 @@ function lowered_count_required_3(program, state) { const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); Runtime.put_reg(state, 2, V.String("[")); - { + if (typeof lowered_starts_with_2 === "function") { + if (lowered_starts_with_2(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["starts_with/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["starts_with/2"] : undefined); + const target = program.labels["starts_with/2"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["starts_with/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -7204,25 +8870,22 @@ function lowered_count_required_3(program, state) { const _ite_cond = (function () { Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); Runtime.put_reg(state, 2, V.String("...")); - { + if (typeof lowered_starts_with_2 === "function") { + if (lowered_starts_with_2(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["starts_with/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["starts_with/2"] : undefined); + const target = program.labels["starts_with/2"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["starts_with/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -7251,38 +8914,23 @@ function lowered_count_required_3(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 204)); Runtime.put_reg(state, 3, Runtime.get_reg(state, 205)); if (Runtime.op_deallocate(state) !== true) return false; + if (typeof lowered_count_required_3 === "function") return lowered_count_required_3(program, state) === true; { - const _lf = (program.lowered_dispatch && program.lowered_dispatch["count_required/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["count_required/3"] : undefined); - if (typeof _lf === "function") return _lf(program, state) === true; const target = program.labels["count_required/3"]; if (target !== undefined && target !== null) { - state.pc = target; - state.program = program; - return Runtime.run_isolated(program, state) === true; + return Runtime.execute_user_isolated(program, state, target) === true; } - if (Runtime.step(program, state, I.Execute("count_required", 3)) !== true) return false; - if (state.halt) return true; - state.program = program; - return Runtime.run_isolated(program, state) === true; + return Runtime.op_builtin(program, state, "count_required", 3) === true; } return false; })()) return true; - while (state.trail.length > _t4_trail) { const _n = state.trail.pop(); delete state.bindings[_n]; } - state.regs = Runtime.copy_table(_t4_regs); - state.var_counter = _t4_vc; - state.stack = _t4_stack.slice(); - state.y_save = _t4_ysave.slice(); - state.mode = _t4_mode; - state.build_stack = _t4_build.slice(); - state.read_stack = _t4_rstack.slice(); - state.read_args = _t4_rargs; - state.read_cursor = _t4_rcur; return false; } -lowered_dispatch["count_required/3"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("count_required/3"); return lowered_count_required_3(program, state); }; +lowered_dispatch["count_required/3"] = function (program, state) { return lowered_count_required_3(program, state); }; // Lowered: check_arity/3 (if-then-else / negation / once) function lowered_check_arity_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("check_arity/3"); if (Runtime.op_allocate(state) !== true) return false; Runtime.put_reg(state, 210, Runtime.get_reg(state, 1)); Runtime.put_reg(state, 203, Runtime.get_reg(state, 2)); @@ -7297,28 +8945,25 @@ function lowered_check_arity_3(program, state) { { const _ite_snap = Runtime.snapshot_machine(state); const _ite_cps = state.cps.length; - const _ite_cond = (function () { - Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); - { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } - { - const saved_cp = state.cp; - const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["last_element/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["last_element/2"] : undefined); - let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["last_element/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("last_element", 2)) !== true) { - _ok = false; - } + const _ite_cond = (function () { + Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); + { const v = Runtime.new_var(state); Runtime.put_reg(state, 201, v); Runtime.put_reg(state, 2, v); } + if (typeof lowered_last_element_2 === "function") { + if (lowered_last_element_2(program, state) !== true) return false; + } else { + const saved_cp = state.cp; + const saved_pc = state.pc; + const target = program.labels["last_element/2"]; + let _ok = true; + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("last_element", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -7327,25 +8972,22 @@ function lowered_check_arity_3(program, state) { } Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); Runtime.put_reg(state, 2, V.String("...")); - { + if (typeof lowered_starts_with_2 === "function") { + if (lowered_starts_with_2(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["starts_with/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["starts_with/2"] : undefined); + const target = program.labels["starts_with/2"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["starts_with/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("starts_with", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -7369,25 +9011,22 @@ function lowered_check_arity_3(program, state) { Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); Runtime.put_reg(state, 2, V.Int(0)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 3, v); } - { + if (typeof lowered_count_required_3 === "function") { + if (lowered_count_required_3(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["count_required/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["count_required/3"] : undefined); + const target = program.labels["count_required/3"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["count_required/3"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("count_required", 3)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("count_required", 3)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -7409,25 +9048,22 @@ function lowered_check_arity_3(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); Runtime.put_reg(state, 3, V.String("argument")); { const v = Runtime.new_var(state); Runtime.put_reg(state, 204, v); Runtime.put_reg(state, 4, v); } - { + if (typeof lowered_nth0_default_4 === "function") { + if (lowered_nth0_default_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["nth0_default/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["nth0_default/4"] : undefined); + const target = program.labels["nth0_default/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["nth0_default/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("nth0_default", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("nth0_default", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -7436,25 +9072,22 @@ function lowered_check_arity_3(program, state) { } Runtime.put_reg(state, 1, Runtime.get_reg(state, 204)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 205, v); Runtime.put_reg(state, 2, v); } - { + if (typeof lowered_strip_brackets_2 === "function") { + if (lowered_strip_brackets_2(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["strip_brackets/2"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["strip_brackets/2"] : undefined); + const target = program.labels["strip_brackets/2"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["strip_brackets/2"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("strip_brackets", 2)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("strip_brackets", 2)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -7490,25 +9123,22 @@ function lowered_check_arity_3(program, state) { Runtime.put_reg(state, 2, Runtime.get_reg(state, 210)); Runtime.put_reg(state, 3, V.String("")); { const v = Runtime.new_var(state); Runtime.put_reg(state, 211, v); Runtime.put_reg(state, 4, v); } - { + if (typeof lowered_nth0_default_4 === "function") { + if (lowered_nth0_default_4(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["nth0_default/4"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["nth0_default/4"] : undefined); + const target = program.labels["nth0_default/4"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["nth0_default/4"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("nth0_default", 4)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("nth0_default", 4)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -7538,9 +9168,10 @@ function lowered_check_arity_3(program, state) { return true; } -lowered_dispatch["check_arity/3"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("check_arity/3"); return lowered_check_arity_3(program, state); }; +lowered_dispatch["check_arity/3"] = function (program, state) { return lowered_check_arity_3(program, state); }; // Lowered: action_entry/3 (if-then-else / negation / once) function lowered_action_entry_3(program, state) { + if (Runtime._prof) Runtime.prof_lowered_call("action_entry/3"); if (Runtime.op_allocate(state) !== true) return false; Runtime.put_reg(state, 201, Runtime.get_reg(state, 1)); Runtime.put_reg(state, 203, Runtime.get_reg(state, 2)); @@ -7553,25 +9184,22 @@ function lowered_action_entry_3(program, state) { Runtime.put_reg(state, 1, Runtime.get_reg(state, 201)); Runtime.put_reg(state, 2, Runtime.get_reg(state, 203)); { const v = Runtime.new_var(state); Runtime.put_reg(state, 202, v); Runtime.put_reg(state, 3, v); } - { + if (typeof lowered_pair_lookup_3 === "function") { + if (lowered_pair_lookup_3(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["pair_lookup/3"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["pair_lookup/3"] : undefined); + const target = program.labels["pair_lookup/3"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["pair_lookup/3"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("pair_lookup", 3)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("pair_lookup", 3)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -7588,25 +9216,22 @@ function lowered_action_entry_3(program, state) { Runtime.restore_machine(state, _ite_snap); while (state.cps.length > _ite_cps) state.cps.pop(); Runtime.put_reg(state, 1, Runtime.get_reg(state, 203)); - { + if (typeof lowered_js_object_prototype_key_1 === "function") { + if (lowered_js_object_prototype_key_1(program, state) !== true) return false; + } else { const saved_cp = state.cp; const saved_pc = state.pc; - const _lf = (program.lowered_dispatch && program.lowered_dispatch["js_object_prototype_key/1"]) || ((typeof lowered_dispatch !== "undefined") ? lowered_dispatch["js_object_prototype_key/1"] : undefined); + const target = program.labels["js_object_prototype_key/1"]; let _ok = true; - if (typeof _lf === "function") { - _ok = _lf(program, state) === true; - } else { - const target = program.labels["js_object_prototype_key/1"]; - if (target !== undefined && target !== null) { - Runtime.push_y_save(state); - state.cp = 0; - state.pc = target; - state.program = program; - _ok = Runtime.run_isolated(program, state) === true; - state.halt = false; - } else if (Runtime.step(program, state, I.Call("js_object_prototype_key", 1)) !== true) { - _ok = false; - } + if (target !== undefined && target !== null) { + Runtime.push_y_save(state); + state.cp = 0; + state.pc = target; + state.program = program; + _ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + } else if (Runtime.step(program, state, I.Call("js_object_prototype_key", 1)) !== true) { + _ok = false; } state.cp = saved_cp; state.pc = saved_pc; @@ -7625,16 +9250,30 @@ function lowered_action_entry_3(program, state) { return true; } -lowered_dispatch["action_entry/3"] = function (program, state) { if (Runtime._prof) Runtime.prof_lowered_call("action_entry/3"); return lowered_action_entry_3(program, state); }; +lowered_dispatch["action_entry/3"] = function (program, state) { return lowered_action_entry_3(program, state); }; shared_program.lowered_dispatch = lowered_dispatch; function substring_range(a1, a2, a3, a4) { - return Runtime.run_predicate(shared_program, 2145, [a1, a2, a3, a4]); + const state = Runtime.new_state(); + const args = [a1, a2, a3, a4]; + for (let i = 0; i < 4; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_substring_range_4(shared_program, state) === true; } M.substring_range = substring_range; function substring_from(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 2126, [a1, a2, a3]); + const state = Runtime.new_state(); + const args = [a1, a2, a3]; + for (let i = 0; i < 3; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_substring_from_3(shared_program, state) === true; } M.substring_from = substring_from; @@ -7646,7 +9285,6 @@ function strip_brackets(a1, a2) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("strip_brackets/2"); return lowered_strip_brackets_2(shared_program, state) === true; } M.strip_brackets = strip_brackets; @@ -7659,7 +9297,6 @@ function string_member(a1, a2) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("string_member/2"); return lowered_string_member_2(shared_program, state) === true; } M.string_member = string_member; @@ -7672,7 +9309,6 @@ function strict_option(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("strict_option/11"); return lowered_strict_option_11(shared_program, state) === true; } M.strict_option = strict_option; @@ -7685,7 +9321,6 @@ function strict_loop(a1, a2, a3, a4, a5, a6, a7, a8) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("strict_loop/8"); return lowered_strict_loop_8(shared_program, state) === true; } M.strict_loop = strict_loop; @@ -7698,7 +9333,6 @@ function starts_with(a1, a2) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("starts_with/2"); return lowered_starts_with_2(shared_program, state) === true; } M.starts_with = starts_with; @@ -7711,7 +9345,6 @@ function split_flag_token(a1, a2, a3) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("split_flag_token/3"); return lowered_split_flag_token_3(shared_program, state) === true; } M.split_flag_token = split_flag_token; @@ -7724,7 +9357,6 @@ function schema_for(a1, a2, a3, a4, a5) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("schema_for/5"); return lowered_schema_for_5(shared_program, state) === true; } M.schema_for = schema_for; @@ -7737,7 +9369,6 @@ function scan_leading_globals(a1, a2, a3, a4) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("scan_leading_globals/4"); return lowered_scan_leading_globals_4(shared_program, state) === true; } M.scan_leading_globals = scan_leading_globals; @@ -7750,7 +9381,6 @@ function registry_entry(a1, a2, a3) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("registry_entry/3"); return lowered_registry_entry_3(shared_program, state) === true; } M.registry_entry = registry_entry; @@ -7763,7 +9393,6 @@ function parse_strict(a1, a2, a3, a4) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("parse_strict/4"); return lowered_parse_strict_4(shared_program, state) === true; } M.parse_strict = parse_strict; @@ -7776,7 +9405,6 @@ function parse_lenient(a1, a2, a3) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("parse_lenient/3"); return lowered_parse_lenient_3(shared_program, state) === true; } M.parse_lenient = parse_lenient; @@ -7789,13 +9417,19 @@ function parse_args(a1, a2, a3) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("parse_args/3"); return lowered_parse_args_3(shared_program, state) === true; } M.parse_args = parse_args; function parse_args(a1, a2) { - return Runtime.run_predicate(shared_program, 1326, [a1, a2]); + const state = Runtime.new_state(); + const args = [a1, a2]; + for (let i = 0; i < 2; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_parse_args_2(shared_program, state) === true; } M.parse_args = parse_args; @@ -7807,7 +9441,6 @@ function pair_lookup(a1, a2, a3) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("pair_lookup/3"); return lowered_pair_lookup_3(shared_program, state) === true; } M.pair_lookup = pair_lookup; @@ -7820,7 +9453,6 @@ function option_kind(a1, a2, a3) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("option_kind/3"); return lowered_option_kind_3(shared_program, state) === true; } M.option_kind = option_kind; @@ -7833,7 +9465,6 @@ function nth0_default(a1, a2, a3, a4) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("nth0_default/4"); return lowered_nth0_default_4(shared_program, state) === true; } M.nth0_default = nth0_default; @@ -7846,7 +9477,6 @@ function next_value(a1, a2) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("next_value/2"); return lowered_next_value_2(shared_program, state) === true; } M.next_value = next_value; @@ -7859,18 +9489,31 @@ function merge_flags_(a1, a2, a3) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("merge_flags_/3"); return lowered_merge_flags__3(shared_program, state) === true; } M.merge_flags_ = merge_flags_; function merge_flags(a1, a2, a3) { - return Runtime.run_predicate(shared_program, 1150, [a1, a2, a3]); + const state = Runtime.new_state(); + const args = [a1, a2, a3]; + for (let i = 0; i < 3; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_merge_flags_3(shared_program, state) === true; } M.merge_flags = merge_flags; function looks_like_legacy_flag(a1) { - return Runtime.run_predicate(shared_program, 1131, [a1]); + const state = Runtime.new_state(); + const args = [a1]; + for (let i = 0; i < 1; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_looks_like_legacy_flag_1(shared_program, state) === true; } M.looks_like_legacy_flag = looks_like_legacy_flag; @@ -7882,13 +9525,19 @@ function long_flag_tail(a1) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("long_flag_tail/1"); return lowered_long_flag_tail_1(shared_program, state) === true; } M.long_flag_tail = long_flag_tail; function lenient_result(a1, a2) { - return Runtime.run_predicate(shared_program, 1097, [a1, a2]); + const state = Runtime.new_state(); + const args = [a1, a2]; + for (let i = 0; i < 2; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_lenient_result_2(shared_program, state) === true; } M.lenient_result = lenient_result; @@ -7900,7 +9549,6 @@ function lenient_loop(a1, a2, a3, a4, a5) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("lenient_loop/5"); return lowered_lenient_loop_5(shared_program, state) === true; } M.lenient_loop = lenient_loop; @@ -7913,7 +9561,6 @@ function legacy_flag_tail(a1) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("legacy_flag_tail/1"); return lowered_legacy_flag_tail_1(shared_program, state) === true; } M.legacy_flag_tail = legacy_flag_tail; @@ -7926,7 +9573,6 @@ function last_element(a1, a2) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("last_element/2"); return lowered_last_element_2(shared_program, state) === true; } M.last_element = last_element; @@ -7939,13 +9585,19 @@ function js_object_prototype_keys(a1) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("js_object_prototype_keys/1"); return lowered_js_object_prototype_keys_1(shared_program, state) === true; } M.js_object_prototype_keys = js_object_prototype_keys; function js_object_prototype_key(a1) { - return Runtime.run_predicate(shared_program, 917, [a1]); + const state = Runtime.new_state(); + const args = [a1]; + for (let i = 0; i < 1; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_js_object_prototype_key_1(shared_program, state) === true; } M.js_object_prototype_key = js_object_prototype_key; @@ -7957,7 +9609,6 @@ function js_flag_char(a1) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("js_flag_char/1"); return lowered_js_flag_char_1(shared_program, state) === true; } M.js_flag_char = js_flag_char; @@ -7970,13 +9621,19 @@ function js_alpha(a1) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("js_alpha/1"); return lowered_js_alpha_1(shared_program, state) === true; } M.js_alpha = js_alpha; function is_long_flag(a1) { - return Runtime.run_predicate(shared_program, 831, [a1]); + const state = Runtime.new_state(); + const args = [a1]; + for (let i = 0; i < 1; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_is_long_flag_1(shared_program, state) === true; } M.is_long_flag = is_long_flag; @@ -7988,7 +9645,6 @@ function is_global_key(a1) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("is_global_key/1"); return lowered_is_global_key_1(shared_program, state) === true; } M.is_global_key = is_global_key; @@ -8001,7 +9657,6 @@ function global_options(a1) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("global_options/1"); return lowered_global_options_1(shared_program, state) === true; } M.global_options = global_options; @@ -8014,7 +9669,6 @@ function flags_set(a1, a2, a3, a4) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("flags_set/4"); return lowered_flags_set_4(shared_program, state) === true; } M.flags_set = flags_set; @@ -8027,13 +9681,19 @@ function flags_put(a1, a2, a3, a4) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("flags_put/4"); return lowered_flags_put_4(shared_program, state) === true; } M.flags_put = flags_put; function first_equals_index(a1, a2) { - return Runtime.run_predicate(shared_program, 711, [a1, a2]); + const state = Runtime.new_state(); + const args = [a1, a2]; + for (let i = 0; i < 2; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_first_equals_index_2(shared_program, state) === true; } M.first_equals_index = first_equals_index; @@ -8045,13 +9705,19 @@ function first_char_index(a1, a2, a3, a4) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("first_char_index/4"); return lowered_first_char_index_4(shared_program, state) === true; } M.first_char_index = first_char_index; function drop_brackets(a1, a2) { - return Runtime.run_predicate(shared_program, 636, [a1, a2]); + const state = Runtime.new_state(); + const args = [a1, a2]; + for (let i = 0; i < 2; i++) { + Runtime.put_reg(state, i + 1, i < args.length && args[i] !== undefined ? args[i] : Runtime.new_var(state)); + } + state.cp = 0; + state.program = shared_program; + return lowered_drop_brackets_2(shared_program, state) === true; } M.drop_brackets = drop_brackets; @@ -8063,7 +9729,6 @@ function default_registry(a1) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("default_registry/1"); return lowered_default_registry_1(shared_program, state) === true; } M.default_registry = default_registry; @@ -8076,7 +9741,6 @@ function count_required(a1, a2, a3) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("count_required/3"); return lowered_count_required_3(shared_program, state) === true; } M.count_required = count_required; @@ -8089,7 +9753,6 @@ function check_arity(a1, a2, a3) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("check_arity/3"); return lowered_check_arity_3(shared_program, state) === true; } M.check_arity = check_arity; @@ -8102,7 +9765,6 @@ function action_entry(a1, a2, a3) { } state.cp = 0; state.program = shared_program; - if (Runtime._prof) Runtime.prof_lowered_call("action_entry/3"); return lowered_action_entry_3(shared_program, state) === true; } M.action_entry = action_entry; diff --git a/examples/cli_args/wamjs/js/wam_runtime.js b/examples/cli_args/wamjs/js/wam_runtime.js index 281c70abc..6dbee137c 100644 --- a/examples/cli_args/wamjs/js/wam_runtime.js +++ b/examples/cli_args/wamjs/js/wam_runtime.js @@ -540,6 +540,53 @@ function term_is_ground(state, v, seen) { Runtime.term_is_ground = term_is_ground; +Runtime.term_is_nil = function (program, v) { + if (!v || typeof v !== "object") return false; + if (v.tag !== "atom") return false; + return Runtime.string_of(program.intern_table, v.id) === "[]"; +}; + +Runtime.term_is_cons = function (program, v) { + if (!v || typeof v !== "object" || v.tag !== "struct") return false; + if ((v.args || []).length !== 2) return false; + return is_cons_fid(program, v.fid); +}; + +Runtime.snapshot_lite = function (state) { + const x = {}; + const r = state.regs; + for (let i = 101; i <= 160; i++) { + if (r[i] !== undefined) x[i] = r[i]; + } + return { + trail_len: state.trail.length, + var_counter: state.var_counter, + mode: state.mode, + build_stack: state.build_stack.slice(), + read_stack: (state.read_stack || []).slice(), + read_args: state.read_args, + read_cursor: state.read_cursor, + a: Runtime.capture_a_regs(state, 16), + x: x + }; +}; + +Runtime.restore_lite = function (state, snap) { + undo_trail(state, snap.trail_len); + state.var_counter = snap.var_counter; + state.mode = snap.mode; + state.build_stack = snap.build_stack || []; + state.read_stack = (snap.read_stack || []).slice(); + if (snap.read_args !== undefined) state.read_args = snap.read_args; + if (snap.read_cursor !== undefined) state.read_cursor = snap.read_cursor; + Runtime.restore_a_regs(state, snap.a); + const r = state.regs; + for (let i = 101; i <= 160; i++) delete r[i]; + const x = snap.x || {}; + const xk = Object.keys(x); + for (let i = 0; i < xk.length; i++) r[xk[i]] = x[xk[i]]; +}; + // Mixed-mode: an interpreted Call/Execute whose target has a lowered // function must run that function, not the bytecode (otherwise helpers // stay on the slow path). Call pushes Y (convention from A2); Execute @@ -587,6 +634,7 @@ function run_lowered_body(program, state, fn) { state.halt = false; return ok === true; } +Runtime.run_lowered_body = run_lowered_body; function invoke_lowered_call(program, state, fn) { const retPc = state.pc + 1; @@ -3814,6 +3862,26 @@ Runtime.run_isolated = function (program, state) { return ok === true; }; +// Lowered last-goal Execute of an *interpreted* user predicate. +// WAM Execute does not modify CP; the callee's Proceed returns to the +// CP that was live at the Execute. A lowered frame's Proceed is +// `return true` from JS, so the isolated interpreter must NOT resume +// at that CP (that would steal the query continuation — GP-PERF round 1 +// corpus test 1). Setting cp=0 makes the callee's Proceed halt the +// isolated run; restoring the saved CP makes this function's caller +// (the lowered wrapper, or invoke_lowered_execute) the actual Proceed. +Runtime.execute_user_isolated = function (program, state, target) { + const saved_cp = state.cp; + state.cp = 0; + state.pc = target; + state.program = program; + state.halt = false; + const ok = Runtime.run_isolated(program, state) === true; + state.halt = false; + state.cp = saved_cp; + return ok === true; +}; + Runtime.collect_run = function (program, state, onSolution) { state.program = program; state.halt = false; From 8990bbf80905be5ef72773362a88e6dbbcea5f70 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 1 Sep 2026 13:43:26 +0000 Subject: [PATCH 4/4] Record GP-PERF-2 argparser numbers and continuation argument. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5067-line differential: 2.187s (2.12× vs A2 4.639s, 1.50× vs round-1 this-VM 3.271s), 0 divergences. Wrappers lower; interpreter instr 0 on the 200-line profile. Residual is still the lowered-tier snapshots. Co-authored-by: johns243a --- docs/WAM_JAVASCRIPT_STATUS.md | 109 ++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 33 deletions(-) diff --git a/docs/WAM_JAVASCRIPT_STATUS.md b/docs/WAM_JAVASCRIPT_STATUS.md index 7a1eee323..7018557c9 100644 --- a/docs/WAM_JAVASCRIPT_STATUS.md +++ b/docs/WAM_JAVASCRIPT_STATUS.md @@ -234,9 +234,11 @@ shim (`cliArgs.mjs`) converts JS `argv` ↔ WAM terms and maps `ok/2` / | Differential vs JS oracle (`run_differential_wamjs.sh`, same seed) | **5067 lines, 0 divergences, 0 message mismatches** | A2 interpreter baseline (parent `grok/wamjs-cli-args`, this machine): oracle -**0.048s**, wamjs **4.639s**. Mixed + intern + direct ops (this branch): -oracle **0.054s**, wamjs **3.144s** (**1.48×** vs 4.639s). Stretch ≥5× was -not met; see [GP-PERF](#gp-perf-mixed-mode-and-ground-intern). +**0.048s**, wamjs **4.639s**. GP-PERF round 1 mixed (`grok/wamjs-perf`): +**3.144s** (**1.48×** vs 4.639s). GP-PERF-2 (`grok/wamjs-perf2`, this +machine): oracle **0.056s**, wamjs **2.187s** (**2.12×** vs 4.639s, +**1.50×** vs this-VM round-1 3.271s). Stretch ≥4.5× vs A2 / ≥3× vs round 1 +was not met; see [GP-PERF](#gp-perf-mixed-mode-and-ground-intern). Runtime gaps this program forced: `sub_string/5`; Y-register save/restore across `Call` of a non-`Allocate` fact; `Execute` of a builtin `Proceed`s to @@ -263,24 +265,45 @@ arrays. A later trail undo only deletes caller bindings. Sharing the live constructed term (no `copy_term`) is unsound: a later write-mode `GetList` can alias into the interned object and build cyclic lists. -### Argparser: lower vs interpret +### Continuation integrity (Execute-of-user) -**Lowered (hot path):** `first_char_index/4`, `starts_with/2`, -`string_member/2`, `pair_lookup/3`, `split_flag_token/3`, -`default_registry/1` (ground memo), `lenient_loop/5`, `strict_loop/8`, -`parse_args/3`, `next_value/2`, `flags_*`, `scan_leading_globals/4`, -`option_kind/3`, `registry_entry/3`, `schema_for/5`, `parse_strict/4`, -`parse_lenient/3`, `count_required/3`, `check_arity/3`, `merge_flags_/3`, -`nth0_default/4`, `strict_option/11`, … +WAM Execute does not modify CP. A lowered frame's Proceed is JS +`return true`, so the callee must not resume at the query CP. -**Still interpret:** +- **Lowered callee:** `return lowered_P_N(program, state) === true`. + JS return *is* Proceed; `state.cp` is untouched. +- **Interpreted user callee:** `Runtime.execute_user_isolated` saves CP, + sets `cp=0` so the isolated interpreter's Proceed **halts** instead of + jumping the query continuation, then restores CP. The lowered wrapper's + `return` is the real Proceed (so `invoke_lowered_execute` can + `proceed_to_cp`). Round 1's `cp=0` without restore stole corpus test 1. +- **Call with live Y after the Call** (the other half of corpus test 1): + `parse_args/2` Calls `default_registry/1` then reads Y1–Y3. Ground-intern + first construction can clobber caller Y; emit `push_y_save` / + `run_lowered_body` / `pop_y_save` only when a Y register is live across + the Call. Interpreter `invoke_lowered_call` always Y-saves. -| Predicate | Why | -|---|---| -| `parse_args/2` | Execute of non-self (`parse_args/3`). Nested `Runtime.run` with `cp=0` steals the query continuation. | -| `drop_brackets/2` | `multi_clause_1`; T4+ITE did not match. | -| `first_equals_index/2`, `is_long_flag/1`, `js_object_prototype_key/1`, `lenient_result/2`, `looks_like_legacy_flag/1`, `merge_flags/3` | Execute of a non-self user predicate. | -| `substring_from/3`, `substring_range/4` | Execute of a JS WAM builtin (`sub_string/5`). | +Probes: `execute_user_continuation_integrity` (nested Execute + +Call-then-continue) and `execute_user_interpreted_callee` in +`tests/test_wam_javascript_lowered.pl`. + +### Argparser: lower vs interpret + +**Lowered (all 43 compiled preds, including the round-1 leftovers):** +`parse_args/2`, `parse_args/3`, `looks_like_legacy_flag/1`, +`lenient_result/2`, `merge_flags/3`, `is_long_flag/1`, +`first_equals_index/2`, `js_object_prototype_key/1`, +`drop_brackets/2` (T4 nil/cons), `substring_from/3`, `substring_range/4` +(Execute of `sub_string/5` → `Runtime.op_builtin`), plus the round-1 hot +path (`first_char_index/4`, `string_member/2`, `pair_lookup/3`, +`starts_with/2`, `lenient_loop/5`, `strict_loop/8`, `default_registry/1` +ground memo, …). + +**Still interpret (argparser build):** none. `build.sh` emits no +`wamjs lower fallback` comments. Call of a JS WAM builtin is +`op_builtin` (same first-solution semantics as interpreter +`try_builtin_fallback`). Unbound-A1 T4 still has a snapshot fallback +inside the lowered function; that is not interpreter fallback. ### 200-line `UW_PROFILE=1` (same cases) @@ -288,21 +311,41 @@ A2 interpreter (parent JS): `first_char_index/4` 3910 calls / 3910 CPs / 96k instr; `default_registry/1` 200 calls / 96k instr / 0 CPs; `string_member/2` 1804 calls / 1821 CPs. -After mixed + intern + `Runtime.op_*` + cheap `==/2` ITE + nested-ITE -fold: interpreter instr drop to **20,667** (almost only `drop_brackets/2`). -Lowered preds report calls-only (`*`): `first_char_index/4*` 3910, -`string_member/2*` 1804, `lenient_loop/5*` 588, `parse_args/3*` 200, -`default_registry/1*` 200. Call counts match A2 (no runaway recursion). +Round 1: interpreter instr **20,667** (almost only `drop_brackets/2`). +Lowered call counts: `first_char_index/4*` 3910, `string_member/2*` 1804. + +Round 2 after L1b (wrappers lower, `drop_brackets/2` still interpreted): +instr **8,985**. After L2+L3 (nil/cons + lite ITE + builtin Execute + +`drop_brackets/2` fold) and L4 (direct JS Call): instr **0**, +`drop_brackets/2*` 10, `parse_args/2*` 200. Call counts still match A2 +(`string_member/2*` 1804 — cheap-ITE-for-`=/2` runaway would explode this). + +### Per-lever wall time (5067-line differential, this VM) + +| Stage | Wall | vs R1 3.271s | vs A2 4.639s | 200-line instr | +|---|---|---|---|---| +| A2 interpreter | 4.639s | — | 1.00× | (interpreter) | +| Round 1 (`grok/wamjs-perf`) | 3.271s (docs 3.144s) | 1.00× | 1.42× | 20,667 | +| L1 Y-save on every Call | 4.978s | 0.66× (regression) | — | — | +| L1b Y-save iff Y live after Call | 3.014s | 1.09× | 1.54× | 8,985 | +| L2+L3 nil/cons + lite ITE + builtin Execute | 2.211s | 1.48× | 2.10× | 0 | +| L4 direct JS Call/Execute + Call-of-builtin | **2.187s** | **1.50×** | **2.12×** | 0 | + +Official `run_differential_wamjs.sh`: oracle **0.056s**, wamjs **2.187s**, +**0 divergences, 0 message mismatches**, corpus **17/17**. Target was ≥3× +vs round 1 (≤1.05s) / ≥4.5× vs A2; L1b paid the wrapper lowering, L2 +paid the snapshot cut, L4 was essentially flat. ### Residual -Lowered helpers still `copy_table` the full register file on every T4 -clause fail and `snapshot_machine` on ITE whose condition unifies -(`=/2`, `put_structure`). Direct `Runtime.op_*` removed `I.*` allocation -but not those copies. Next lever: a **correct** Execute-of-user path -(so `parse_args/2` / `looks_like_legacy_flag/1` / `substring_from/3` -wrappers lower) without the `cp=0` steal; then, if the loop is the cost, -skip full-register T4 snapshots for helpers that only touch A1–AN. +The lowered tier still dominates. Unbound-A1 T4 copies the register file; +unifying ITE still `snapshot_lite`s A1–A16 + X101–X160 (Call/Allocate in +the condition still `snapshot_machine`). Recursive Call is a direct JS +call but still `allocate`/`deallocate`s Y frames (convention: Y-snapshot +≥201, not Lua locals). `default_registry/1` ground-intern `copy_term`s a +large term on first construction. Next lever: skip `snapshot_lite` when +the ITE condition is read-only, and/or intern `default_registry/1` at +emit time so the first `parse_args/2` is not a full construction. ## Remaining / partial @@ -316,12 +359,12 @@ skip full-register T4 snapshots for helpers that only touch A1–AN. | `format/2` `/3` | **Implemented** for `~w ~a ~d ~p ~q ~n ~s ~t ~~`. Not ported: `~f`, `~r`, `~D`, positioning (`~N|`, `~+`, `t~`), aliases, and stream sinks other than stdout / `atom(A)` / `string(S)`. | | `sub_atom/5` | **Implemented** when Atom is ground; enumerates unbound Before/Length/After (and filters a ground SubAtom). | | `sub_string/5` | **Implemented.** Same enumeration as `sub_atom/5`; Sub is a `V.String`. | -| Peerhailer argparser (A2) | **Implemented.** `examples/cli_args/wamjs/` compiles `cli_args.pl` through `wam_javascript` (`emit_mode(mixed)`) and matches the JS oracle: **17/17** corpus, **5067-line** differential with **0 divergences, 0 message mismatches**. A2 interpreter baseline 4.639s → mixed 3.144s (**1.48×**). | +| Peerhailer argparser (A2) | **Implemented.** `examples/cli_args/wamjs/` compiles `cli_args.pl` through `wam_javascript` (`emit_mode(mixed)`) and matches the JS oracle: **17/17** corpus, **5067-line** differential with **0 divergences, 0 message mismatches**. A2 interpreter baseline 4.639s → round-1 mixed 3.144s (**1.48×**) → GP-PERF-2 **2.187s** (**2.12×** vs A2). | | String term tag | **Implemented.** `V.String` is a distinct tag. Unify/`==` require equal strings (not atoms). Standard order / `compare/3` / `sort` matches SWI 9.0.4: Var < Number < **String** < Atom < Compound (`"foo" @< foo`). `atom_string/2`, `string_concat/3`, `string_chars/2` (construct), `string_to_atom/2`, `number_string/2`, `split_string/4` produce strings. `string/1` is true only for the tag. `string_length/2` accepts a string, atom, or number (code-point length). `write/1` prints text unquoted; `writeq/1` and `format` `~q` recurse through lists/compounds, double-quote strings, and quote atoms only when needed (see quoting subset below). **Compiled `"foo"` literals** are spelled with outer double quotes in WAM text (`quote_wam_constant/2`); the shared classifier still returns `atom(foo)` (no `string(_)` Class). JS consults `wam_constant_token_is_string/1` and builds `V.String`. Other runtimes intern the atom as before. Fact-source JSON/TSV values still intern as atoms. | | `library(assoc)` | **Implemented** as a Prolog `assoc/1` list of Key-Value pairs (not SWI's AVL tree). get/put/list/keys match SWI for unique-key maps. | | First-arg indexing | **Implemented.** `switch_on_constant` / `_fallthrough` / `_a2`, `switch_on_structure` / `_a2`, and `switch_on_term` / `_a2` jump to the matching clause group. Ground first-arg with a unique clause leaves no choice point (`deterministic/0`). Unbound first arg falls through to the try/retry/trust chain (no lost solutions). Exclusive miss fails; fallthrough variants keep the chain for variable-headed clauses. Dedicated `try`/`retry`/`trust` dispatch chains are emitted for multi-clause groups. | | Second-arg / deep indexing | A2 switches are implemented; deep (argument >2) indexing is not. | -| Lowered / functions emit mode | **Implemented.** `javascript_wam_resolve_emit_mode/2` accepts `interpreter` (default), `functions` (lower every eligible predicate), `mixed` (lower every eligible predicate, interpret the rest), and `mixed([P/A, ...])` (lower only the named ones). Eligible shapes: single-clause deterministic bodies; T4 all-clauses-inline (including nested `\+` via a depth-aware ITE fold); T5 first-arg constant dispatch; T6 hash dispatch (≥8 atom keys); structured ITE / negation / once. Ground facts intern via `copy_term` into `program.ground_memo`. Unsupported ops and Execute-of-other fall back to the interpreter rather than emitting wrong code. Interpreter-mode bytecode and wrappers are unchanged. | +| Lowered / functions emit mode | **Implemented.** `javascript_wam_resolve_emit_mode/2` accepts `interpreter` (default), `functions` (lower every eligible predicate), `mixed` (lower every eligible predicate, interpret the rest), and `mixed([P/A, ...])` (lower only the named ones). Eligible shapes: single-clause deterministic bodies; T4 all-clauses-inline (including nested `\+` via a depth-aware ITE fold, and nil/cons list recursion without a bound-A1 snapshot); T5 first-arg constant dispatch; T6 hash dispatch (≥8 atom keys); structured ITE / negation / once. Ground facts intern via `copy_term` into `program.ground_memo`. Execute of a user predicate preserves CP (`execute_user_isolated` or JS `return`). Execute/Call of a JS WAM builtin is `op_builtin`. Unsupported ops fall back to the interpreter rather than emitting wrong code. Interpreter-mode bytecode and wrappers are unchanged. | | CLI / runtime term parser | **Implemented.** Pratt reader: int/float/atom (incl. quoted)/var/list/`[H\|T]`/compound. CLI argv + `read_term_from_atom` / `atom_to_term` / `term_to_atom`. **`op/3`** updates the live infix/prefix/postfix tables (defaults cloned from ISO). Compile-time ops via `javascript_wam_ops/1`. Capability `native(parse_term)` via `INTEGRATION_PATCH.md` §7. | | Interpreter profiling | **Implemented.** Off by default (`Runtime._prof === null`). `UW_PROFILE=1` / `json` or `Runtime.profile(...)` writes a per-predicate table or JSON to **stderr**. Lowered tier: call counts only. See [Profiling (GP-PROF)](#profiling-gp-prof). | | `op/3` | **Implemented.** Infix `xfx`/`xfy`/`yfx`, prefix `fx`/`fy`, postfix `xf`/`yf`. Priority 0 removes. Name = atom or list of atoms. `current_op/3` is not implemented; ops are process-global. | @@ -385,5 +428,5 @@ classifier still returns `atom(_)`), then opt-in interpreter profiling (`UW_PROFILE=1` / `json`, stderr-only table or JSON; lowered = call counts), then the peerhailer CLI argparser through mixed emit (A2 + GP-PERF: `examples/cli_args/wamjs/`, 17/17 corpus + 5067-line differential vs the -JS oracle, 0 divergences, 1.48× vs the interpreter baseline). +JS oracle, 0 divergences; A2 4.639s → round-1 3.144s → GP-PERF-2 2.187s). Source-verified against SWI-Prolog as the oracle (2026-09-01).