Fix a code generation bug: it called

Estimated hours taken: 0.5 hours for the fix, 8 hours debugging
	(plus a similar amount of Zoltan's time debugging)

string_switch.m:
	Fix a code generation bug: it called
	code_info__generate_failure from the wrong spot, and so used
	the wrong exprn_info.  This meant that the code generated
	by generate_failure contained incorrect register shuffling,
	since it thought the variables were in different locations
	to where they really were.
This commit is contained in:
Fergus Henderson
1996-04-26 04:15:09 +00:00
parent 0d6497f527
commit a5a6fe26fb

View File

@@ -71,6 +71,12 @@ string_switch__generate(Cases, Var, CodeModel, _CanFail, EndLabel, Code) -->
code_info__release_reg(SlotR),
code_info__release_reg(StringR),
% Generate the code for when the hash lookup fails.
% This must be done before gen_hash_slots, since
% we want to use the exprn_info corresponding to
% the start of the switch, not to the end of the last case.
code_info__generate_failure(FailCode),
% Generate the code etc. for the hash table
%
string_switch__gen_hash_slots(0, TableSize, HashSlotsMap, CodeModel,
@@ -105,10 +111,6 @@ string_switch__generate(Cases, Var, CodeModel, _CanFail, EndLabel, Code) -->
"no match, so fail"
])
},
code_info__generate_failure(FailCodeA),
code_info__generate_forced_saves(FailCodeB),
{ FailCode = tree(FailCodeA, FailCodeB) },
code_info__remake_with_store_map,
{
JumpCode = node([
label(JumpLabel) -
@@ -120,7 +122,8 @@ string_switch__generate(Cases, Var, CodeModel, _CanFail, EndLabel, Code) -->
% Collect all the generated code fragments together
{ Code = tree(tree(VarCode, tree(HashLookupCode, FailCode)),
tree(JumpCode, SlotsCode))
}.
},
code_info__remake_with_store_map.
:- pred string_switch__hash_cases(cases_list, int, map(int, cases_list)).
:- mode string_switch__hash_cases(in, in, out) is det.