[m-rev.] for review: fix .NET commit handling
Tyson Dowd
trd at cs.mu.OZ.AU
Wed Jul 11 21:11:25 AEST 2001
Hi,
This is a response to Fergus' review comments about the commit handling
code.
===================================================================
Estimated hours taken: 1
Branches: main
Fix the handling of commits in .NET.
compiler/ml_code_gen.m:
Initialize (new_object) the commit object just before we throw it.
Also fix some code that looked up the target option as a string
instead of an enumeration.
compiler/ml_elim_nested.m:
Don't initialize the commit object inside the constructor for the
class -- this hard to maintain and may not always be correct.
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.89
diff -u -r1.89 ml_code_gen.m
--- compiler/ml_code_gen.m 2001/06/22 09:14:30 1.89
+++ compiler/ml_code_gen.m 2001/07/11 10:58:03
@@ -1582,18 +1582,38 @@
/* push nesting level */
{ MLDS_Context = mlds__make_context(Context) },
ml_gen_info_new_commit_label(CommitLabelNum),
- { CommitRef = mlds__var_name(
- string__format("commit_%d", [i(CommitLabelNum)]),
- no) },
- ml_gen_var_lval(CommitRef, mlds__commit_type, CommitRefLval),
+ { CommitRef = mlds__var_name(string__format("commit_%d",
+ [i(CommitLabelNum)]), no) },
+ ml_gen_var_lval(CommitRef, mlds__commit_type,
+ CommitRefLval),
{ CommitRefDecl = ml_gen_commit_var_decl(MLDS_Context,
CommitRef) },
{ DoCommitStmt = do_commit(lval(CommitRefLval)) },
- { DoCommitStatement = mlds__statement(DoCommitStmt,
- MLDS_Context) },
+ { DoCommitStatement =
+ mlds__statement(DoCommitStmt, MLDS_Context) },
+ =(MLDSGenInfo),
+ { ml_gen_info_get_module_info(MLDSGenInfo, ModuleInfo) },
+ { module_info_globals(ModuleInfo, Globals) },
+ { globals__get_target(Globals, Target) },
+ { Target = il ->
+ % XXX would be a good performance thing
+ % to re-use the same pre-allocated commit
+ % object over and over again, instead of
+ % allocating them each time.
+ NewCommitObject = mlds__statement(
+ atomic(new_object(CommitRefLval, no,
+ mlds__commit_type, no, no, [], [])),
+ MLDS_Context),
+ DoCommitBody = ml_gen_block([],
+ [NewCommitObject,
+ DoCommitStatement],
+ Context)
+ ;
+ DoCommitBody = DoCommitStatement
+ },
/* pop nesting level */
ml_gen_nondet_label_func(SuccessFuncLabel, Context,
- DoCommitStatement, SuccessFunc),
+ DoCommitBody, SuccessFunc),
ml_get_env_ptr(EnvPtrRval),
{ SuccessCont = success_cont(SuccessFuncLabelRval,
@@ -2182,7 +2202,7 @@
=(MLDSGenInfo),
{ ml_gen_info_get_module_info(MLDSGenInfo, ModuleInfo) },
{ module_info_globals(ModuleInfo, Globals) },
- { globals__lookup_string_option(Globals, target, Target) },
+ { globals__get_target(Globals, Target) },
( { CodeModel = model_non } ->
% For IL code, we can't call continutations because
@@ -2193,7 +2213,7 @@
% continuation call.
(
- { Target = "il" }
+ { Target = il }
->
ml_gen_call_current_success_cont_indirectly(Context,
CallCont)
Index: compiler/ml_elim_nested.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_elim_nested.m,v
retrieving revision 1.32
diff -u -r1.32 ml_elim_nested.m
--- compiler/ml_elim_nested.m 2001/07/11 10:27:05 1.32
+++ compiler/ml_elim_nested.m 2001/07/11 10:58:04
@@ -380,24 +380,16 @@
% away.
globals__get_target(Globals, Target),
( Target = il ->
- % Generate a ctor for the class which
- % initilaises the commit field.
- ThisPtr = self(mlds__commit_type),
- FieldType = mlds__commit_type,
- CtorType = mlds__commit_type,
- PtrType = EnvTypeName,
-
- % Note we have to do the correct name mangling
- % for the IL backend.
- FieldName = qual(mlds__append_name(ModuleName,
- EnvClassName ++ "_0"), "commit_1"),
- Lval = field(no, ThisPtr, named_field(FieldName, CtorType),
- FieldType, PtrType),
+ % Generate a ctor for the class.
- Rval = new_object(Lval, no, FieldType, no, no, [], []),
+ % XXX we can't generate an empty constructor,
+ % because the IL backend interprets that as
+ % :- external.
+ % So we generate an empty block instead.
+ Stmt = mlds__statement(block([], []), Context),
- Stmt = mlds__statement(atomic(Rval), Context),
- Ctor = mlds__function(no, func_params([], []), yes(Stmt)),
+ Ctor = mlds__function(no, func_params([], []),
+ yes(Stmt)),
CtorFlags = init_decl_flags(public, per_instance, non_virtual,
overridable, modifiable, concrete),
--
Tyson Dowd #
# Surreal humour isn't everyone's cup of fur.
trd at cs.mu.oz.au #
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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