mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-24 05:43:53 +00:00
Estimated hours taken: 1 Branches: main Fix a bug reported by Samrith, which is that some of the files in benchmarks/progs/icfp2000, e.g. eval.m, got a compiler abort when compiled with -O0 --optimize-repeat=0 --optimize-saved-vars. This was because --optimize-saved-vars relied on jump optimization being done, but --optimize-repeat=0 disables jump optimization. compiler/handle_options.m: Make --optimize-repeat at least one if some other optimization requires the optimizations controlled by --optimize-repeat. compiler/optimize.m: compiler/use_local_vars.m: Rename some predicates to make their unqualified names more meaningful. Delete unnecessary module qualifications. Switch to using . instead of __ as module qualifier. compiler/mercury_compile.m: Conform to the change to optimize.m. compiler/modules.m: Rename a predicate to avoid a confusing overloading. compiler/compile_target_code.m: Conform to the change to modules.m. tests/valid/eval.m: New test case to check the fix. tests/valid/Mmakefile: Enable the new test case.
67 lines
1.5 KiB
Mathematica
67 lines
1.5 KiB
Mathematica
% This is a regression test. The compiler on 29 January, 2006 aborted with
|
|
% the message "Software Error: basic_block.m: Unexpected: extend_basic_blocks:
|
|
% fall through mismatch" when invoked with -O0 --optimize-repeat=0
|
|
% --optimize-saved-vars on this file.
|
|
%
|
|
% The contents of this file are an extract from eval.m in the CVS directory
|
|
% benchmarks/progs/icfp2000.
|
|
|
|
:- module eval.
|
|
:- interface.
|
|
|
|
:- import_module bool.
|
|
:- import_module list.
|
|
:- import_module io.
|
|
|
|
:- type token_list == list(token_group).
|
|
|
|
:- type token_group
|
|
---> single_token(token)
|
|
; function(token_list)
|
|
; array(token_list).
|
|
|
|
:- type token
|
|
---> identifier(string)
|
|
; binder(string)
|
|
; boolean(bool)
|
|
; number(int)
|
|
; string(string).
|
|
|
|
:- type code == token_list.
|
|
|
|
:- pred interpret(code::in, io__state::di, io__state::uo) is det.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
:- import_module map.
|
|
:- import_module array.
|
|
|
|
:- type value
|
|
---> boolean(bool)
|
|
; int(int)
|
|
; real(float)
|
|
; string(string).
|
|
|
|
:- type id == string.
|
|
|
|
:- type env == map(id, value).
|
|
|
|
:- type stack == list(value).
|
|
|
|
interpret(Code) -->
|
|
initial_setup(Env0, Stack0),
|
|
interpret(Code, Env0, Stack0, _Env, _Stack).
|
|
|
|
:- pred initial_setup(env::out, stack::out,
|
|
io__state::di, io__state::uo) is det.
|
|
|
|
initial_setup(Env, []) -->
|
|
{ map__init(Env) }.
|
|
|
|
:- pred interpret(code::in, env::in, stack::in,
|
|
env::out, stack::out, io__state::di, io__state::uo) is det.
|
|
|
|
interpret(_, Env, Stack, Env, Stack) --> [].
|