[m-rev.] diff: more cleanups
Zoltan Somogyi
zs at cs.mu.OZ.AU
Wed Mar 23 11:46:01 AEDT 2005
compiler/mlds_to_il.m:
compiler/mlds_to_managed.m:
Finish converting these modules to our current coding style. Use
predmode syntax and state variables as appropriate. Delete arguments
that were useful only when callers used DCGs.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.146
diff -u -b -r1.146 mlds_to_il.m
--- compiler/mlds_to_il.m 22 Mar 2005 06:40:11 -0000 1.146
+++ compiler/mlds_to_il.m 23 Mar 2005 00:06:39 -0000
@@ -338,7 +338,7 @@
% declare the foreign module as an assembly we
% reference
list__map((pred(F::in, I::out) is det :-
- mangle_foreign_code_module(ModuleName, F, N),
+ mangle_foreign_code_module(F, ModuleName, N),
I = mercury_import(compiler_visible_interface,
N)
),
@@ -1040,7 +1040,7 @@
Entity = function(_MaybePredProcId, Params, MaybeStatement,
Attributes),
- il_info_get_module_name(ModuleName, !Info),
+ il_info_get_module_name(!.Info, ModuleName),
% XXX We formerly returned a list of definitions, so we could put
% this term in a comment term, so we cannot currently do this.
@@ -1121,7 +1121,7 @@
% Retrieve the locals, put them in the enclosing
% scope.
- il_info_get_locals_list(Locals, !Info),
+ il_info_get_locals_list(!.Info, Locals),
InstrsTree2 = tree__list([
context_node(Context),
node(CtorInstrs),
@@ -1453,7 +1453,7 @@
true
;
( DataName = var(VarName) ->
- il_info_get_module_name(ModuleName, !Info),
+ il_info_get_module_name(!.Info, ModuleName),
Lval = var(qual(ModuleName, module_qual,
VarName), MLDSType),
get_load_store_lval_instrs(Lval,
@@ -1503,33 +1503,33 @@
% data).
data_initializer_to_instrs(init_struct(_StructType, InitList0), Type,
- AllocInstrs, InitInstrs) -->
+ AllocInstrs, InitInstrs, !Info) :-
- { InitList = flatten_inits(InitList0) },
+ InitList = flatten_inits(InitList0),
data_initializer_to_instrs(init_array(InitList), Type,
- AllocInstrs, InitInstrs).
+ AllocInstrs, InitInstrs, !Info).
% Put the array allocation in AllocInstrs.
% For sub-initializations, we don't worry about keeping AllocInstrs
% and InitInstrs apart, since we are only interested in top level
% allocations.
data_initializer_to_instrs(init_array(InitList), Type,
- AllocInstrs, InitInstrs) -->
+ AllocInstrs, InitInstrs, !Info) :-
%
% figure out the array element type
%
- DataRep =^ il_data_rep,
- ( { Type = mlds__array_type(ElemType0) } ->
- { ElemType = ElemType0 },
- { ILElemType = mlds_type_to_ilds_type(DataRep, ElemType) }
+ DataRep = !.Info ^ il_data_rep,
+ ( Type = mlds__array_type(ElemType0) ->
+ ElemType = ElemType0,
+ ILElemType = mlds_type_to_ilds_type(DataRep, ElemType)
;
% XXX we assume struct fields have type mlds__generic_type
% This is probably wrong for --high-level-data
- { ElemType = mlds__generic_type },
- { ILElemType = il_generic_type }
+ ElemType = mlds__generic_type,
+ ILElemType = il_generic_type
),
- { ILElemType = ilds__type(_, ILElemSimpleType) },
+ ILElemType = ilds__type(_, ILElemSimpleType),
% To initialize an array, we generate the following
% code:
@@ -1546,53 +1546,55 @@
%
% The initialization will leave the array on the stack.
%
- { AllocInstrs = node([
+ AllocInstrs = node([
ldc(int32, i(list__length(InitList))),
- newarr(ILElemType)]) },
- { AddInitializer =
+ newarr(ILElemType)]),
+ AddInitializer =
(pred(Init0::in, X0 - Tree0::in, (X0 + 1) - Tree::out,
- in, out) is det -->
+ Info0::in, Info::out) is det :-
% we may need to box the arguments
% XXX is this right?
- ( { ElemType = mlds__generic_type } ->
+ ( ElemType = mlds__generic_type ->
maybe_box_initializer(Init0, Init)
;
- { Init = Init0 }
+ Init = Init0
),
data_initializer_to_instrs(Init, ElemType,
- ATree1, ITree1),
- { Tree = tree(tree(Tree0, node(
+ ATree1, ITree1, Info0, Info),
+ Tree = tree(tree(Tree0, node(
[dup, ldc(int32, i(X0))])),
tree(tree(ATree1, ITree1),
node([stelem(ILElemSimpleType)]
- ))) }
- ) },
- list__foldl2(AddInitializer, InitList, 0 - empty, _ - InitInstrs).
-data_initializer_to_instrs(no_initializer, _, node([]), node([])) --> [].
+ )))
+ ),
+ list__foldl2(AddInitializer, InitList, 0 - empty, _ - InitInstrs,
+ !Info).
+data_initializer_to_instrs(no_initializer, _, node([]), node([]), !Info).
% If we are initializing an array or struct, we need to box
% all the things inside it.
-:- pred maybe_box_initializer(mlds__initializer, mlds__initializer,
- il_info, il_info).
-:- mode maybe_box_initializer(in, out, in, out) is det.
+:- pred maybe_box_initializer(mlds__initializer::in, mlds__initializer::out)
+ is det.
% nothing to do
-maybe_box_initializer(no_initializer, no_initializer) --> [].
+maybe_box_initializer(no_initializer, no_initializer).
% array already boxed
-maybe_box_initializer(init_array(X), init_array(X)) --> [].
+maybe_box_initializer(init_array(X), init_array(X)).
% struct already boxed
-maybe_box_initializer(init_struct(Type, X), init_struct(Type, X)) --> [].
+maybe_box_initializer(init_struct(Type, X), init_struct(Type, X)).
% single items need to be boxed
-maybe_box_initializer(init_obj(Rval), init_obj(NewRval)) -->
- { rval_to_type(Rval, BoxType) },
- { NewRval = unop(box(BoxType), Rval) }.
+maybe_box_initializer(init_obj(Rval), init_obj(NewRval)) :-
+ rval_to_type(Rval, BoxType),
+ NewRval = unop(box(BoxType), Rval).
% Code to flatten nested intializers.
:- func flatten_inits(list(mlds__initializer)) = list(mlds__initializer).
+
flatten_inits(Inits) = list__condense(list__map(flatten_init, Inits)).
:- func flatten_init(mlds__initializer) = list(mlds__initializer).
+
flatten_init(I) = Inits :-
( I = init_struct(_Type, Inits0) ->
Inits = flatten_inits(Inits0)
@@ -1607,126 +1609,126 @@
% Convert basic MLDS statements into IL.
%
-:- pred statements_to_il(list(mlds__statement), instr_tree, il_info, il_info).
-:- mode statements_to_il(in, out, in, out) is det.
-statements_to_il([], empty) --> [].
-statements_to_il([ S | Statements], tree(Instrs0, Instrs1)) -->
- statement_to_il(S, Instrs0),
- statements_to_il(Statements, Instrs1).
-
-:- pred statement_to_il(mlds__statement, instr_tree, il_info, il_info).
-:- mode statement_to_il(in, out, in, out) is det.
-
-statement_to_il(statement(block(Defns, Statements), Context),
- Instrs) -->
- il_info_get_module_name(ModuleName),
- il_info_get_next_block_id(BlockId),
- { list__map(defn_to_local(ModuleName), Defns, Locals) },
- il_info_add_locals(Locals),
+:- pred statements_to_il(list(mlds__statement)::in, instr_tree::out,
+ il_info::in, il_info::out) is det.
+
+statements_to_il([], empty, !Info).
+statements_to_il([HeadStmt | TailStmts], tree(HeadCode, TailCode), !Info) :-
+ statement_to_il(HeadStmt, HeadCode, !Info),
+ statements_to_il(TailStmts, TailCode, !Info).
+
+:- pred statement_to_il(mlds__statement::in, instr_tree::out,
+ il_info::in, il_info::out) is det.
+
+statement_to_il(statement(block(Defns, Statements), Context), Instrs, !Info) :-
+ il_info_get_module_name(!.Info, ModuleName),
+ il_info_get_next_block_id(BlockId, !Info),
+ list__map(defn_to_local(ModuleName), Defns, Locals),
+ il_info_add_locals(Locals, !Info),
list__foldl2(generate_defn_initializer, Defns, empty,
- InitInstrsTree),
- statements_to_il(Statements, BlockInstrs),
- DataRep =^ il_data_rep,
- { list__map((pred((K - V)::in, (K - W)::out) is det :-
- W = mlds_type_to_ilds_type(DataRep, V)), Locals, ILLocals) },
- { Scope = scope(ILLocals) },
- { Instrs = tree__list([
+ InitInstrsTree, !Info),
+ statements_to_il(Statements, BlockInstrs, !Info),
+ DataRep = !.Info ^ il_data_rep,
+ list__map((pred((K - V)::in, (K - W)::out) is det :-
+ W = mlds_type_to_ilds_type(DataRep, V)), Locals, ILLocals),
+ Scope = scope(ILLocals),
+ Instrs = tree__list([
context_node(Context),
instr_node(start_block(Scope, BlockId)),
InitInstrsTree,
comment_node("block body"),
BlockInstrs,
node([end_block(Scope, BlockId)])
- ]) },
- il_info_remove_locals(Locals).
+ ]) ,
+ il_info_remove_locals(Locals, !Info).
-statement_to_il(statement(atomic(Atomic), Context), Instrs) -->
- atomic_statement_to_il(Atomic, AtomicInstrs),
- { Instrs = tree(context_node(Context), AtomicInstrs) }.
+statement_to_il(statement(atomic(Atomic), Context), Instrs, !Info) :-
+ atomic_statement_to_il(Atomic, AtomicInstrs, !Info),
+ Instrs = tree(context_node(Context), AtomicInstrs).
statement_to_il(statement(call(Sig, Function, _This, Args, Returns, CallKind),
- Context), Instrs) -->
- VerifiableCode =^ verifiable_code,
- ByRefTailCalls =^ il_byref_tailcalls,
- MsCLR =^ support_ms_clr,
- RotorCLR =^ support_rotor_clr,
- DataRep =^ il_data_rep,
- { TypeParams = mlds_signature_to_ilds_type_params(DataRep, Sig) },
- { ReturnParam = mlds_signature_to_il_return_param(DataRep, Sig) },
- CallerSig =^ signature,
- { CallerSig = signature(_, CallerReturnParam, _) },
+ Context), Instrs, !Info) :-
+ VerifiableCode = !.Info ^ verifiable_code,
+ ByRefTailCalls = !.Info ^ il_byref_tailcalls,
+ MsCLR = !.Info ^ support_ms_clr,
+ RotorCLR = !.Info ^ support_rotor_clr,
+ DataRep = !.Info ^ il_data_rep,
+ TypeParams = mlds_signature_to_ilds_type_params(DataRep, Sig),
+ ReturnParam = mlds_signature_to_il_return_param(DataRep, Sig),
+ CallerSig = !.Info ^ signature,
+ CallerSig = signature(_, CallerReturnParam, _),
(
- { CallKind = tail_call ; CallKind = no_return_call },
+ ( CallKind = tail_call ; CallKind = no_return_call ),
% if --verifiable-code is enabled,
% and the arguments contain one or more byrefs,
% then don't emit the "tail." prefix,
% unless --il-byref-tailcalls is set
\+ (
- { VerifiableCode = yes },
+ VerifiableCode = yes,
some [Ref] (
- { list__member(Ref, TypeParams) },
- { Ref = ilds__type(_, '&'(_))
+ list__member(Ref, TypeParams),
+ ( Ref = ilds__type(_, '&'(_))
; Ref = ilds__type(_, '*'(_))
; Ref = ilds__type(_, refany)
- }
+ )
),
- { ByRefTailCalls = no }
+ ByRefTailCalls = no
),
% if --verifiable-code is enabled, then we must not output
% the "tail." prefix unless the callee return type is
% compatible with the caller return type
\+ (
- { VerifiableCode = yes },
- { ReturnParam \= CallerReturnParam }
+ VerifiableCode = yes,
+ ReturnParam \= CallerReturnParam
),
% In the MS CLR implementation the callee and caller return
% type of a tail call must be compatible even when we are
% using unverifiable code.
\+ (
- { MsCLR = yes },
- { ReturnParam \= CallerReturnParam }
+ MsCLR = yes,
+ ReturnParam \= CallerReturnParam
),
% The ROTOR implementation only allows "tail."
% annotations on direct calls (tail.call),
% not indirect calls (calli).
\+ (
- { RotorCLR = yes },
- { Function \= const(_) }
+ RotorCLR = yes,
+ Function \= const(_)
)
->
- { TailCallInstrs = [tailcall] },
+ TailCallInstrs = [tailcall],
% For calls marked with "tail.", we need a `ret'
% instruction immediately after the call (this is in fact
% needed for correct IL, not just for verifiability)
- { RetInstrs = [ret] },
- { ReturnsStoredInstrs = empty },
- { LoadMemRefInstrs = empty }
+ RetInstrs = [ret],
+ ReturnsStoredInstrs = empty,
+ LoadMemRefInstrs = empty
;
% For non-tail calls, we might have to load a memory
% reference before the call so we can store the result
% into the memory reference after the call.
- { TailCallInstrs = [] },
- { RetInstrs = [] },
+ TailCallInstrs = [],
+ RetInstrs = [],
get_all_load_store_lval_instrs(Returns,
- LoadMemRefInstrs, ReturnsStoredInstrs)
+ LoadMemRefInstrs, ReturnsStoredInstrs, !Info)
),
- list__map_foldl(load, Args, ArgsLoadInstrsTrees),
- { ArgsLoadInstrs = tree__list(ArgsLoadInstrsTrees) },
- ( { Function = const(_) } ->
- { FunctionLoadInstrs = empty },
- { rval_to_function(Function, MemberName) },
- { Instrs0 = [call(methoddef(call_conv(no, default),
- ReturnParam, MemberName, TypeParams))] }
- ;
- load(Function, FunctionLoadInstrs),
- { list__length(TypeParams, Length) },
- { list__duplicate(Length, no, NoList) },
- { assoc_list__from_corresponding_lists(
- TypeParams, NoList, ParamsList) },
- { Instrs0 = [calli(signature(call_conv(no, default),
- ReturnParam, ParamsList))] }
+ list__map_foldl(load, Args, ArgsLoadInstrsTrees, !Info),
+ ArgsLoadInstrs = tree__list(ArgsLoadInstrsTrees),
+ ( Function = const(Const) ->
+ FunctionLoadInstrs = empty,
+ const_rval_to_function(Const, MemberName),
+ Instrs0 = [call(methoddef(call_conv(no, default),
+ ReturnParam, MemberName, TypeParams))]
+ ;
+ load(Function, FunctionLoadInstrs, !Info),
+ list__length(TypeParams, Length),
+ list__duplicate(Length, no, NoList),
+ assoc_list__from_corresponding_lists(
+ TypeParams, NoList, ParamsList),
+ Instrs0 = [calli(signature(call_conv(no, default),
+ ReturnParam, ParamsList))]
),
- { Instrs = tree__list([
+ Instrs = tree__list([
context_node(Context),
comment_node("call"),
LoadMemRefInstrs,
@@ -1736,15 +1738,15 @@
node(Instrs0),
node(RetInstrs),
ReturnsStoredInstrs
- ]) }.
+ ]).
statement_to_il(statement(if_then_else(Condition, ThenCase, ElseCase),
- Context), Instrs) -->
- generate_condition(Condition, ConditionInstrs, ElseLabel),
- il_info_make_next_label(DoneLabel),
- statement_to_il(ThenCase, ThenInstrs),
- maybe_map_fold(statement_to_il, ElseCase, empty, ElseInstrs),
- { Instrs = tree__list([
+ Context), Instrs, !Info) :-
+ generate_condition(Condition, ConditionInstrs, ElseLabel, !Info),
+ il_info_make_next_label(DoneLabel, !Info),
+ statement_to_il(ThenCase, ThenInstrs, !Info),
+ maybe_map_fold(statement_to_il, ElseCase, empty, ElseInstrs, !Info),
+ Instrs = tree__list([
context_node(Context),
comment_node("if then else"),
ConditionInstrs,
@@ -1756,21 +1758,22 @@
ElseInstrs,
comment_node("end if then else"),
instr_node(label(DoneLabel))
- ]) }.
+ ]).
statement_to_il(statement(switch(_Type, _Val, _Range, _Cases, _Default),
- _Context), _Instrs) -->
+ _Context), _Instrs, !Info) :-
% The IL back-end only supports computed_gotos and if-then-else chains;
% the MLDS code generator should either avoid generating MLDS switches,
% or should transform them into computed_gotos or if-then-else chains.
- { error("mlds_to_il.m: `switch' not supported") }.
+ error("mlds_to_il.m: `switch' not supported").
statement_to_il(statement(while(Condition, Body, AtLeastOnce),
- Context), Instrs) -->
- generate_condition(Condition, ConditionInstrs, EndLabel),
- il_info_make_next_label(StartLabel),
- statement_to_il(Body, BodyInstrs),
- { AtLeastOnce = no,
+ Context), Instrs, !Info) :-
+ generate_condition(Condition, ConditionInstrs, EndLabel, !Info),
+ il_info_make_next_label(StartLabel, !Info),
+ statement_to_il(Body, BodyInstrs, !Info),
+ (
+ AtLeastOnce = no,
Instrs = tree__list([
context_node(Context),
comment_node("while"),
@@ -1780,7 +1783,8 @@
instr_node(br(label_target(StartLabel))),
instr_node(label(EndLabel))
])
- ; AtLeastOnce = yes,
+ ;
+ AtLeastOnce = yes,
% XXX this generates a branch over branch which
% is suboptimal.
Instrs = tree__list([
@@ -1792,46 +1796,48 @@
instr_node(br(label_target(StartLabel))),
instr_node(label(EndLabel))
])
+ ).
- }.
-
-statement_to_il(statement(return(Rvals), Context), Instrs) -->
- ( { Rvals = [Rval] } ->
- load(Rval, LoadInstrs),
- { Instrs = tree__list([
+statement_to_il(statement(return(Rvals), Context), Instrs, !Info) :-
+ (
+ Rvals = [Rval],
+ load(Rval, LoadInstrs, !Info),
+ Instrs = tree__list([
context_node(Context),
LoadInstrs,
- instr_node(ret)]) }
- ; { Rvals = [] } ->
- { unexpected(this_file, "empty list of return values") }
+ instr_node(ret)])
;
+ Rvals = [],
+ unexpected(this_file, "empty list of return values")
+ ;
+ Rvals = [_, _ | _],
% MS IL doesn't support multiple return values
- { sorry(this_file, "multiple return values") }
+ sorry(this_file, "multiple return values")
).
-statement_to_il(statement(label(Label), Context), Instrs) -->
- { string__format("label %s", [s(Label)], Comment) },
- { Instrs = node([
+statement_to_il(statement(label(Label), Context), Instrs, !Info) :-
+ string__format("label %s", [s(Label)], Comment),
+ Instrs = node([
comment(Comment),
context_instr(Context),
label(Label)
- ]) }.
+ ]).
-statement_to_il(statement(goto(label(Label)), Context), Instrs) -->
- { string__format("goto %s", [s(Label)], Comment) },
- { Instrs = node([
+statement_to_il(statement(goto(label(Label)), Context), Instrs, !Info) :-
+ string__format("goto %s", [s(Label)], Comment),
+ Instrs = node([
comment(Comment),
context_instr(Context),
br(label_target(Label))
- ]) }.
+ ]).
-statement_to_il(statement(goto(break), _Context), _Instrs) -->
- { sorry(this_file, "break") }.
+statement_to_il(statement(goto(break), _Context), _Instrs, !Info) :-
+ sorry(this_file, "break").
-statement_to_il(statement(goto(continue), _Context), _Instrs) -->
- { sorry(this_file, "continue") }.
+statement_to_il(statement(goto(continue), _Context), _Instrs, !Info) :-
+ sorry(this_file, "continue").
-statement_to_il(statement(do_commit(_Ref), Context), Instrs) -->
+statement_to_il(statement(do_commit(_Ref), Context), Instrs, !Info) :-
% For commits, we use exception handling.
%
@@ -1847,16 +1853,16 @@
% throw
%
- { NewObjInstr = newobj_constructor(il_commit_class_name, []) },
- { Instrs = tree__list([
+ NewObjInstr = newobj_constructor(il_commit_class_name, []),
+ Instrs = tree__list([
context_node(Context),
comment_node("do_commit/1"),
instr_node(NewObjInstr),
instr_node(throw)
- ]) }.
+ ]).
statement_to_il(statement(try_commit(_Ref, GoalToTry, CommitHandlerGoal),
- Context), Instrs) -->
+ Context), Instrs, !Info) :-
% For commits, we use exception handling.
%
@@ -1874,14 +1880,14 @@
% label1:
%
- il_info_get_next_block_id(TryBlockId),
- statement_to_il(GoalToTry, GoalInstrsTree),
- il_info_get_next_block_id(CatchBlockId),
- statement_to_il(CommitHandlerGoal, HandlerInstrsTree),
- il_info_make_next_label(DoneLabel),
+ il_info_get_next_block_id(TryBlockId, !Info),
+ statement_to_il(GoalToTry, GoalInstrsTree, !Info),
+ il_info_get_next_block_id(CatchBlockId, !Info),
+ statement_to_il(CommitHandlerGoal, HandlerInstrsTree, !Info),
+ il_info_make_next_label(DoneLabel, !Info),
- { ClassName = il_commit_class_name },
- { Instrs = tree__list([
+ ClassName = il_commit_class_name,
+ Instrs = tree__list([
context_node(Context),
comment_node("try_commit/3"),
@@ -1897,123 +1903,127 @@
instr_node(leave(label_target(DoneLabel))),
instr_node(end_block(catch(ClassName), CatchBlockId)),
instr_node(label(DoneLabel))
-
- ]) }.
+ ]).
statement_to_il(statement(computed_goto(Rval, MLDSLabels), Context),
- Instrs) -->
- load(Rval, RvalLoadInstrs),
- { Targets = list__map(func(L) = label_target(L), MLDSLabels) },
- { Instrs = tree__list([
+ Instrs, !Info) :-
+ load(Rval, RvalLoadInstrs, !Info),
+ Targets = list__map(func(L) = label_target(L), MLDSLabels),
+ Instrs = tree__list([
context_node(Context),
comment_node("computed goto"),
RvalLoadInstrs,
instr_node(switch(Targets))
- ]) }.
+ ]).
-:- pred atomic_statement_to_il(mlds__atomic_statement, instr_tree,
- il_info, il_info).
-:- mode atomic_statement_to_il(in, out, in, out) is det.
-
-atomic_statement_to_il(gc_check, node(Instrs)) -->
- { Instrs = [comment(
- "gc check -- not relevant for this backend")] }.
-atomic_statement_to_il(mark_hp(_), node(Instrs)) -->
- { Instrs = [comment(
- "mark hp -- not relevant for this backend")] }.
-atomic_statement_to_il(restore_hp(_), node(Instrs)) -->
- { Instrs = [comment(
- "restore hp -- not relevant for this backend")] }.
+:- pred atomic_statement_to_il(mlds__atomic_statement::in, instr_tree::out,
+ il_info::in, il_info::out) is det.
+
+atomic_statement_to_il(gc_check, node(Instrs), !Info) :-
+ Instrs = [comment(
+ "gc check -- not relevant for this backend")].
+atomic_statement_to_il(mark_hp(_), node(Instrs), !Info) :-
+ Instrs = [comment(
+ "mark hp -- not relevant for this backend")].
+atomic_statement_to_il(restore_hp(_), node(Instrs), !Info) :-
+ Instrs = [comment(
+ "restore hp -- not relevant for this backend")].
atomic_statement_to_il(outline_foreign_proc(Lang, _, ReturnLvals, _Code),
- Instrs) -->
- il_info_get_module_name(ModuleName),
- ( no =^ method_foreign_lang ->
- =(Info),
- ^ method_foreign_lang := yes(Lang),
- ^ file_foreign_langs :=
- set__insert(Info ^ file_foreign_langs, Lang),
- { mangle_foreign_code_module(ModuleName, Lang,
- OutlineLangModuleName) },
- { ClassName = mlds_module_name_to_class_name(
- OutlineLangModuleName) },
- signature(_, RetType, Params) =^ signature,
+ Instrs, !Info) :-
+ il_info_get_module_name(!.Info, ModuleName),
+ (
+ !.Info ^ method_foreign_lang = no,
+ Info0 = !.Info,
+ !:Info = !.Info ^ method_foreign_lang := yes(Lang),
+ !:Info = !.Info ^ file_foreign_langs :=
+ set__insert(Info0 ^ file_foreign_langs, Lang),
+ mangle_foreign_code_module(Lang, ModuleName,
+ OutlineLangModuleName),
+ ClassName = mlds_module_name_to_class_name(
+ OutlineLangModuleName),
+ signature(_, RetType, Params) = !.Info ^ signature,
- ( { ReturnLvals = [] } ->
+ (
+ ReturnLvals = [],
% If there is a return type, but no return value, it
% must be a semidet predicate so put it in
% SUCCESS_INDICATOR.
% XXX it would be better to get the code generator
% to tell us this is the case directly
- { LoadInstrs = empty },
- { RetType = void ->
+ LoadInstrs = empty,
+ ( RetType = void ->
StoreInstrs = empty
;
StoreInstrs = instr_node(
stloc(name("SUCCESS_INDICATOR")))
- }
- ; { ReturnLvals = [ReturnLval] } ->
+ )
+ ;
+ ReturnLvals = [ReturnLval],
get_load_store_lval_instrs(ReturnLval,
- LoadInstrs, StoreInstrs)
+ LoadInstrs, StoreInstrs, !Info)
;
- { sorry(this_file, "multiple return values") }
+ ReturnLvals = [_, _ | _],
+ sorry(this_file, "multiple return values")
),
- MethodName =^ method_name,
- { assoc_list__keys(Params, TypeParams) },
- { list__map_foldl((pred(_::in, Instr::out,
+ MethodName = !.Info ^ method_name,
+ assoc_list__keys(Params, TypeParams),
+ list__map_foldl((pred(_::in, Instr::out,
Num::in, Num + 1::out) is det :-
Instr = ldarg(index(Num))),
- TypeParams, LoadArgInstrs, 0, _) },
- { Instrs = tree__list([
+ TypeParams, LoadArgInstrs, 0, _),
+ Instrs = tree__list([
comment_node(
- "outline foreign proc -- call handwritten version"),
+ "outline foreign proc -- " ++
+ "call handwritten version"),
LoadInstrs,
node(LoadArgInstrs),
instr_node(call(get_static_methodref(
ClassName, MethodName, RetType, TypeParams))),
StoreInstrs
- ]) }
+ ])
;
- { Instrs = comment_node(
- "outline foreign proc -- already called") }
+ !.Info ^ method_foreign_lang = yes(_),
+ Instrs = comment_node("outline foreign proc -- already called")
).
-atomic_statement_to_il(inline_target_code(lang_il, Code), Instrs) -->
- { Instrs = inline_code_to_il_asm(Code) }.
-atomic_statement_to_il(inline_target_code(lang_C, _Code), _Instrs) -->
- { unexpected(this_file, "lang_C") }.
-atomic_statement_to_il(inline_target_code(lang_java, _Code), _Instrs) -->
- { unexpected(this_file, "lang_java") }.
-atomic_statement_to_il(inline_target_code(lang_java_bytecode, _), _) -->
- { unexpected(this_file, "lang_java_bytecode") }.
-atomic_statement_to_il(inline_target_code(lang_java_asm, _), _) -->
- { unexpected(this_file, "lang_java_asm") }.
-atomic_statement_to_il(inline_target_code(lang_asm, _), _) -->
- { unexpected(this_file, "lang_asm") }.
-atomic_statement_to_il(inline_target_code(lang_GNU_C, _), _) -->
- { unexpected(this_file, "lang_GNU_C") }.
-atomic_statement_to_il(inline_target_code(lang_C_minus_minus, _), _) -->
- { unexpected(this_file, "lang_C_minus_minus") }.
-
-atomic_statement_to_il(trail_op(_), node(Instrs)) -->
- { Instrs = [comment(
- "... some trail operation ... (unimplemented)")] }.
+atomic_statement_to_il(inline_target_code(lang_il, Code), Instrs, !Info) :-
+ Instrs = inline_code_to_il_asm(Code).
+atomic_statement_to_il(inline_target_code(lang_C, _Code), _Instrs, !Info) :-
+ unexpected(this_file, "lang_C").
+atomic_statement_to_il(inline_target_code(lang_java, _Code), _Instrs, !Info) :-
+ unexpected(this_file, "lang_java").
+atomic_statement_to_il(inline_target_code(lang_java_bytecode, _), _, !Info) :-
+ unexpected(this_file, "lang_java_bytecode").
+atomic_statement_to_il(inline_target_code(lang_java_asm, _), _, !Info) :-
+ unexpected(this_file, "lang_java_asm").
+atomic_statement_to_il(inline_target_code(lang_asm, _), _, !Info) :-
+ unexpected(this_file, "lang_asm").
+atomic_statement_to_il(inline_target_code(lang_GNU_C, _), _, !Info) :-
+ unexpected(this_file, "lang_GNU_C").
+atomic_statement_to_il(inline_target_code(lang_C_minus_minus, _), _, !Info) :-
+ unexpected(this_file, "lang_C_minus_minus").
+
+atomic_statement_to_il(trail_op(_), node(Instrs), !Info) :-
+ Instrs = [comment(
+ "... some trail operation ... (unimplemented)")].
-atomic_statement_to_il(assign(Lval, Rval), Instrs) -->
+atomic_statement_to_il(assign(Lval, Rval), Instrs, !Info) :-
% do assignments by loading the rval and storing
% to the lval
- load(Rval, LoadRvalInstrs),
- get_load_store_lval_instrs(Lval, LoadMemRefInstrs, StoreLvalInstrs),
- { Instrs = tree__list([
+ load(Rval, LoadRvalInstrs, !Info),
+ get_load_store_lval_instrs(Lval, LoadMemRefInstrs, StoreLvalInstrs,
+ !Info),
+ Instrs = tree__list([
comment_node("assign"),
LoadMemRefInstrs,
LoadRvalInstrs,
StoreLvalInstrs
- ]) }.
-atomic_statement_to_il(comment(Comment), Instrs) -->
- { Instrs = node([comment(Comment)]) }.
+ ]).
+atomic_statement_to_il(comment(Comment), Instrs, !Info) :-
+ Instrs = node([comment(Comment)]).
-atomic_statement_to_il(delete_object(Target), Instrs) -->
+atomic_statement_to_il(delete_object(Target), Instrs, !Info) :-
% XXX we assume the code generator knows what it is
% doing and is only going to delete real objects (e.g.
% reference types). It would perhaps be prudent to
@@ -2023,14 +2033,14 @@
% We implement delete_object by storing null in the
% lval, which hopefully gives the garbage collector a good
% solid hint that this storage is no longer required.
- get_load_store_lval_instrs(Target, LoadInstrs, StoreInstrs),
- { Instrs = tree__list([LoadInstrs, instr_node(ldnull), StoreInstrs]) }.
+ get_load_store_lval_instrs(Target, LoadInstrs, StoreInstrs, !Info),
+ Instrs = tree__list([LoadInstrs, instr_node(ldnull), StoreInstrs]).
atomic_statement_to_il(new_object(Target, _MaybeTag, HasSecTag, Type, Size,
- MaybeCtorName, Args0, ArgTypes0), Instrs) -->
- DataRep =^ il_data_rep,
+ MaybeCtorName, Args0, ArgTypes0), Instrs, !Info) :-
+ DataRep = !.Info ^ il_data_rep,
+ (
(
- {
Type = mlds__generic_env_ptr_type
;
Type = mlds__class_type(_, _, mlds__class)
@@ -2039,7 +2049,7 @@
Type = mlds__mercury_type(MercuryType,
user_ctor_type, _),
\+ type_needs_lowlevel_rep(il, MercuryType)
- }
+ )
->
% If this is a class, we should call the
% constructor. (This is needed for nondet environment
@@ -2052,19 +2062,20 @@
% call ClassName::.ctor
% ... store to memory reference ...
%
- { ClassName0 = mlds_type_to_ilds_class_name(DataRep, Type) },
- ( { MaybeCtorName = yes(QualifiedCtorName) } ->
- { QualifiedCtorName = qual(_, _,
- ctor_id(CtorName, CtorArity)) },
- { CtorType = entity_name_to_ilds_id(
- type(CtorName, CtorArity)) },
- { ClassName = append_nested_class_name(ClassName0,
- [CtorType]) }
+ ClassName0 = mlds_type_to_ilds_class_name(DataRep, Type),
+ ( MaybeCtorName = yes(QualifiedCtorName) ->
+ QualifiedCtorName = qual(_, _,
+ ctor_id(CtorName, CtorArity)),
+ CtorType = entity_name_to_ilds_id(
+ type(CtorName, CtorArity)),
+ ClassName = append_nested_class_name(ClassName0,
+ [CtorType])
;
- { ClassName = ClassName0 }
+ ClassName = ClassName0
),
% Skip the secondary tag, if any
- { HasSecTag = yes ->
+ (
+ HasSecTag = yes,
(
ArgTypes0 = [_SecondaryTag | ArgTypes1],
Args0 = [_SecondaryTagVal | Args1]
@@ -2076,23 +2087,24 @@
"newobj without secondary tag")
)
;
+ HasSecTag = no,
ArgTypes = ArgTypes0,
Args = Args0
- },
- { ILArgTypes = list__map(mlds_type_to_ilds_type(DataRep),
- ArgTypes) },
- list__map_foldl(load, Args, ArgsLoadInstrsTrees),
- { ArgsLoadInstrs = tree__list(ArgsLoadInstrsTrees) },
+ ),
+ ILArgTypes = list__map(mlds_type_to_ilds_type(DataRep),
+ ArgTypes),
+ list__map_foldl(load, Args, ArgsLoadInstrsTrees, !Info),
+ ArgsLoadInstrs = tree__list(ArgsLoadInstrsTrees),
get_load_store_lval_instrs(Target, LoadMemRefInstrs,
- StoreLvalInstrs),
- { CallCtor = newobj_constructor(ClassName, ILArgTypes) },
- { Instrs = tree__list([
+ StoreLvalInstrs, !Info),
+ CallCtor = newobj_constructor(ClassName, ILArgTypes),
+ Instrs = tree__list([
LoadMemRefInstrs,
comment_node("new object (call constructor)"),
ArgsLoadInstrs,
instr_node(CallCtor),
StoreLvalInstrs
- ]) }
+ ])
;
% Otherwise this is a generic mercury object -- we
% use an array of System::Object to represent
@@ -2123,8 +2135,8 @@
% (XXX we do almost exactly the same code when
% initializing array data structures -- we
% should reuse that code.
- { LoadInArray = (pred(Rval::in, I::out, Arg0::in,
- Arg::out) is det :-
+ LoadInArray = (pred(Rval::in, I::out, Arg0::in, Arg::out)
+ is det :-
Arg0 = Index - S0,
I0 = instr_node(dup),
load(const(int_const(Index)), I1, S0, S1),
@@ -2147,38 +2159,39 @@
I3 = instr_node(stelem(il_generic_simple_type)),
I = tree__list([I0, I1, I2, I3]),
Arg = (Index + 1) - S
- ) },
- =(State0),
- { list__map_foldl(LoadInArray, Args0, ArgsLoadInstrsTrees,
- 0 - State0, _ - State) },
- { ArgsLoadInstrs = tree__list(ArgsLoadInstrsTrees) },
- dcg_set(State),
+ ),
+ list__map_foldl(LoadInArray, Args0, ArgsLoadInstrsTrees,
+ 0 - !.Info, _ - !:Info),
+ ArgsLoadInstrs = tree__list(ArgsLoadInstrsTrees),
% Get the instructions to load and store the
% target.
get_load_store_lval_instrs(Target, LoadMemRefInstrs,
- StoreLvalInstrs),
+ StoreLvalInstrs, !Info),
- { Size = yes(SizeInWordsRval0) ->
+ (
+ Size = yes(SizeInWordsRval0),
SizeInWordsRval = SizeInWordsRval0
;
+ Size = no,
% XXX do we need to handle this case?
% I think it's needed for --high-level-data
error("unknown size in MLDS new_object")
- },
- load(SizeInWordsRval, LoadSizeInstrs),
+ ),
+ load(SizeInWordsRval, LoadSizeInstrs, !Info),
- { Instrs = tree__list([
+ Instrs = tree__list([
LoadMemRefInstrs,
comment_node("new object"),
LoadSizeInstrs,
instr_node(newarr(il_generic_type)),
ArgsLoadInstrs,
StoreLvalInstrs
- ]) }
+ ])
).
:- func inline_code_to_il_asm(list(target_code_component)) = instr_tree.
+
inline_code_to_il_asm([]) = empty.
inline_code_to_il_asm([T | Ts]) = tree(Instrs, Rest) :-
(
@@ -2198,9 +2211,12 @@
)
;
T = raw_target_code(Code, Attrs),
- ( yes(max_stack_size(N)) = get_max_stack_attribute(Attrs) ->
+ MaybeMaxStack = get_max_stack_attribute(Attrs),
+ (
+ MaybeMaxStack = yes(max_stack_size(N)),
Instrs = instr_node(il_asm_code(Code, N))
;
+ MaybeMaxStack = no,
error(this_file ++ ": max_stack_size not set")
)
;
@@ -2217,18 +2233,21 @@
:- func get_max_stack_attribute(target_code_attributes) =
maybe(target_code_attribute).
+
get_max_stack_attribute([]) = no.
get_max_stack_attribute([X | _Xs]) = yes(X) :- X = max_stack_size(_).
-:- pred get_all_load_store_lval_instrs(list(lval), instr_tree, instr_tree,
- il_info, il_info).
-:- mode get_all_load_store_lval_instrs(in, out, out, in, out) is det.
-get_all_load_store_lval_instrs([], empty, empty) --> [].
+:- pred get_all_load_store_lval_instrs(list(lval)::in,
+ instr_tree::out, instr_tree::out, il_info::in, il_info::out) is det.
+
+get_all_load_store_lval_instrs([], empty, empty, !Info).
get_all_load_store_lval_instrs([Lval | Lvals],
tree(LoadMemRefNode, LoadMemRefTree),
- tree(StoreLvalNode, StoreLvalTree)) -->
- get_load_store_lval_instrs(Lval, LoadMemRefNode, StoreLvalNode),
- get_all_load_store_lval_instrs(Lvals, LoadMemRefTree, StoreLvalTree).
+ tree(StoreLvalNode, StoreLvalTree), !Info) :-
+ get_load_store_lval_instrs(Lval, LoadMemRefNode, StoreLvalNode,
+ !Info),
+ get_all_load_store_lval_instrs(Lvals, LoadMemRefTree, StoreLvalTree,
+ !Info).
% Some lvals need to be loaded before you load the rval.
% XXX It would be much better if this took the lval and the rval and
@@ -2237,48 +2256,43 @@
% the rval in between.
% The predicate `store' should probably take the lval and the
% rval and do all of this at once.
-:- pred get_load_store_lval_instrs(lval, instr_tree, instr_tree, il_info,
- il_info).
-:- mode get_load_store_lval_instrs(in, out, out, in, out) is det.
-get_load_store_lval_instrs(Lval, LoadMemRefInstrs,
- StoreLvalInstrs) -->
- DataRep =^ il_data_rep,
- ( { Lval = mem_ref(Rval0, MLDS_Type) } ->
- load(Rval0, LoadMemRefInstrs),
- { SimpleType = mlds_type_to_ilds_simple_type(DataRep,
- MLDS_Type) },
- { StoreLvalInstrs = instr_node(stind(SimpleType)) }
- ; { Lval = field(_MaybeTag, FieldRval, FieldNum, FieldType,
- ClassType) } ->
- { ClassILType = mlds_type_to_ilds_type(DataRep, ClassType) },
- ( { ClassILType = ilds__type(_, '[]'(_, _)) } ->
- ( { FieldNum = offset(OffsetRval) },
- { FieldILType = mlds_type_to_ilds_simple_type(
- DataRep, FieldType) },
- load(FieldRval, LoadArrayRval),
- load(OffsetRval, LoadIndexRval),
- { LoadMemRefInstrs = tree__list([
- LoadArrayRval,
- LoadIndexRval]) },
- { StoreLvalInstrs = node(
- [stelem(FieldILType)]) }
- ; { FieldNum = named_field(_, _) },
- { unexpected(this_file,
- "named_field for a type with an array representation.") }
- )
- ;
- { get_fieldref(DataRep, FieldNum, FieldType, ClassType,
- FieldRef, CastClassInstrs) },
- load(FieldRval, LoadMemRefInstrs0),
- { LoadMemRefInstrs = tree__list([
+:- pred get_load_store_lval_instrs(lval::in, instr_tree::out, instr_tree::out,
+ il_info::in, il_info::out) is det.
+
+get_load_store_lval_instrs(Lval, LoadMemRefInstrs, StoreLvalInstrs, !Info) :-
+ DataRep = !.Info ^ il_data_rep,
+ ( Lval = mem_ref(Rval0, MLDS_Type) ->
+ load(Rval0, LoadMemRefInstrs, !Info),
+ SimpleType = mlds_type_to_ilds_simple_type(DataRep, MLDS_Type),
+ StoreLvalInstrs = instr_node(stind(SimpleType))
+ ; Lval = field(_MaybeTag, FieldRval, FieldNum, FieldType, ClassType) ->
+ ClassILType = mlds_type_to_ilds_type(DataRep, ClassType),
+ ( ClassILType = ilds__type(_, '[]'(_, _)) ->
+ ( FieldNum = offset(OffsetRval),
+ FieldILType = mlds_type_to_ilds_simple_type(
+ DataRep, FieldType),
+ load(FieldRval, LoadArrayRval, !Info),
+ load(OffsetRval, LoadIndexRval, !Info),
+ LoadMemRefInstrs = tree__list([
+ LoadArrayRval, LoadIndexRval]),
+ StoreLvalInstrs = node([stelem(FieldILType)])
+ ; FieldNum = named_field(_, _),
+ unexpected(this_file, "named_field for " ++
+ "a type with an array representation.")
+ )
+ ;
+ get_fieldref(DataRep, FieldNum, FieldType, ClassType,
+ FieldRef, CastClassInstrs),
+ load(FieldRval, LoadMemRefInstrs0, !Info),
+ LoadMemRefInstrs = tree__list([
LoadMemRefInstrs0,
- CastClassInstrs]) },
- { StoreLvalInstrs = instr_node(stfld(FieldRef)) }
+ CastClassInstrs]),
+ StoreLvalInstrs = instr_node(stfld(FieldRef))
)
;
- { LoadMemRefInstrs = empty },
- store(Lval, StoreLvalInstrs)
+ LoadMemRefInstrs = empty,
+ store(Lval, StoreLvalInstrs, !Info)
).
%-----------------------------------------------------------------------------%
@@ -2292,168 +2306,172 @@
% sandwich the calculation of the rval in between the two.
%
-:- pred load(mlds__rval, instr_tree, il_info, il_info) is det.
-:- mode load(in, out, in, out) is det.
+:- pred load(mlds__rval::in, instr_tree::out, il_info::in, il_info::out)
+ is det.
-load(lval(Lval), Instrs) -->
- DataRep =^ il_data_rep,
- ( { Lval = var(Var, VarType) },
- { mangle_mlds_var(Var, MangledVarStr) },
- =(Info),
- { is_local(MangledVarStr, Info) ->
+load(lval(Lval), Instrs, !Info) :-
+ DataRep = !.Info ^ il_data_rep,
+ ( Lval = var(Var, VarType),
+ mangle_mlds_var(Var, MangledVarStr),
+ ( is_local(MangledVarStr, !.Info) ->
Instrs = instr_node(ldloc(name(MangledVarStr)))
- ; is_argument(MangledVarStr, Info) ->
+ ; is_argument(MangledVarStr, !.Info) ->
Instrs = instr_node(ldarg(name(MangledVarStr)))
- ; is_local_field(Var, VarType, Info, FieldRef) ->
+ ; is_local_field(Var, VarType, !.Info, FieldRef) ->
Instrs = instr_node(ldsfld(FieldRef))
;
FieldRef = make_static_fieldref(DataRep, Var, VarType),
Instrs = instr_node(ldsfld(FieldRef))
- }
- ; { Lval = field(_MaybeTag, Rval, FieldNum, FieldType, ClassType) },
- load(Rval, RvalLoadInstrs),
- ( { FieldNum = offset(OffSet) } ->
- { SimpleFieldType = mlds_type_to_ilds_simple_type(
- DataRep, FieldType) },
- load(OffSet, OffSetLoadInstrs),
- { CastClassInstrs = empty },
- { LoadInstruction = ldelem(SimpleFieldType) }
- ;
- { get_fieldref(DataRep, FieldNum, FieldType, ClassType,
- FieldRef, CastClassInstrs) },
- { LoadInstruction = ldfld(FieldRef) },
- { OffSetLoadInstrs = empty }
+ )
+ ; Lval = field(_MaybeTag, Rval, FieldNum, FieldType, ClassType),
+ load(Rval, RvalLoadInstrs, !Info),
+ ( FieldNum = offset(OffSet) ->
+ SimpleFieldType = mlds_type_to_ilds_simple_type(
+ DataRep, FieldType),
+ load(OffSet, OffSetLoadInstrs, !Info),
+ CastClassInstrs = empty,
+ LoadInstruction = ldelem(SimpleFieldType)
+ ;
+ get_fieldref(DataRep, FieldNum, FieldType, ClassType,
+ FieldRef, CastClassInstrs),
+ LoadInstruction = ldfld(FieldRef),
+ OffSetLoadInstrs = empty
),
- { Instrs = tree__list([
+ Instrs = tree__list([
RvalLoadInstrs,
CastClassInstrs,
OffSetLoadInstrs,
instr_node(LoadInstruction)
- ]) }
- ; { Lval = mem_ref(Rval, MLDS_Type) },
- { SimpleType = mlds_type_to_ilds_simple_type(DataRep,
- MLDS_Type) },
- load(Rval, RvalLoadInstrs),
- { Instrs = tree__list([
+ ])
+ ; Lval = mem_ref(Rval, MLDS_Type),
+ SimpleType = mlds_type_to_ilds_simple_type(DataRep, MLDS_Type),
+ load(Rval, RvalLoadInstrs, !Info),
+ Instrs = tree__list([
RvalLoadInstrs,
instr_node(ldind(SimpleType))
- ]) }
+ ])
).
-load(mkword(_Tag, _Rval), Instrs) -->
- { Instrs = comment_node("unimplemented load rval mkword") }.
+load(mkword(_Tag, _Rval), Instrs, !Info) :-
+ Instrs = comment_node("unimplemented load rval mkword").
% XXX check these, what should we do about multi strings,
% characters, etc.
-load(const(Const), Instrs) -->
- DataRep =^ il_data_rep,
+load(const(Const), Instrs, !Info) :-
+ DataRep = !.Info ^ il_data_rep,
% true and false are just the integers 1 and 0
- { Const = true,
+ (
+ Const = true,
Instrs = instr_node(ldc(bool, i(1)))
- ; Const = false,
+ ;
+ Const = false,
Instrs = instr_node(ldc(bool, i(0)))
- ; Const = string_const(Str),
+ ;
+ Const = string_const(Str),
Instrs = instr_node(ldstr(Str))
- ; Const = int_const(Int),
+ ;
+ Const = int_const(Int),
Instrs = instr_node(ldc(int32, i(Int)))
- ; Const = float_const(Float),
+ ;
+ Const = float_const(Float),
Instrs = instr_node(ldc(float64, f(Float)))
- ; Const = multi_string_const(_Length, _MultiString),
+ ;
+ Const = multi_string_const(_Length, _MultiString),
Instrs = throw_unimplemented("load multi_string_const")
- ; Const = code_addr_const(CodeAddr),
+ ;
+ Const = code_addr_const(CodeAddr),
MethodRef = code_addr_constant_to_methodref(DataRep, CodeAddr),
Instrs = instr_node(ldftn(MethodRef))
- ; Const = data_addr_const(DataAddr),
+ ;
+ Const = data_addr_const(DataAddr),
data_addr_constant_to_fieldref(DataAddr, FieldRef),
Instrs = instr_node(ldsfld(FieldRef))
- ; Const = null(_MLDSType),
+ ;
+ Const = null(_MLDSType),
% We might consider loading an integer for
% null function types.
Instrs = instr_node(ldnull)
- }.
+ ).
-load(unop(Unop, Rval), Instrs) -->
- load(Rval, RvalLoadInstrs),
- unaryop_to_il(Unop, Rval, UnOpInstrs),
- { Instrs = tree__list([RvalLoadInstrs, UnOpInstrs]) }.
-
-load(binop(BinOp, R1, R2), Instrs) -->
- load(R1, R1LoadInstrs),
- load(R2, R2LoadInstrs),
- binaryop_to_il(BinOp, BinaryOpInstrs),
- { Instrs = tree__list([R1LoadInstrs, R2LoadInstrs, BinaryOpInstrs]) }.
-
-load(mem_addr(Lval), Instrs) -->
- DataRep =^ il_data_rep,
- ( { Lval = var(Var, VarType) },
- { mangle_mlds_var(Var, MangledVarStr) },
- =(Info),
- { is_local(MangledVarStr, Info) ->
+load(unop(Unop, Rval), Instrs, !Info) :-
+ load(Rval, RvalLoadInstrs, !Info),
+ unaryop_to_il(Unop, Rval, UnOpInstrs, !Info),
+ Instrs = tree__list([RvalLoadInstrs, UnOpInstrs]).
+
+load(binop(BinOp, R1, R2), Instrs, !Info) :-
+ load(R1, R1LoadInstrs, !Info),
+ load(R2, R2LoadInstrs, !Info),
+ binaryop_to_il(BinOp, BinaryOpInstrs, !Info),
+ Instrs = tree__list([R1LoadInstrs, R2LoadInstrs, BinaryOpInstrs]).
+
+load(mem_addr(Lval), Instrs, !Info) :-
+ DataRep = !.Info ^ il_data_rep,
+ ( Lval = var(Var, VarType),
+ mangle_mlds_var(Var, MangledVarStr),
+ ( is_local(MangledVarStr, !.Info) ->
Instrs = instr_node(ldloca(name(MangledVarStr)))
- ; is_argument(MangledVarStr, Info) ->
+ ; is_argument(MangledVarStr, !.Info) ->
Instrs = instr_node(ldarga(name(MangledVarStr)))
- ; is_local_field(Var, VarType, Info, FieldRef) ->
+ ; is_local_field(Var, VarType, !.Info, FieldRef) ->
Instrs = instr_node(ldsfld(FieldRef))
;
FieldRef = make_static_fieldref(DataRep, Var, VarType),
Instrs = instr_node(ldsfld(FieldRef))
- }
- ; { Lval = field(_MaybeTag, Rval, FieldNum, FieldType, ClassType) },
- { get_fieldref(DataRep, FieldNum, FieldType, ClassType,
- FieldRef, CastClassInstrs) },
- load(Rval, RvalLoadInstrs),
- { Instrs = tree__list([
+ )
+ ; Lval = field(_MaybeTag, Rval, FieldNum, FieldType, ClassType),
+ get_fieldref(DataRep, FieldNum, FieldType, ClassType,
+ FieldRef, CastClassInstrs),
+ load(Rval, RvalLoadInstrs, !Info),
+ Instrs = tree__list([
RvalLoadInstrs,
CastClassInstrs,
instr_node(ldflda(FieldRef))
- ]) }
- ; { Lval = mem_ref(_, _) },
+ ])
+ ; Lval = mem_ref(_, _),
% XXX implement this
- { Instrs = throw_unimplemented("load mem_addr lval mem_ref") }
+ Instrs = throw_unimplemented("load mem_addr lval mem_ref")
).
-load(self(_), tree__list([instr_node(ldarg(index(0)))])) --> [].
+load(self(_), tree__list([instr_node(ldarg(index(0)))]), !Info).
-:- pred store(mlds__lval, instr_tree, il_info, il_info) is det.
-:- mode store(in, out, in, out) is det.
+:- pred store(mlds__lval::in, instr_tree::out, il_info::in, il_info::out)
+ is det.
-store(field(_MaybeTag, Rval, FieldNum, FieldType, ClassType), Instrs) -->
- DataRep =^ il_data_rep,
- { get_fieldref(DataRep, FieldNum, FieldType, ClassType,
- FieldRef, CastClassInstrs) },
- load(Rval, RvalLoadInstrs),
- { Instrs = tree__list([
+store(field(_MaybeTag, Rval, FieldNum, FieldType, ClassType), Instrs, !Info) :-
+ DataRep = !.Info ^ il_data_rep,
+ get_fieldref(DataRep, FieldNum, FieldType, ClassType,
+ FieldRef, CastClassInstrs),
+ load(Rval, RvalLoadInstrs, !Info),
+ Instrs = tree__list([
CastClassInstrs,
RvalLoadInstrs,
- instr_node(stfld(FieldRef))]) }.
+ instr_node(stfld(FieldRef))]).
-store(mem_ref(_Rval, _Type), _Instrs, Info, Info) :-
+store(mem_ref(_Rval, _Type), _Instrs, !Info) :-
% you always need load the reference first, then
% the value, then stind it. There's no swap
% instruction. Annoying, eh?
unexpected(this_file, "store into mem_ref").
-store(var(Var, VarType), Instrs) -->
- DataRep =^ il_data_rep,
- { mangle_mlds_var(Var, MangledVarStr) },
- =(Info),
- { is_local(MangledVarStr, Info) ->
+store(var(Var, VarType), Instrs, !Info) :-
+ DataRep = !.Info ^ il_data_rep,
+ mangle_mlds_var(Var, MangledVarStr),
+ ( is_local(MangledVarStr, !.Info) ->
Instrs = instr_node(stloc(name(MangledVarStr)))
- ; is_argument(MangledVarStr, Info) ->
+ ; is_argument(MangledVarStr, !.Info) ->
Instrs = instr_node(starg(name(MangledVarStr)))
;
FieldRef = make_static_fieldref(DataRep, Var, VarType),
Instrs = instr_node(stsfld(FieldRef))
- }.
+ ).
%-----------------------------------------------------------------------------%
%
% Convert binary and unary operations to IL
%
-:- pred unaryop_to_il(mlds__unary_op, mlds__rval, instr_tree, il_info,
- il_info) is det.
-:- mode unaryop_to_il(in, in, out, in, out) is det.
+:- pred unaryop_to_il(mlds__unary_op::in, mlds__rval::in, instr_tree::out,
+ il_info::in, il_info::out) is det.
% Once upon a time the MLDS code generator generated primary tag tests
% (but we don't use primary tags).
@@ -2462,38 +2480,38 @@
% always succeed in the tag test (which is good, with tagbits = 0
% we want to always succeed all primary tag tests).
-unaryop_to_il(std_unop(mktag), _, comment_node("mktag (a no-op)")) --> [].
-unaryop_to_il(std_unop(tag), _, Instrs) -->
- load(const(int_const(0)), Instrs).
-unaryop_to_il(std_unop(unmktag), _, comment_node("unmktag (a no-op)")) --> [].
-unaryop_to_il(std_unop(strip_tag),_,comment_node("strip_tag (a no-op)")) --> [].
-unaryop_to_il(std_unop(mkbody), _, comment_node("mkbody (a no-op)")) --> [].
-unaryop_to_il(std_unop(unmkbody), _, comment_node("unmkbody (a no-op)")) --> [].
-
-unaryop_to_il(std_unop(hash_string), _, node([call(il_mercury_string_hash)]))
- --> [].
-unaryop_to_il(std_unop(bitwise_complement), _, node([not])) --> [].
+unaryop_to_il(std_unop(mktag), _, comment_node("mktag (a no-op)"), !Info).
+unaryop_to_il(std_unop(tag), _, Instrs, !Info) :-
+ load(const(int_const(0)), Instrs, !Info).
+unaryop_to_il(std_unop(unmktag), _, comment_node("unmktag (a no-op)"), !Info).
+unaryop_to_il(std_unop(strip_tag),_,comment_node("strip_tag (a no-op)"),
+ !Info).
+unaryop_to_il(std_unop(mkbody), _, comment_node("mkbody (a no-op)"), !Info).
+unaryop_to_il(std_unop(unmkbody), _, comment_node("unmkbody (a no-op)"),
+ !Info).
+unaryop_to_il(std_unop(hash_string), _, node([call(il_mercury_string_hash)]),
+ !Info).
+unaryop_to_il(std_unop(bitwise_complement), _, node([not]), !Info).
% might want to revisit this and define not to be only
% valid on 1 or 0, then we can use ldc.i4.1 and xor,
% which might be more efficient.
unaryop_to_il(std_unop((not)), _,
- node([ldc(int32, i(1)), clt(unsigned)])) --> [].
+ node([ldc(int32, i(1)), clt(unsigned)]), !Info).
- % XXX should detect casts to System.Array from
- % array types and ignore them, as they are not
- % necessary.
-unaryop_to_il(cast(DestType), SrcRval, Instrs) -->
- DataRep =^ il_data_rep,
- { DestILType = mlds_type_to_ilds_type(DataRep, DestType) },
- { rval_to_type(SrcRval, SrcType) },
- { SrcILType = mlds_type_to_ilds_type(DataRep, SrcType) },
+ % XXX should detect casts to System.Array from array types
+ % and ignore them, as they are not necessary.
+unaryop_to_il(cast(DestType), SrcRval, Instrs, !Info) :-
+ DataRep = !.Info ^ il_data_rep,
+ DestILType = mlds_type_to_ilds_type(DataRep, DestType),
+ rval_to_type(SrcRval, SrcType),
+ SrcILType = mlds_type_to_ilds_type(DataRep, SrcType),
%
% we need to handle casts to/from "refany" specially --
% IL has special instructions for those
%
- {
+ (
% is it a cast to refany?
DestILType = ilds__type(_, refany)
->
@@ -2607,24 +2625,23 @@
instr_node(conv(DestSimpleType))
])
)
- }.
+ ).
-unaryop_to_il(box(UnboxedType), _, Instrs) -->
- DataRep =^ il_data_rep,
- { UnboxedILType = mlds_type_to_ilds_type(DataRep, UnboxedType) },
- { already_boxed(UnboxedILType) ->
- % It is already boxed, so we don't need
- % to do anything.
+unaryop_to_il(box(UnboxedType), _, Instrs, !Info) :-
+ DataRep = !.Info ^ il_data_rep,
+ UnboxedILType = mlds_type_to_ilds_type(DataRep, UnboxedType),
+ ( already_boxed(UnboxedILType) ->
+ % It is already boxed, so we don't need to do anything.
Instrs = empty
;
Instrs = convert_to_object(UnboxedILType)
- }.
+ ).
-unaryop_to_il(unbox(UnboxedType), Rval, Instrs) -->
- DataRep =^ il_data_rep,
- { rval_to_type(Rval, RvalType) },
- { UnboxedILType = mlds_type_to_ilds_type(DataRep, UnboxedType) },
- { already_boxed(UnboxedILType) ->
+unaryop_to_il(unbox(UnboxedType), Rval, Instrs, !Info) :-
+ DataRep = !.Info^ il_data_rep,
+ rval_to_type(Rval, RvalType),
+ UnboxedILType = mlds_type_to_ilds_type(DataRep, UnboxedType),
+ ( already_boxed(UnboxedILType) ->
( RvalType = UnboxedType ->
% We already have the correct type
Instrs = empty
@@ -2634,9 +2651,10 @@
)
;
Instrs = convert_from_object(UnboxedILType)
- }.
+ ).
:- pred already_boxed(ilds__type::in) is semidet.
+
already_boxed(ilds__type(_, object)).
already_boxed(ilds__type(_, string)).
already_boxed(ilds__type(_, refany)).
@@ -2646,123 +2664,124 @@
already_boxed(ilds__type(_, '&'(_))).
already_boxed(ilds__type(_, '*'(_))).
-:- pred binaryop_to_il(binary_op, instr_tree, il_info,
- il_info) is det.
-:- mode binaryop_to_il(in, out, in, out) is det.
+:- pred binaryop_to_il(binary_op::in, instr_tree::out,
+ il_info::in, il_info::out) is det.
-binaryop_to_il((+), instr_node(I)) -->
- { I = add(nocheckoverflow, signed) }.
+binaryop_to_il((+), instr_node(I), !Info) :-
+ I = add(nocheckoverflow, signed).
-binaryop_to_il((-), instr_node(I)) -->
- { I = sub(nocheckoverflow, signed) }.
+binaryop_to_il((-), instr_node(I), !Info) :-
+ I = sub(nocheckoverflow, signed).
-binaryop_to_il((*), instr_node(I)) -->
- { I = mul(nocheckoverflow, signed) }.
+binaryop_to_il((*), instr_node(I), !Info) :-
+ I = mul(nocheckoverflow, signed).
-binaryop_to_il((/), instr_node(I)) -->
- { I = div(signed) }.
+binaryop_to_il((/), instr_node(I), !Info) :-
+ I = div(signed).
-binaryop_to_il((mod), instr_node(I)) -->
- { I = rem(signed) }.
+binaryop_to_il((mod), instr_node(I), !Info) :-
+ I = rem(signed).
-binaryop_to_il((<<), instr_node(I)) -->
- { I = shl }.
+binaryop_to_il((<<), instr_node(I), !Info) :-
+ I = shl.
-binaryop_to_il((>>), instr_node(I)) -->
- { I = shr(signed) }.
+binaryop_to_il((>>), instr_node(I), !Info) :-
+ I = shr(signed).
-binaryop_to_il((&), instr_node(I)) -->
- { I = (and) }.
+binaryop_to_il((&), instr_node(I), !Info) :-
+ I = (and).
-binaryop_to_il(('|'), instr_node(I)) -->
- { I = (or) }.
+binaryop_to_il(('|'), instr_node(I), !Info) :-
+ I = (or).
-binaryop_to_il(('^'), instr_node(I)) -->
- { I = (xor) }.
+binaryop_to_il(('^'), instr_node(I), !Info) :-
+ I = (xor).
-binaryop_to_il((and), instr_node(I)) --> % This is logical and
- { I = (and) }.
+binaryop_to_il((and), instr_node(I), !Info) :-
+ % This is logical and
+ I = (and).
-binaryop_to_il((or), instr_node(I)) --> % This is logical or
- { I = (or) }.
+binaryop_to_il((or), instr_node(I), !Info) :-
+ % This is logical or
+ I = (or).
-binaryop_to_il(eq, instr_node(I)) -->
- { I = ceq }.
+binaryop_to_il(eq, instr_node(I), !Info) :-
+ I = ceq.
-binaryop_to_il(ne, node(Instrs)) -->
- { Instrs = [
+binaryop_to_il(ne, node(Instrs), !Info) :-
+ Instrs = [
ceq,
ldc(int32, i(0)),
ceq
- ] }.
+ ].
-binaryop_to_il(body, _) -->
- { unexpected(this_file, "binop: body") }.
+binaryop_to_il(body, _, !Info) :-
+ unexpected(this_file, "binop: body").
-binaryop_to_il(array_index(ElemType), instr_node(I)) -->
- DataRep =^ il_data_rep,
- { MLDS_Type = ml_gen_array_elem_type(ElemType) },
- { ILSimpleType = mlds_type_to_ilds_simple_type(DataRep, MLDS_Type) },
- { I = ldelem(ILSimpleType) }.
+binaryop_to_il(array_index(ElemType), instr_node(I), !Info) :-
+ DataRep = !.Info ^ il_data_rep,
+ MLDS_Type = ml_gen_array_elem_type(ElemType),
+ ILSimpleType = mlds_type_to_ilds_simple_type(DataRep, MLDS_Type),
+ I = ldelem(ILSimpleType).
% String operations.
binaryop_to_il(str_eq, node([
call(il_string_equals)
- ])) --> [].
+ ]), !Info).
binaryop_to_il(str_ne, node([
call(il_string_equals),
ldc(int32, i(0)),
ceq
- ])) --> [].
+ ]), !Info).
binaryop_to_il(str_lt, node([
call(il_string_compare),
ldc(int32, i(0)),
clt(signed)
- ])) --> [].
+ ]), !Info).
binaryop_to_il(str_gt, node([
call(il_string_compare),
ldc(int32, i(0)),
cgt(signed)
- ])) --> [].
+ ]), !Info).
binaryop_to_il(str_le, node([
call(il_string_compare),
ldc(int32, i(1)), clt(signed)
- ])) --> [].
+ ]), !Info).
binaryop_to_il(str_ge, node([
call(il_string_compare),
ldc(int32, i(-1)),
cgt(signed)
- ])) --> [].
+ ]), !Info).
% Integer comparison
-binaryop_to_il((<), node([clt(signed)])) --> [].
-binaryop_to_il((>), node([cgt(signed)])) --> [].
-binaryop_to_il((<=), node([cgt(signed), ldc(int32, i(0)), ceq])) --> [].
-binaryop_to_il((>=), node([clt(signed), ldc(int32, i(0)), ceq])) --> [].
-binaryop_to_il(unsigned_le, node([cgt(unsigned), ldc(int32, i(0)), ceq])) -->
- [].
+binaryop_to_il((<), node([clt(signed)]), !Info).
+binaryop_to_il((>), node([cgt(signed)]), !Info).
+binaryop_to_il((<=), node([cgt(signed), ldc(int32, i(0)), ceq]), !Info).
+binaryop_to_il((>=), node([clt(signed), ldc(int32, i(0)), ceq]), !Info).
+binaryop_to_il(unsigned_le, node([cgt(unsigned), ldc(int32, i(0)), ceq]),
+ !Info).
% Floating pointer operations.
-binaryop_to_il(float_plus, instr_node(I)) -->
- { I = add(nocheckoverflow, signed) }.
-binaryop_to_il(float_minus, instr_node(I)) -->
- { I = sub(nocheckoverflow, signed) }.
-binaryop_to_il(float_times, instr_node(I)) -->
- { I = mul(nocheckoverflow, signed) }.
-binaryop_to_il(float_divide, instr_node(I)) -->
- { I = div(signed) }.
-binaryop_to_il(float_eq, instr_node(I)) -->
- { I = ceq }.
-binaryop_to_il(float_ne, node(Instrs)) -->
- { Instrs = [
+binaryop_to_il(float_plus, instr_node(I), !Info) :-
+ I = add(nocheckoverflow, signed).
+binaryop_to_il(float_minus, instr_node(I), !Info) :-
+ I = sub(nocheckoverflow, signed).
+binaryop_to_il(float_times, instr_node(I), !Info) :-
+ I = mul(nocheckoverflow, signed).
+binaryop_to_il(float_divide, instr_node(I), !Info) :-
+ I = div(signed).
+binaryop_to_il(float_eq, instr_node(I), !Info) :-
+ I = ceq.
+binaryop_to_il(float_ne, node(Instrs), !Info) :-
+ Instrs = [
ceq,
ldc(int32, i(0)),
ceq
- ] }.
-binaryop_to_il(float_lt, node([clt(signed)])) --> [].
-binaryop_to_il(float_gt, node([cgt(signed)])) --> [].
-binaryop_to_il(float_le, node([cgt(signed), ldc(int32, i(0)), ceq])) --> [].
-binaryop_to_il(float_ge, node([clt(signed), ldc(int32, i(0)), ceq])) --> [].
+ ].
+binaryop_to_il(float_lt, node([clt(signed)]), !Info).
+binaryop_to_il(float_gt, node([cgt(signed)]), !Info).
+binaryop_to_il(float_le, node([cgt(signed), ldc(int32, i(0)), ceq]), !Info).
+binaryop_to_il(float_ge, node([clt(signed), ldc(int32, i(0)), ceq]), !Info).
%-----------------------------------------------------------------------------%
%
@@ -2793,31 +2812,30 @@
% the peephole optimizer pick this one up. Since it's pretty easy
% to detect I've left it here for now.
-:- pred generate_condition(rval, instr_tree, string,
- il_info, il_info).
-:- mode generate_condition(in, out, out, in, out) is det.
+:- pred generate_condition(rval::in, instr_tree::out, string::out,
+ il_info::in, il_info::out) is det.
-generate_condition(Rval, Instrs, ElseLabel) -->
- il_info_make_next_label(ElseLabel),
+generate_condition(Rval, Instrs, ElseLabel, !Info) :-
+ il_info_make_next_label(ElseLabel, !Info),
(
- { Rval = binop(eq, Operand1, Operand2) }
+ Rval = binop(eq, Operand1, Operand2)
->
- load(Operand1, Op1Instr),
- load(Operand2, Op2Instr),
- { OpInstr = instr_node(
- bne(unsigned, label_target(ElseLabel))) },
- { Instrs = tree__list([Op1Instr, Op2Instr, OpInstr]) }
+ load(Operand1, Op1Instr, !Info),
+ load(Operand2, Op2Instr, !Info),
+ OpInstr = instr_node(
+ bne(unsigned, label_target(ElseLabel))),
+ Instrs = tree__list([Op1Instr, Op2Instr, OpInstr])
;
- { Rval = binop(ne, Operand1, Operand2) }
+ Rval = binop(ne, Operand1, Operand2)
->
- load(Operand1, Op1Instr),
- load(Operand2, Op2Instr),
- { OpInstr = instr_node(beq(label_target(ElseLabel))) },
- { Instrs = tree__list([Op1Instr, Op2Instr, OpInstr]) }
- ;
- load(Rval, RvalLoadInstrs),
- { ExtraInstrs = instr_node(brfalse(label_target(ElseLabel))) },
- { Instrs = tree__list([RvalLoadInstrs, ExtraInstrs]) }
+ load(Operand1, Op1Instr, !Info),
+ load(Operand2, Op2Instr, !Info),
+ OpInstr = instr_node(beq(label_target(ElseLabel))),
+ Instrs = tree__list([Op1Instr, Op2Instr, OpInstr])
+ ;
+ load(Rval, RvalLoadInstrs, !Info),
+ ExtraInstrs = instr_node(brfalse(label_target(ElseLabel))),
+ Instrs = tree__list([RvalLoadInstrs, ExtraInstrs])
).
%-----------------------------------------------------------------------------%
@@ -2828,38 +2846,24 @@
% make sense.
% Convert an rval into a function we can call.
-:- pred rval_to_function(rval, class_member_name).
-:- mode rval_to_function(in, out) is det.
-rval_to_function(Rval, MemberName) :-
- ( Rval = const(Const),
+:- pred const_rval_to_function(rval_const::in, class_member_name::out) is det.
+
+const_rval_to_function(Const, MemberName) :-
( Const = code_addr_const(CodeConst) ->
- ( CodeConst = proc(ProcLabel, _Sig),
+ (
+ CodeConst = proc(ProcLabel, _Sig),
mangle_mlds_proc_label(ProcLabel, no,
- ClassName, ProcLabelStr),
- MemberName = class_member_name(ClassName,
- id(ProcLabelStr))
- ; CodeConst = internal(ProcLabel, SeqNum, _Sig),
+ ClassName, ProcLabelStr)
+ ;
+ CodeConst = internal(ProcLabel, SeqNum, _Sig),
mangle_mlds_proc_label(ProcLabel, yes(SeqNum),
- ClassName, ProcLabelStr),
+ ClassName, ProcLabelStr)
+ ),
MemberName = class_member_name(ClassName,
id(ProcLabelStr))
- )
;
- unexpected(this_file,
- "rval_to_function: const is not a code address")
- )
- ; Rval = mkword(_, _),
- unexpected(this_file, "mkword_function_name")
- ; Rval = lval(_),
- unexpected(this_file, "lval_function_name")
- ; Rval = unop(_, _),
- unexpected(this_file, "unop_function_name")
- ; Rval = binop(_, _, _),
- unexpected(this_file, "binop_function_name")
- ; Rval = mem_addr(_),
- unexpected(this_file, "mem_addr_function_name")
- ; Rval = self(_),
- unexpected(this_file, "self_function_name")
+ unexpected(this_file, "rval_to_function: " ++
+ "const is not a code address")
).
%-----------------------------------------------------------------------------
@@ -2936,48 +2940,47 @@
% // Maybe initialise the runtime
% call void [mercury]mercury.runtime::init_runtime(bool)
-:- pred make_class_constructor_class_member(fieldref, mlds__imports,
- list(instr), list(instr), class_member, il_info, il_info).
-:- mode make_class_constructor_class_member(in, in, in, in,
- out, in, out) is det.
+:- pred make_class_constructor_class_member(fieldref::in, mlds__imports::in,
+ list(instr)::in, list(instr)::in, class_member::out,
+ il_info::in, il_info::out) is det.
+
make_class_constructor_class_member(DoneFieldRef, Imports, AllocInstrs,
- InitInstrs, Method) -->
- { Method = method(methodhead([public, static], cctor,
- signature(call_conv(no, default), void, []), []),
- MethodDecls) },
- { ResponsibleInitRuntimeInstrs = responsible_for_init_runtime_instrs },
- { RuntimeInitInstrs = runtime_initialization_instrs },
- test_rtti_initialization_field(DoneFieldRef, TestInstrs),
- set_rtti_initialization_field(DoneFieldRef, SetInstrs),
- { CCtorCalls = list__filter_map(
+ InitInstrs, Method, !Info) :-
+ Method = method(methodhead([public, static], cctor,
+ signature(call_conv(no, default), void, []), []), MethodDecls),
+ ResponsibleInitRuntimeInstrs = responsible_for_init_runtime_instrs,
+ RuntimeInitInstrs = runtime_initialization_instrs,
+ test_rtti_initialization_field(DoneFieldRef, TestInstrs, !Info),
+ set_rtti_initialization_field(DoneFieldRef, SetInstrs, !Info),
+ CCtorCalls = list__filter_map(
(func(I::in) = (C::out) is semidet :-
I = mercury_import(compiler_visible_interface,
ImportName),
C = call_class_constructor(
class_name(ImportName, wrapper_class_name))
- ), Imports) },
- { AllInstrs = list__condense([ResponsibleInitRuntimeInstrs,
+ ), Imports),
+ AllInstrs = list__condense([ResponsibleInitRuntimeInstrs,
TestInstrs, AllocInstrs, SetInstrs,
- CCtorCalls, InitInstrs, RuntimeInitInstrs, [ret]]) },
- { MethodDecls = [instrs(AllInstrs)] }.
+ CCtorCalls, InitInstrs, RuntimeInitInstrs, [ret]]),
+ MethodDecls = [instrs(AllInstrs)].
+
+:- pred test_rtti_initialization_field(fieldref::in, list(instr)::out,
+ il_info::in, il_info::out) is det.
+
+test_rtti_initialization_field(FieldRef, Instrs, !Info) :-
+ il_info_make_next_label(DoneLabel, !Info),
+ Instrs = [ldsfld(FieldRef), brfalse(label_target(DoneLabel)),
+ pop, ret, label(DoneLabel)].
+
+:- pred set_rtti_initialization_field(fieldref::in, list(instr)::out,
+ il_info::in, il_info::out) is det.
+
+set_rtti_initialization_field(FieldRef, Instrs, !Info) :-
+ Instrs = [ldc(int32, i(1)), stsfld(FieldRef)].
+
+:- pred generate_rtti_initialization_field(ilds__class_name::in,
+ fieldref::out, class_member::out) is det.
-:- pred test_rtti_initialization_field(fieldref, list(instr),
- il_info, il_info).
-:- mode test_rtti_initialization_field(in, out, in, out) is det.
-test_rtti_initialization_field(FieldRef, Instrs) -->
- il_info_make_next_label(DoneLabel),
- { Instrs = [ldsfld(FieldRef), brfalse(label_target(DoneLabel)),
- pop, ret, label(DoneLabel)] }.
-
-:- pred set_rtti_initialization_field(fieldref, list(instr),
- il_info, il_info).
-:- mode set_rtti_initialization_field(in, out, in, out) is det.
-set_rtti_initialization_field(FieldRef, Instrs) -->
- { Instrs = [ldc(int32, i(1)), stsfld(FieldRef)] }.
-
-:- pred generate_rtti_initialization_field(ilds__class_name,
- fieldref, class_member).
-:- mode generate_rtti_initialization_field(in, out, out) is det.
generate_rtti_initialization_field(ClassName, AllocDoneFieldRef,
AllocDoneField) :-
AllocDoneFieldName = "rtti_initialized",
@@ -2992,6 +2995,7 @@
:- func mlds_inherits_to_ilds_inherits(il_data_rep, list(mlds__type))
= ilasm__extends.
+
mlds_inherits_to_ilds_inherits(DataRep, Inherits) = Extends :-
( Inherits = [],
Extends = extends_nothing
@@ -3002,33 +3006,40 @@
error("multiple inheritance not supported")
).
-:- pred mlds_signature_to_ilds_type_params(il_data_rep, mlds__func_signature,
- list(ilds__type)).
-:- mode mlds_signature_to_ilds_type_params(in, in, out) is det.
+:- pred mlds_signature_to_ilds_type_params(il_data_rep::in,
+ mlds__func_signature::in, list(ilds__type)::out) is det.
+
mlds_signature_to_ilds_type_params(DataRep,
func_signature(Args, _Returns), Params) :-
Params = list__map(mlds_type_to_ilds_type(DataRep), Args).
:- func mlds_arg_to_il_arg(mlds__argument) = pair(ilds__id, mlds__type).
+
mlds_arg_to_il_arg(mlds__argument(EntityName, Type, _GC_TraceCode)) =
Id - Type :-
mangle_entity_name(EntityName, Id).
:- func mlds_signature_to_ilds_type_params(il_data_rep, mlds__func_signature)
= list(ilds__type).
+
mlds_signature_to_ilds_type_params(DataRep, func_signature(Args, _Returns)) =
list__map(mlds_type_to_ilds_type(DataRep), Args).
:- func mlds_signature_to_il_return_param(il_data_rep, mlds__func_signature)
= ret_type.
+
mlds_signature_to_il_return_param(DataRep, func_signature(_, Returns))
= Param :-
- ( Returns = [] ->
+ (
+ Returns = [],
Param = void
- ; Returns = [ReturnType] ->
- SimpleType = mlds_type_to_ilds_simple_type(DataRep, ReturnType),
+ ;
+ Returns = [ReturnType],
+ SimpleType = mlds_type_to_ilds_simple_type(DataRep,
+ ReturnType),
Param = simple_type(SimpleType)
;
+ Returns = [_, _ | _],
% IL doesn't support multiple return values
sorry(this_file, "multiple return values")
).
@@ -3037,12 +3048,15 @@
ILInputTypes = list__map(input_param_to_ilds_type(DataRep, ModuleName),
Inputs),
FuncParams = mlds__func_params(Inputs, Outputs),
- ( Outputs = [] ->
+ (
+ Outputs = [],
Param = void
- ; Outputs = [ReturnType] ->
+ ;
+ Outputs = [ReturnType],
SimpleType = mlds_type_to_ilds_simple_type(DataRep, ReturnType),
Param = simple_type(SimpleType)
;
+ Outputs = [_, _ | _],
% IL doesn't support multiple return values
sorry(this_file, "multiple return values")
),
@@ -3050,6 +3064,7 @@
:- func input_param_to_ilds_type(il_data_rep, mlds_module_name, mlds__argument)
= ilds__param.
+
input_param_to_ilds_type(DataRep, _ModuleName, Arg) = ILType - yes(Id) :-
Arg = mlds__argument(EntityName, MldsType, _GC_TraceCode),
mangle_entity_name(EntityName, Id),
@@ -3057,6 +3072,7 @@
:- func mlds_type_to_ilds_simple_type(il_data_rep, mlds__type) =
ilds__simple_type.
+
mlds_type_to_ilds_simple_type(DataRep, MLDSType) = SimpleType :-
ilds__type(_, SimpleType) = mlds_type_to_ilds_type(DataRep, MLDSType).
@@ -3120,7 +3136,8 @@
mlds_type_to_ilds_type(_, mlds__foreign_type(ForeignType))
= ilds__type([], Class) :-
- ( ForeignType = il(il(RefOrVal, Assembly, Type)),
+ (
+ ForeignType = il(il(RefOrVal, Assembly, Type)),
sym_name_to_class_name(Type, ForeignClassName),
( RefOrVal = reference,
Class = class(structured_name(assembly(Assembly),
@@ -3129,9 +3146,11 @@
Class = valuetype(structured_name(assembly(Assembly),
ForeignClassName, []))
)
- ; ForeignType = c(_),
+ ;
+ ForeignType = c(_),
error("mlds_to_il: c foreign type")
- ; ForeignType = java(_),
+ ;
+ ForeignType = java(_),
error("mlds_to_il: java foreign type")
).
@@ -3180,6 +3199,7 @@
:- func mlds_class_to_ilds_simple_type(mlds__class_kind, ilds__class_name) =
ilds__simple_type.
+
mlds_class_to_ilds_simple_type(Kind, ClassName) = SimpleType :-
( Kind = mlds__package, SimpleType = class(ClassName)
; Kind = mlds__class, SimpleType = class(ClassName)
@@ -3189,6 +3209,7 @@
).
:- func mercury_type_to_highlevel_class_type(mercury_type) = ilds__type.
+
mercury_type_to_highlevel_class_type(MercuryType) = ILType :-
( type_to_ctor_and_args(MercuryType, TypeCtor, _Args) ->
ml_gen_type_name(TypeCtor, ClassName, Arity),
@@ -3212,6 +3233,7 @@
get_ilds_type_class_name(mlds_type_to_ilds_type(DataRep, MldsType)).
:- func get_ilds_type_class_name(ilds__type) = ilds__class_name.
+
get_ilds_type_class_name(ILType) = ClassName :-
(
( ILType = ilds__type(_, class(ClassName0))
@@ -3283,10 +3305,12 @@
%
predlabel_to_id(pred(PredOrFunc, MaybeModuleName, Name, Arity, CodeModel,
NonOutputFunc), ProcId, MaybeSeqNum, Id) :-
- ( MaybeModuleName = yes(ModuleName) ->
+ (
+ MaybeModuleName = yes(ModuleName),
mlds_to_il__sym_name_to_string(ModuleName, MStr),
string__format("%s_", [s(MStr)], MaybeModuleStr)
;
+ MaybeModuleName = no,
MaybeModuleStr = ""
),
(
@@ -3308,9 +3332,11 @@
;
string__format("_m%d", [i(ProcIdInt)], MaybeProcIdInt)
),
- ( MaybeSeqNum = yes(SeqNum) ->
+ (
+ MaybeSeqNum = yes(SeqNum),
string__format("_i%d", [i(SeqNum)], MaybeSeqNumStr)
;
+ MaybeSeqNum = no,
MaybeSeqNumStr = ""
),
string__format("%s%s_%d%s%s%s", [
@@ -3323,15 +3349,19 @@
predlabel_to_id(special_pred(PredName, MaybeModuleName, TypeName, Arity),
ProcId, MaybeSeqNum, Id) :-
proc_id_to_int(ProcId, ProcIdInt),
- ( MaybeModuleName = yes(ModuleName) ->
+ (
+ MaybeModuleName = yes(ModuleName),
mlds_to_il__sym_name_to_string(ModuleName, MStr),
string__format("%s_", [s(MStr)], MaybeModuleStr)
;
+ MaybeModuleName = no,
MaybeModuleStr = ""
),
- ( MaybeSeqNum = yes(SeqNum) ->
+ (
+ MaybeSeqNum = yes(SeqNum),
string__format("_%d", [i(SeqNum)], MaybeSeqNumStr)
;
+ MaybeSeqNum = no,
MaybeSeqNumStr = ""
),
string__format("special_%s%s_%s_%d_%d%s",
@@ -3349,6 +3379,7 @@
:- func make_static_fieldref(il_data_rep, mlds__var, mlds__type)
= fieldref.
+
make_static_fieldref(DataRep, Var, VarType) = FieldRef :-
Var = qual(ModuleName, _QualKind, VarName),
mangle_mlds_var(Var, MangledVarStr),
@@ -3358,11 +3389,10 @@
mlds_type_to_ilds_type(DataRep, VarType), ClassName,
MangledVarStr).
-:- pred mangle_foreign_code_module(mlds_module_name, foreign_language,
- mlds_module_name).
-:- mode mangle_foreign_code_module(in, in, out) is det.
+:- pred mangle_foreign_code_module(foreign_language::in,
+ mlds_module_name::in, mlds_module_name::out) is det.
-mangle_foreign_code_module(ModuleName0, Lang, ModuleName) :-
+mangle_foreign_code_module(Lang, ModuleName0, ModuleName) :-
LangStr = simple_foreign_language_string(Lang),
PackageName0 = mlds_module_name_to_package_name(ModuleName0),
(
@@ -3411,16 +3441,15 @@
% When generating references to RTTI, we need to mangle the
% module name if the RTTI is defined in C code by hand.
% If no data_name is provided, always do the mangling.
-:- pred mangle_dataname_module(maybe(mlds__data_name), mlds_module_name,
- mlds_module_name).
-:- mode mangle_dataname_module(in, in, out) is det.
+:- pred mangle_dataname_module(maybe(mlds__data_name)::in,
+ mlds_module_name::in, mlds_module_name::out) is det.
-mangle_dataname_module(no, ModuleName0, ModuleName) :-
- mangle_foreign_code_module(ModuleName0, csharp, ModuleName).
+mangle_dataname_module(no, !ModuleName) :-
+ mangle_foreign_code_module(csharp, !ModuleName).
-mangle_dataname_module(yes(DataName), ModuleName0, ModuleName) :-
+mangle_dataname_module(yes(DataName), !ModuleName) :-
(
- SymName = mlds_module_name_to_sym_name(ModuleName0),
+ SymName = mlds_module_name_to_sym_name(!.ModuleName),
SymName = qualified(qualified(unqualified("mercury"),
LibModuleName0), wrapper_class_name),
DataName = var(_),
@@ -3428,15 +3457,14 @@
CodeString = "__csharp_code"
->
string__append(LibModuleName0, CodeString, LibModuleName),
- ModuleName = mercury_module_name_to_mlds(
+ !:ModuleName = mercury_module_name_to_mlds(
qualified(qualified(unqualified("mercury"),
LibModuleName), wrapper_class_name))
;
- ModuleName = ModuleName0
+ true
).
-:- pred mangle_dataname(mlds__data_name, string).
-:- mode mangle_dataname(in, out) is det.
+:- pred mangle_dataname(mlds__data_name::in, string::out) is det.
mangle_dataname(var(MLDSVarName), Name) :-
Name = mangle_mlds_var_name(MLDSVarName).
@@ -3459,8 +3487,8 @@
ClassName = mlds_module_name_to_class_name(ModuleName),
predlabel_to_id(PredLabel, ProcId, MaybeSeqNum, PredStr).
-:- pred mangle_entity_name(mlds__entity_name, string).
-:- mode mangle_entity_name(in, out) is det.
+:- pred mangle_entity_name(mlds__entity_name::in, string::out) is det.
+
mangle_entity_name(type(_TypeName, _), _MangledName) :-
error("can't mangle type names").
mangle_entity_name(data(DataName), MangledName) :-
@@ -3477,24 +3505,25 @@
Str = mangle_mlds_var_name(VarName).
:- func mangle_mlds_var_name(mlds__var_name) = string.
+
mangle_mlds_var_name(mlds__var_name(Name, yes(Num))) =
string__format("%s_%d", [s(Name), i(Num)]).
mangle_mlds_var_name(mlds__var_name(Name, no)) = Name.
-:- pred mlds_to_il__sym_name_to_string(sym_name, string).
-:- mode mlds_to_il__sym_name_to_string(in, out) is det.
+:- pred mlds_to_il__sym_name_to_string(sym_name::in, string::out) is det.
+
mlds_to_il__sym_name_to_string(SymName, String) :-
mlds_to_il__sym_name_to_string(SymName, ".", String).
-:- pred mlds_to_il__sym_name_to_string(sym_name, string, string).
-:- mode mlds_to_il__sym_name_to_string(in, in, out) is det.
+:- pred mlds_to_il__sym_name_to_string(sym_name::in, string::in, string::out)
+ is det.
+
mlds_to_il__sym_name_to_string(SymName, Separator, String) :-
mlds_to_il__sym_name_to_string_2(SymName, Separator, Parts, []),
string__append_list(Parts, String).
-:- pred mlds_to_il__sym_name_to_string_2(sym_name, string, list(string),
- list(string)).
-:- mode mlds_to_il__sym_name_to_string_2(in, in, out, in) is det.
+:- pred mlds_to_il__sym_name_to_string_2(sym_name::in, string::in,
+ list(string)::out, list(string)::in) is det.
mlds_to_il__sym_name_to_string_2(qualified(ModuleSpec,Name), Separator) -->
mlds_to_il__sym_name_to_string_2(ModuleSpec, Separator),
@@ -3533,22 +3562,24 @@
AssemblyName = assembly(PackageString)
;
mlds_to_il__sym_name_to_string(PackageSymName, PackageString),
- ( PackageSymName = unqualified(_),
+ (
+ PackageSymName = unqualified(_),
AssemblyName = assembly(PackageString)
- ; PackageSymName = qualified(_, _),
+ ;
+ PackageSymName = qualified(_, _),
AssemblyName = module(PackageString,
outermost_qualifier(PackageSymName))
)
).
-:- pred sym_name_to_class_name(sym_name, list(ilds__id)).
-:- mode sym_name_to_class_name(in, out) is det.
+:- pred sym_name_to_class_name(sym_name::in, list(ilds__id)::out) is det.
+
sym_name_to_class_name(SymName, Ids) :-
sym_name_to_class_name_2(SymName, Ids0),
list__reverse(Ids0, Ids).
-:- pred sym_name_to_class_name_2(sym_name, list(ilds__id)).
-:- mode sym_name_to_class_name_2(in, out) is det.
+:- pred sym_name_to_class_name_2(sym_name::in, list(ilds__id)::out) is det.
+
sym_name_to_class_name_2(qualified(ModuleSpec, Name), [Name | Modules]) :-
sym_name_to_class_name_2(ModuleSpec, Modules).
sym_name_to_class_name_2(unqualified(Name), [Name]).
@@ -3558,18 +3589,19 @@
% Predicates for checking various attributes of variables.
%
-:- pred is_argument(ilds__id, il_info).
-:- mode is_argument(in, in) is semidet.
+:- pred is_argument(ilds__id::in, il_info::in) is semidet.
+
is_argument(VarName, Info) :-
list__member(VarName - _, Info ^ arguments).
-:- pred is_local(ilds__id, il_info).
-:- mode is_local(in, in) is semidet.
+:- pred is_local(ilds__id::in, il_info::in) is semidet.
+
is_local(VarName, Info) :-
map__contains(Info ^ locals, VarName).
-:- pred is_local_field(mlds__var, mlds__type, il_info, fieldref).
-:- mode is_local_field(in, in, in, out) is semidet.
+:- pred is_local_field(mlds__var::in, mlds__type::in, il_info::in,
+ fieldref::out) is semidet.
+
is_local_field(Var, VarType, Info, FieldRef) :-
mangle_mlds_var(Var, VarName),
set__member(VarName, Info ^ field_names),
@@ -3596,10 +3628,8 @@
rval_to_type(lval(var(_, Type)), Type).
rval_to_type(lval(field(_, _, _, Type, _)), Type).
rval_to_type(lval(mem_ref(_, Type)), Type).
-
rval_to_type(mkword(_, _), _) :-
unexpected(this_file, "rval_to_type: mkword").
-
rval_to_type(unop(Unop, _), Type) :-
(
Unop = box(_),
@@ -3615,19 +3645,16 @@
functor(StdUnop, StdUnopStr, _Arity),
sorry(this_file, "rval_to_type: unop: " ++ StdUnopStr)
).
-
rval_to_type(binop(_, _, _), _) :-
sorry(this_file, "rval_to_type: binop").
-
rval_to_type(mem_addr(_), _) :-
sorry(this_file, "rval_to_type: mem_addr").
-
rval_to_type(self(Type), Type).
-
rval_to_type(const(Const), Type) :-
Type = rval_const_to_type(Const).
:- func rval_const_to_type(mlds__rval_const) = mlds__type.
+
rval_const_to_type(data_addr_const(_)) =
mlds__array_type(mlds__generic_type).
rval_const_to_type(code_addr_const(_)) = mlds__func_type(
@@ -3672,8 +3699,8 @@
MemberName, TypeParams).
% Assumed to be a field of a class
-:- pred data_addr_constant_to_fieldref(mlds__data_addr, fieldref).
-:- mode data_addr_constant_to_fieldref(in, out) is det.
+:- pred data_addr_constant_to_fieldref(mlds__data_addr::in, fieldref::out)
+ is det.
data_addr_constant_to_fieldref(data_addr(ModuleName, DataName), FieldRef) :-
mangle_dataname(DataName, FieldName),
@@ -3692,9 +3719,8 @@
% XXX we remove byrefs from fields here. Perhaps we ought to do
% this in a separate pass. See defn_to_class_decl which does
% the same thing when creating the fields.
-:- pred get_fieldref(il_data_rep, field_id, mlds__type, mlds__type,
- fieldref, instr_tree).
-:- mode get_fieldref(in, in, in, in, out, out) is det.
+:- pred get_fieldref(il_data_rep::in, field_id::in, mlds__type::in,
+ mlds__type::in, fieldref::out, instr_tree::out) is det.
get_fieldref(DataRep, FieldNum, FieldType, ClassType0,
FieldRef, CastClassInstrs) :-
@@ -3730,9 +3756,7 @@
CtorClassName = mlds_module_name_to_class_name(ModuleName),
PtrClassName = mlds_type_to_ilds_class_name(DataRep, ClassType),
ClassName = fixup_class_qualifiers(CtorClassName, PtrClassName),
- (
- PtrClassName = CtorClassName
- ->
+ ( PtrClassName = CtorClassName ->
CastClassInstrs = empty
;
CastClassInstrs = instr_node(
@@ -3748,6 +3772,7 @@
% third field of the structured_name.
:- func fixup_class_qualifiers(ilds__class_name, ilds__class_name) =
ilds__class_name.
+
fixup_class_qualifiers(CtorClassName0, PtrClassName) = CtorClassName :-
PtrClassName = structured_name(PtrAssembly, PtrClass, PtrNested),
CtorClassName0 = structured_name(CtorAssembly, CtorClass, CtorNested),
@@ -3762,7 +3787,8 @@
% if any, will be a nested class within.
% (XXX This relies on the way that ml_type_gen.m generates
% the nested MLDS classes for discriminated unions.)
- common_prefix(CtorClass, PtrClass, OuterClass, NestedClasses, _),
+ common_prefix(CtorClass, PtrClass, OuterClass, NestedClasses,
+ _),
CtorClassName = structured_name(CtorAssembly, OuterClass,
NestedClasses)
;
@@ -3772,28 +3798,28 @@
% common_prefix(List1, List2, Prefix, Tail1, Tail2):
% List1 = Prefix ++ Tail1,
% List2 = Prefix ++ Tail2.
-:- pred common_prefix(list(T), list(T), list(T), list(T), list(T)).
-:- mode common_prefix(in, in, out, out, out) is det.
+:- pred common_prefix(list(T)::in, list(T)::in, list(T)::out, list(T)::out,
+ list(T)::out) is det.
+
common_prefix([], Ys, [], [], Ys).
-common_prefix([X|Xs], [], [], [X|Xs], []).
-common_prefix([X|Xs], [Y|Ys], Prefix, TailXs, TailYs) :-
- (if X = Y then
+common_prefix([X | Xs], [], [], [X | Xs], []).
+common_prefix([X | Xs], [Y | Ys], Prefix, TailXs, TailYs) :-
+ ( X = Y ->
common_prefix(Xs, Ys, Prefix1, TailXs, TailYs),
- Prefix = [X|Prefix1]
- else
- TailXs = [X|Xs],
- TailYs = [Y|Ys],
+ Prefix = [X | Prefix1]
+ ;
+ TailXs = [X | Xs],
+ TailYs = [Y | Ys],
Prefix = []
).
%-----------------------------------------------------------------------------%
-:- pred defn_to_local(mlds_module_name, mlds__defn,
- pair(ilds__id, mlds__type)).
-:- mode defn_to_local(in, in, out) is det.
+:- pred defn_to_local(mlds_module_name::in, mlds__defn::in,
+ pair(ilds__id, mlds__type)::out) is det.
-defn_to_local(ModuleName,
- mlds__defn(Name, _Context, _DeclFlags, Entity), Id - MLDSType) :-
+defn_to_local(ModuleName, Defn, Id - MLDSType) :-
+ Defn = mlds__defn(Name, _Context, _DeclFlags, Entity),
(
Name = data(DataName),
Entity = mlds__data(MLDSType0, _Initializer, _GC_TraceCode)
@@ -3803,7 +3829,8 @@
var_name(MangledDataName, no)), Id),
MLDSType0 = MLDSType
;
- error("definition name was not data/1")
+ unexpected(this_file,
+ "defn_to_local: definition name was not data/1")
).
%-----------------------------------------------------------------------------%
@@ -4005,6 +4032,7 @@
% unmanaged pointers.
:- func choose_il_envptr_type(globals) = ilds__type.
+
choose_il_envptr_type(Globals) = ILType :-
globals__lookup_bool_option(Globals, put_nondet_env_on_heap, OnHeap),
globals__lookup_bool_option(Globals, verifiable_code, Verifiable),
@@ -4050,6 +4078,7 @@
% qualify a name with "[mercury]mercury."
:- func mercury_library_name(ilds__namespace_qual_name) = ilds__class_name.
+
mercury_library_name(Name) =
structured_name(assembly("mercury"), ["mercury" | Name], []).
@@ -4057,6 +4086,7 @@
% name on the end.
:- func mercury_library_wrapper_class_name(ilds__namespace_qual_name) =
ilds__class_name.
+
mercury_library_wrapper_class_name(Name) =
structured_name(assembly("mercury"),
["mercury" | Name] ++ [wrapper_class_name], []).
@@ -4065,6 +4095,7 @@
% qualifiy a name with "[mercury]mercury.runtime."
:- func mercury_runtime_name(ilds__namespace_qual_name) = ilds__class_name.
+
mercury_runtime_name(Name) =
structured_name(assembly("mercury"), ["mercury", "runtime" | Name], []).
@@ -4072,13 +4103,17 @@
% qualifiy a name with "[mscorlib]System."
:- func il_system_name(ilds__namespace_qual_name) = ilds__class_name.
-il_system_name(Name) = structured_name(il_system_assembly_name,
+
+il_system_name(Name) =
+ structured_name(il_system_assembly_name,
[il_system_namespace_name | Name], []).
:- func il_system_assembly_name = assembly_name.
+
il_system_assembly_name = assembly("mscorlib").
:- func il_system_namespace_name = string.
+
il_system_namespace_name = "System".
%-----------------------------------------------------------------------------
@@ -4090,31 +4125,39 @@
mlds_to_il__generate_extern_assembly(CurrentAssembly, Version, SignAssembly,
SeparateAssemblies, Imports, AllDecls) :-
Gen = (pred(Import::in, Decl::out) is semidet :-
- ( Import = mercury_import(compiler_visible_interface,
+ (
+ Import = mercury_import(compiler_visible_interface,
ImportName),
- ( SignAssembly = yes,
+ (
+ SignAssembly = yes,
AsmDecls = mercury_strong_name_assembly_decls
- ; SignAssembly = no,
+ ;
+ SignAssembly = no,
AsmDecls = []
)
- ; Import = foreign_import(ForeignImportName),
+ ;
+ Import = foreign_import(ForeignImportName),
ForeignImportName = il_assembly_name(ImportName),
PackageName = mlds_module_name_to_package_name(
ImportName),
mdbcomp__prim_data__sym_name_to_string(PackageName,
ForeignPackageStr),
( string__prefix(ForeignPackageStr, "System") ->
- AsmDecls = dotnet_system_assembly_decls(Version)
+ AsmDecls =
+ dotnet_system_assembly_decls(Version)
;
AsmDecls = []
)
),
AsmName = mlds_module_name_to_assembly_name(ImportName),
- ( AsmName = assembly(Assembly),
+ (
+ AsmName = assembly(Assembly),
Assembly \= "mercury",
Decl = [extern_assembly(Assembly, AsmDecls)]
- ; AsmName = module(ModuleName, Assembly),
- ( SeparateAssemblies = no,
+ ;
+ AsmName = module(ModuleName, Assembly),
+ (
+ SeparateAssemblies = no,
( Assembly = CurrentAssembly ->
ModuleStr = ModuleName ++ ".dll",
Decl = [file(ModuleStr),
@@ -4124,7 +4167,8 @@
Decl = [extern_assembly(Assembly,
AsmDecls)]
)
- ; SeparateAssemblies = yes,
+ ;
+ SeparateAssemblies = yes,
Decl = [extern_assembly(ModuleName, AsmDecls)]
)
)
@@ -4167,10 +4211,13 @@
%-----------------------------------------------------------------------------
:- func make_method_defn(bool, bool, instr_tree) = method_defn.
+
make_method_defn(DebugIlAsm, VerifiableCode, InstrTree) = MethodDecls :-
- ( DebugIlAsm = yes,
+ (
+ DebugIlAsm = yes,
Add = 1
- ; DebugIlAsm = no,
+ ;
+ DebugIlAsm = no,
Add = 0
),
Instrs = list__condense(tree__flatten(InstrTree)),
@@ -4180,9 +4227,11 @@
% non-verifiable code, then we can skip it. The code that
% the Mercury compiler generates doesn't require it, and
% omitting it may lead to slightly faster code.
- ( VerifiableCode = yes ->
+ (
+ VerifiableCode = yes,
MethodDecls = [MaxStack, zeroinit, instrs(Instrs)]
;
+ VerifiableCode = no,
MethodDecls = [MaxStack, instrs(Instrs)]
).
@@ -4193,14 +4242,17 @@
load_this = ldarg(index(0)).
:- func call_class_constructor(ilds__class_name) = instr.
+
call_class_constructor(CtorMemberName) =
call(get_static_methodref(CtorMemberName, cctor, void, [])).
:- func call_constructor(ilds__class_name) = instr.
+
call_constructor(CtorMemberName) =
call(get_constructor_methoddef(CtorMemberName, [])).
:- func throw_unimplemented(string) = instr_tree.
+
throw_unimplemented(String) =
node([
ldstr(String),
@@ -4210,56 +4262,67 @@
).
:- func newobj_constructor(ilds__class_name, list(ilds__type)) = instr.
+
newobj_constructor(CtorMemberName, ArgTypes) =
newobj(get_constructor_methoddef(CtorMemberName, ArgTypes)).
:- func get_constructor_methoddef(ilds__class_name, list(ilds__type))
= methodref.
+
get_constructor_methoddef(CtorMemberName, ArgTypes) =
get_instance_methodref(CtorMemberName, ctor, void, ArgTypes).
:- func get_instance_methodref(ilds__class_name, member_name, ret_type,
list(ilds__type)) = methodref.
+
get_instance_methodref(ClassName, MethodName, RetType, TypeParams) =
methoddef(call_conv(yes, default), RetType,
class_member_name(ClassName, MethodName), TypeParams).
:- func get_static_methodref(ilds__class_name, member_name, ret_type,
list(ilds__type)) = methodref.
+
get_static_methodref(ClassName, MethodName, RetType, TypeParams) =
methoddef(call_conv(no, default), RetType,
class_member_name(ClassName, MethodName), TypeParams).
:- func make_constructor_class_member(method_defn) = class_member.
+
make_constructor_class_member(MethodDecls) = method(
methodhead([], ctor, signature(call_conv(no, default),
void, []), []), MethodDecls).
:- func make_fieldref(ilds__type, ilds__class_name, ilds__id) = fieldref.
+
make_fieldref(ILType, ClassName, Id) =
fieldref(ILType, class_member_name(ClassName, id(Id))).
:- func responsible_for_init_runtime_instrs = list(instr).
+
responsible_for_init_runtime_instrs = [
call(get_static_methodref(runtime_init_module_name,
responsible_for_init_runtime_name, simple_type(bool), []))
].
:- func runtime_initialization_instrs = list(instr).
+
runtime_initialization_instrs = [
call(get_static_methodref(runtime_init_module_name,
runtime_init_method_name, void, [il_bool_type]))
].
:- func runtime_init_module_name = ilds__class_name.
+
runtime_init_module_name =
structured_name(assembly("mercury"),
["mercury", "runtime", "Init"], []).
:- func runtime_init_method_name = ilds__member_name.
+
runtime_init_method_name = id("init_runtime").
:- func responsible_for_init_runtime_name = ilds__member_name.
+
responsible_for_init_runtime_name = id("responsible_for_initialising_runtime").
%-----------------------------------------------------------------------------%
@@ -4283,65 +4346,61 @@
:- pred il_info_new_class(class_defn::in, il_info::in, il_info::out) is det.
-il_info_new_class(ClassDefn) -->
- { ClassDefn = class_defn(_, _, _, _, _, Members) },
- { list__filter_map((pred(M::in, S::out) is semidet :-
+il_info_new_class(ClassDefn, !Info) :-
+ ClassDefn = class_defn(_, _, _, _, _, Members),
+ list__filter_map((pred(M::in, S::out) is semidet :-
M = mlds__defn(Name, _, _, data(_, _, _)),
S = entity_name_to_ilds_id(Name)
- ), Members, FieldNames)
- },
- ^ alloc_instrs := empty,
- ^ init_instrs := empty,
- ^ class_members := [],
- ^ has_main := no,
- ^ class_foreign_langs := set__init,
- ^ field_names := set__list_to_set(FieldNames).
+ ), Members, FieldNames),
+ !:Info = !.Info ^ alloc_instrs := empty,
+ !:Info = !.Info ^ init_instrs := empty,
+ !:Info = !.Info ^ class_members := [],
+ !:Info = !.Info ^ has_main := no,
+ !:Info = !.Info ^ class_foreign_langs := set__init,
+ !:Info = !.Info ^ field_names := set__list_to_set(FieldNames).
% reset the il_info for processing a new method
-:- pred il_info_new_method(arguments_map, signature, member_name,
- il_info, il_info).
-:- mode il_info_new_method(in, in, in, in, out) is det.
-
-il_info_new_method(ILArgs, ILSignature, MethodName) -->
- =(Info),
- ( yes(SomeLang) =^ method_foreign_lang ->
- ^ file_foreign_langs :=
- set__insert(Info ^ file_foreign_langs, SomeLang),
- ^ class_foreign_langs :=
- set__insert(Info ^ class_foreign_langs, SomeLang)
- ;
- []
- ),
- ^ locals := map__init,
- ^ instr_tree := empty,
- ^ label_counter := counter__init(1),
- ^ block_counter := counter__init(1),
- ^ method_foreign_lang := no,
- ^ arguments := ILArgs,
- ^ method_name := MethodName,
- ^ signature := ILSignature.
-
-:- pred il_info_set_arguments(assoc_list(ilds__id, mlds__type),
- il_info, il_info).
-:- mode il_info_set_arguments(in, in, out) is det.
-il_info_set_arguments(Arguments, Info0, Info) :-
- Info = Info0 ^ arguments := Arguments.
-
-:- pred il_info_get_arguments(arguments_map, il_info, il_info).
-:- mode il_info_get_arguments(out, in, out) is det.
-il_info_get_arguments(Arguments, Info0, Info0) :-
- Arguments = Info0 ^ arguments.
-
-:- pred il_info_get_mlds_type(ilds__id, mlds__type, il_info, il_info).
-:- mode il_info_get_mlds_type(in, out, in, out) is det.
-il_info_get_mlds_type(Id, Type, Info0, Info0) :-
+:- pred il_info_new_method(arguments_map::in, signature::in, member_name::in,
+ il_info::in, il_info::out) is det.
+
+il_info_new_method(ILArgs, ILSignature, MethodName, !Info) :-
+ Info0 = !.Info,
(
- map__search(Info0 ^ locals, Id, Type0)
- ->
+ !.Info ^ method_foreign_lang = yes(SomeLang),
+ !:Info = !.Info ^ file_foreign_langs :=
+ set__insert(Info0 ^ file_foreign_langs, SomeLang),
+ !:Info = !.Info ^ class_foreign_langs :=
+ set__insert(Info0 ^ class_foreign_langs, SomeLang)
+ ;
+ !.Info ^ method_foreign_lang = no
+ ),
+ !:Info = !.Info ^ locals := map__init,
+ !:Info = !.Info ^ instr_tree := empty,
+ !:Info = !.Info ^ label_counter := counter__init(1),
+ !:Info = !.Info ^ block_counter := counter__init(1),
+ !:Info = !.Info ^ method_foreign_lang := no,
+ !:Info = !.Info ^ arguments := ILArgs,
+ !:Info = !.Info ^ method_name := MethodName,
+ !:Info = !.Info ^ signature := ILSignature.
+
+:- pred il_info_set_arguments(assoc_list(ilds__id, mlds__type)::in,
+ il_info::in, il_info::out) is det.
+
+il_info_set_arguments(Arguments, !Info) :-
+ !:Info = !.Info ^ arguments := Arguments.
+
+:- pred il_info_get_arguments(il_info::in, arguments_map::out) is det.
+
+il_info_get_arguments(Info, Arguments) :-
+ Arguments = Info ^ arguments.
+
+:- pred il_info_get_mlds_type(ilds__id::in, mlds__type::out,
+ il_info::in, il_info::out) is det.
+
+il_info_get_mlds_type(Id, Type, !Info) :-
+ ( map__search(!.Info ^ locals, Id, Type0) ->
Type = Type0
- ;
- assoc_list__search(Info0 ^ arguments, Id, Type0)
- ->
+ ; assoc_list__search(!.Info ^ arguments, Id, Type0) ->
Type = Type0
;
% XXX If it isn't a local or an argument, it can only be a
@@ -4352,86 +4411,96 @@
% RTTI creates global variables -- these all happen to be of
% type mlds__native_int_type.
:- func mlds_type_for_rtti_global = mlds__type.
+
mlds_type_for_rtti_global = native_int_type.
-:- pred il_info_set_modulename(mlds_module_name, il_info, il_info).
-:- mode il_info_set_modulename(in, in, out) is det.
-il_info_set_modulename(ModuleName, Info0, Info) :-
- Info = Info0 ^ module_name := ModuleName.
-
-:- pred il_info_add_locals(assoc_list(ilds__id, mlds__type), il_info, il_info).
-:- mode il_info_add_locals(in, in, out) is det.
-il_info_add_locals(NewLocals, Info0, Info) :-
- Info = Info0 ^ locals :=
- map__det_insert_from_assoc_list(Info0 ^ locals, NewLocals).
-
-:- pred il_info_remove_locals(assoc_list(ilds__id, mlds__type),
- il_info, il_info).
-:- mode il_info_remove_locals(in, in, out) is det.
-il_info_remove_locals(RemoveLocals, Info0, Info) :-
+:- pred il_info_set_modulename(mlds_module_name::in,
+ il_info::in, il_info::out) is det.
+
+il_info_set_modulename(ModuleName, !Info) :-
+ !:Info = !.Info ^ module_name := ModuleName.
+
+:- pred il_info_add_locals(assoc_list(ilds__id, mlds__type)::in,
+ il_info::in, il_info::out) is det.
+
+il_info_add_locals(NewLocals, !Info) :-
+ !:Info = !.Info ^ locals :=
+ map__det_insert_from_assoc_list(!.Info ^ locals, NewLocals).
+
+:- pred il_info_remove_locals(assoc_list(ilds__id, mlds__type)::in,
+ il_info::in, il_info::out) is det.
+
+il_info_remove_locals(RemoveLocals, !Info) :-
assoc_list__keys(RemoveLocals, Keys),
- map__delete_list(Info0 ^ locals, Keys, NewLocals),
- Info = Info0 ^ locals := NewLocals.
+ map__delete_list(!.Info ^ locals, Keys, NewLocals),
+ !:Info = !.Info ^ locals := NewLocals.
+
+:- pred il_info_add_class_member(list(class_member)::in,
+ il_info::in, il_info::out) is det.
+
+il_info_add_class_member(ClassMembers, !Info) :-
+ !:Info = !.Info ^ class_members :=
+ list__append(ClassMembers, !.Info ^ class_members).
+
+:- pred il_info_add_instructions(list(instr)::in,
+ il_info::in, il_info::out) is det.
+
+il_info_add_instructions(NewInstrs, !Info) :-
+ !:Info = !.Info ^ instr_tree :=
+ tree(!.Info ^ instr_tree, node(NewInstrs)).
+
+:- pred il_info_add_init_instructions(list(instr)::in,
+ il_info::in, il_info::out) is det.
+
+il_info_add_init_instructions(NewInstrs, !Info) :-
+ !:Info = !.Info ^ init_instrs :=
+ tree(!.Info ^ init_instrs, node(NewInstrs)).
+
+:- pred il_info_add_alloc_instructions(list(instr)::in,
+ il_info::in, il_info::out) is det.
+
+il_info_add_alloc_instructions(NewInstrs, !Info) :-
+ !:Info = !.Info ^ alloc_instrs :=
+ tree(!.Info ^ alloc_instrs, node(NewInstrs)).
-:- pred il_info_add_class_member(list(class_member), il_info, il_info).
-:- mode il_info_add_class_member(in, in, out) is det.
-il_info_add_class_member(ClassMembers, Info0, Info) :-
- Info = Info0 ^ class_members :=
- list__append(ClassMembers, Info0 ^ class_members).
-
-:- pred il_info_add_instructions(list(instr), il_info, il_info).
-:- mode il_info_add_instructions(in, in, out) is det.
-il_info_add_instructions(NewInstrs, Info0, Info) :-
- Info = Info0 ^ instr_tree := tree(Info0 ^ instr_tree, node(NewInstrs)).
-
-:- pred il_info_add_init_instructions(list(instr), il_info, il_info).
-:- mode il_info_add_init_instructions(in, in, out) is det.
-il_info_add_init_instructions(NewInstrs, Info0, Info) :-
- Info = Info0 ^ init_instrs := tree(Info0 ^ init_instrs,
- node(NewInstrs)).
-
-:- pred il_info_add_alloc_instructions(list(instr), il_info, il_info).
-:- mode il_info_add_alloc_instructions(in, in, out) is det.
-il_info_add_alloc_instructions(NewInstrs, Info0, Info) :-
- Info = Info0 ^ alloc_instrs := tree(Info0 ^ alloc_instrs,
- node(NewInstrs)).
-
-:- pred il_info_get_instructions(tree(list(instr)), il_info, il_info).
-:- mode il_info_get_instructions(out, in, out) is det.
-il_info_get_instructions(Instrs, Info, Info) :-
+:- pred il_info_get_instructions(il_info::in, tree(list(instr))::out) is det.
+
+il_info_get_instructions(Info, Instrs) :-
Instrs = Info ^ instr_tree.
-:- pred il_info_get_locals_list(assoc_list(ilds__id, ilds__type),
- il_info, il_info).
-:- mode il_info_get_locals_list(out, in, out) is det.
-il_info_get_locals_list(Locals, Info, Info) :-
+:- pred il_info_get_locals_list(il_info::in,
+ assoc_list(ilds__id, ilds__type)::out) is det.
+
+il_info_get_locals_list(Info, Locals) :-
DataRep = Info ^ il_data_rep,
map__map_values((pred(_K::in, V::in, W::out) is det :-
W = mlds_type_to_ilds_type(DataRep, V)),
Info ^ locals, LocalsMap),
map__to_assoc_list(LocalsMap, Locals).
-:- pred il_info_get_module_name(mlds_module_name, il_info, il_info).
-:- mode il_info_get_module_name(out, in, out) is det.
-il_info_get_module_name(ModuleName, Info, Info) :-
+:- pred il_info_get_module_name(il_info::in, mlds_module_name::out) is det.
+
+il_info_get_module_name(Info, ModuleName) :-
ModuleName = Info ^ module_name.
-:- pred il_info_get_next_block_id(blockid, il_info, il_info).
-:- mode il_info_get_next_block_id(out, in, out) is det.
-il_info_get_next_block_id(N, Info0, Info) :-
- counter__allocate(N, Info0 ^ block_counter, NewCounter),
- Info = Info0 ^ block_counter := NewCounter.
-
-:- pred il_info_get_next_label_num(int, il_info, il_info).
-:- mode il_info_get_next_label_num(out, in, out) is det.
-il_info_get_next_label_num(N, Info0, Info) :-
- counter__allocate(N, Info0 ^ label_counter, NewCounter),
- Info = Info0 ^ label_counter := NewCounter.
-
-:- pred il_info_make_next_label(ilds__label, il_info, il_info).
-:- mode il_info_make_next_label(out, in, out) is det.
-il_info_make_next_label(Label, Info0, Info) :-
- il_info_get_next_label_num(LabelNnum, Info0, Info),
+:- pred il_info_get_next_block_id(blockid::out, il_info::in, il_info::out)
+ is det.
+
+il_info_get_next_block_id(N, !Info) :-
+ counter__allocate(N, !.Info ^ block_counter, NewCounter),
+ !:Info = !.Info ^ block_counter := NewCounter.
+
+:- pred il_info_get_next_label_num(int::out, il_info::in, il_info::out) is det.
+
+il_info_get_next_label_num(N, !Info) :-
+ counter__allocate(N, !.Info ^ label_counter, NewCounter),
+ !:Info = !.Info ^ label_counter := NewCounter.
+
+:- pred il_info_make_next_label(ilds__label::out, il_info::in, il_info::out)
+ is det.
+
+il_info_make_next_label(Label, !Info) :-
+ il_info_get_next_label_num(LabelNnum, !Info),
string__format("l%d", [i(LabelNnum)], Label).
%-----------------------------------------------------------------------------%
@@ -4439,20 +4508,24 @@
% General utility predicates.
%
-:- pred dcg_set(T::in, T::unused, T::out) is det.
-dcg_set(T, _, T).
+% :- pred dcg_set(T::in, T::unused, T::out) is det.
+
+% dcg_set(T, _, T).
%-----------------------------------------------------------------------------%
% Use this to make comments into trees easily.
:- func comment_node(string) = instr_tree.
+
comment_node(S) = node([comment(S)]).
% Use this to make contexts into trees easily.
:- func context_node(mlds__context) = instr_tree.
+
context_node(Context) = node([context_instr(Context)]).
:- func context_instr(mlds__context) = instr.
+
context_instr(Context) = context(FileName, LineNumber) :-
ProgContext = mlds__get_prog_context(Context),
term__context_file(ProgContext, FileName),
@@ -4460,17 +4533,17 @@
% Use this to make instructions into trees easily.
:- func instr_node(instr) = instr_tree.
+
instr_node(I) = node([I]).
% Maybe fold T into U, and map it to V.
% U remains untouched if T is `no'.
-:- pred maybe_map_fold(pred(T, V, U, U), maybe(T), V, V, U, U).
-:- mode maybe_map_fold(pred(in, out, in, out) is det, in, in, out, in, out)
- is det.
+:- pred maybe_map_fold(pred(T, V, U, U)::in(pred(in, out, in, out) is det),
+ maybe(T)::in, V::in, V::out, U::in, U::out) is det.
-maybe_map_fold(_, no, V, V, U, U).
-maybe_map_fold(P, yes(T), _, V, U0, U) :-
- P(T, V, U0, U).
+maybe_map_fold(_, no, !V, !U).
+maybe_map_fold(P, yes(T), _, !:V, !U) :-
+ P(T, !:V, !U).
%-----------------------------------------------------------------------------%
@@ -4478,4 +4551,3 @@
this_file = "mlds_to_il.m".
:- end_module mlds_to_il.
-
Index: compiler/mlds_to_managed.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_managed.m,v
retrieving revision 1.18
diff -u -b -r1.18 mlds_to_managed.m
--- compiler/mlds_to_managed.m 22 Mar 2005 06:40:12 -0000 1.18
+++ compiler/mlds_to_managed.m 22 Mar 2005 12:24:37 -0000
@@ -22,17 +22,14 @@
% Convert the MLDS to the specified foreign language and write
% it to a file.
-:- pred output_managed_code(foreign_language, mlds, io__state, io__state).
-:- mode output_managed_code(in(managed_lang), in, di, uo) is det.
+:- pred output_managed_code(foreign_language::in(managed_lang), mlds::in,
+ io::di, io::uo) is det.
% Print the header comments of the output module
-:- pred output_src_start(mercury_module_name, io__state, io__state).
-:- mode output_src_start(in, di, uo) is det.
+:- pred output_src_start(mercury_module_name::in, io::di, io::uo) is det.
% Print the footer commments of the output module
-:- pred output_src_end(mercury_module_name, io__state, io__state).
-:- mode output_src_end(in, di, uo) is det.
-
+:- pred output_src_end(mercury_module_name::in, io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -222,8 +219,7 @@
)
;
SymName = mlds_module_name_to_sym_name(Name),
- mdbcomp__prim_data__sym_name_to_string(SymName,
- ".", Str)
+ sym_name_to_string(SymName, ".", Str)
),
Result = [Str]
;
@@ -343,8 +339,7 @@
), !IO).
:- pred generate_method_code(foreign_language::in(managed_lang),
- mlds_module_name::in, mlds__defn::in,
- io::di, io::uo) is det.
+ mlds_module_name::in, mlds__defn::in, io::di, io::uo) is det.
generate_method_code(_, _, defn(export(_), _, _, _), !IO).
generate_method_code(_, _, defn(data(_), _, _, _), !IO).
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list