Remove dead code for generating fail/0 label The imports arrange for fail_0 to always be present so it is no longer necessary to look if fail/0 is used in a switch_on_term() opcode and insert the label during pl2am translation. Change-Id: I80c1c68227fb597560243ee56d5f7b7de2619ede
diff --git a/src/compiler/am2j.pl b/src/compiler/am2j.pl index d7a753e..577af04 100644 --- a/src/compiler/am2j.pl +++ b/src/compiler/am2j.pl
@@ -149,7 +149,6 @@ write_java0((Label: Instruction), In, Out) :- !, write_label(Label, Out), write_java0(Instruction, In, Out). -write_java0(label(fail/0), _, _) :- !. write_java0(label(L), _, Out) :- !, tab(Out, 4), write(Out, 'static final Operation '),
diff --git a/src/compiler/pl2am.pl b/src/compiler/pl2am.pl index 2cbe84c..95089ed 100644 --- a/src/compiler/pl2am.pl +++ b/src/compiler/pl2am.pl
@@ -168,7 +168,6 @@ :- dynamic file_name/1. :- dynamic dummy_clause_counter/1. :- dynamic pl2am_flag/1. -:- dynamic fail_flag/0. % used for generating label(fail/0) or not % :- module('com.googlecode.prolog_cafe.compiler.pl2am', [main/0,pl2am/1]). :- package 'com.googlecode.prolog_cafe.compiler.pl2am'. @@ -212,7 +211,6 @@ retractall(file_name(_)), retractall(dummy_clause_counter(_)), retractall(pl2am_flag(_)), - retractall(fail_flag), assert(file_name(File)), assert(dummy_clause_counter(0)), assert_compile_opts(Opts), @@ -592,9 +590,7 @@ % generates try, retry, trust, switch_on_term, and switch_on_hash {generate_switch0(Clauses, FA, Instrs, [])}, % generates sub-labels for BP - generate_bp_label(Instrs, FA+sub, 1, Ls0, SWTs), - % generates fail label (fail_flag may be asserted by generate_switch0/4) - {(retract(fail_flag) -> Ls1 = [label(fail/0)|Ls0] ; Ls1 = Ls0)}, + generate_bp_label(Instrs, FA+sub, 1, Ls1, SWTs), % generates labels for clauses {length(Clauses, N)}, {generate_cl_label(FA, 1, N, Ls2)}, @@ -629,7 +625,7 @@ generate_sw1(Is1, FA, Tag, L, PIs0, PIs). %%% 2nd. Indexing -generate_sw1([], _, _, fail/0, PIs, PIs) --> !, {assert_fail}. +generate_sw1([], _, _, fail/0, PIs, PIs) --> !. generate_sw1([I], _, _, L, PIs, PIs) --> !, {I = [L|_]}. generate_sw1(Is, FA, Tag, L, PIs0, PIs) --> {no_switch_on_hash(Is, Tag)}, @@ -657,7 +653,6 @@ generate_hash_tries([], _, _, []) --> !. generate_hash_tries([K:[]|LIs], L0, N, [K:fail/0|Ls]) --> !, - {assert_fail}, generate_hash_tries(LIs, L0, N, Ls). generate_hash_tries([K:[I]|LIs], L0, N, [K:L|Ls]) --> !, {I = [L|_]}, @@ -739,10 +734,6 @@ select_indices([_|Is0], Tag, Is) :- select_indices(Is0, Tag, Is). -%%% Assert Fail Flag -assert_fail:- clause(fail_flag, _), !. -assert_fail:- assert(fail_flag). - %%% Generate Labels for Backtrack Point generate_bp_label([], _, _, [], []) --> !. generate_bp_label([X|Xs], CL, N, Ls, [X|Hs]) -->