[m-rev.] for review: fix .NET commit handling
Tyson Dowd
trd at cs.mu.OZ.AU
Wed Jul 11 22:36:04 AEST 2001
On 11-Jul-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 11-Jul-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > Index: compiler/ml_elim_nested.m
> ...
> > ( Target = il ->
> > + % Generate a ctor for the class.
> >
> > + % 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),
>
> There shouldn't be an XXX on that comment.
> An XXX would indicate something that we ought to fix later,
> but this comment is just explaining why it was done the
> way it was, not pointing out a hack or suggesting something
> that could be fixed later.
Sorry, I intended to fix it later. This has bitten me once and Pete
once so I wanted to fix it. But the XXX should go on mlds.m.
> More importantly, that shouldn't be done in ml_elim_nested.m.
> ml_elim_nested.m shouldn't have target-dependent code.
> At worst there should be stuff which is dependent on target capabilities
> (e.g. "target_supports_computed_goto").
Target capabilities is fine, it's easy to generalize "Target = il".
> However, I suppose it's more important get it working first.
> So I suggest you go ahead and commit that.
> I'll fix the modularity problems.
I would prefer to commit my followup.
This is the interdiff for it:
diff -u compiler/ml_code_gen.m compiler/ml_code_gen.m
--- compiler/ml_code_gen.m
+++ compiler/ml_code_gen.m
@@ -1604,7 +1604,7 @@
atomic(new_object(CommitRefLval, no,
mlds__commit_type, no, no, [], [])),
MLDS_Context),
- DoCommitBody = ml_gen_block([],
+ DoCommitBody = ml_gen_block([CommitRefDecl],
[NewCommitObject,
DoCommitStatement],
Context)
@@ -1636,8 +1636,13 @@
[SetSuccessTrue]), Context)) },
{ TryCommitStatement = mlds__statement(TryCommitStmt,
MLDS_Context) },
- { CommitFuncLocalDecls = [CommitRefDecl, SuccessFunc |
- GoalStaticDecls] },
+ { Target = il ->
+ CommitFuncLocalDecls = [SuccessFunc |
+ GoalStaticDecls]
+ ;
+ CommitFuncLocalDecls = [CommitRefDecl, SuccessFunc |
+ GoalStaticDecls]
+ },
maybe_put_commit_in_own_func(CommitFuncLocalDecls,
[TryCommitStatement], Context,
CommitFuncDecls, MLDS_Statements),
only in patch2:
--- compiler/mlds_to_il.m 2001/07/11 10:24:36 1.42
+++ compiler/mlds_to_il.m 2001/07/11 12:21:52
@@ -1050,10 +1050,9 @@
maybe_box_initializer(init_struct(X), init_struct(X)) --> [].
% single items need to be boxed
maybe_box_initializer(init_obj(Rval), init_obj(NewRval)) -->
- rval_to_type(Rval, BoxType),
+ { rval_to_type(Rval, BoxType) },
{ NewRval = unop(box(BoxType), Rval) }.
-
%-----------------------------------------------------------------------------%
%
% Convert basic MLDS statements into IL.
@@ -1276,7 +1275,7 @@
statement_to_il(CommitHandlerGoal, HandlerInstrsTree),
il_info_make_next_label(DoneLabel),
- rval_to_type(lval(Ref), MLDSRefType),
+ { rval_to_type(lval(Ref), MLDSRefType) },
DataRep =^ il_data_rep,
{ ClassName = mlds_type_to_ilds_class_name(DataRep, MLDSRefType) },
{ Instrs = tree__list([
@@ -2716,46 +2715,44 @@
% constants to the MLDS version of their IL representation).
% This is so you can generate appropriate box rvals for
% rval_consts.
+
+:- pred rval_to_type(mlds__rval::in, mlds__type::out) is det.
+
+rval_to_type(lval(var(_, Type)), Type).
+rval_to_type(lval(field(_, _, _, Type, _)), Type).
+rval_to_type(lval(mem_ref(_, Type)), Type).
-:- pred rval_to_type(mlds__rval::in, mlds__type::out,
- il_info::in, il_info::out) is det.
+rval_to_type(mkword(_, _), _) :-
+ unexpected(this_file, "rval_to_type: mkword").
-rval_to_type(lval(Lval), Type, Info0, Info) :-
- ( Lval = var(Var, _VarType),
- mangle_mlds_var(Var, MangledVarStr),
- il_info_get_mlds_type(MangledVarStr, Type, Info0, Info)
- ; Lval = field(_, _, _, Type, _),
- Info = Info0
- ; Lval = mem_ref(_Rval, Type),
- Info = Info0
+rval_to_type(unop(Unop, _), Type) :-
+ (
+ Unop = box(_),
+ Type = mlds__generic_type
+ ;
+ Unop = unbox(UnboxType),
+ Type = UnboxType
+ ;
+ Unop = cast(CastType),
+ Type = CastType
+ ;
+ Unop = std_unop(StdUnop),
+ functor(StdUnop, StdUnopStr, _Arity),
+ unexpected(this_file, "rval_to_type: unop: " ++ StdUnopStr)
).
- % The following five conversions should never occur or be boxed
- % anyway, but just in case they are we make them reference
- % mercury.invalid which is a non-exisitant class. If we try to
- % run this code, we'll get a runtime error.
- % XXX can we just call error?
-rval_to_type(mkword(_Tag, _Rval), Type, I, I) :-
- ModuleName = mercury_module_name_to_mlds(unqualified("mercury")),
- Type = mlds__class_type(qual(ModuleName, "invalid"),
- 0, mlds__class).
-rval_to_type(unop(_, _), Type, I, I) :-
- ModuleName = mercury_module_name_to_mlds(unqualified("mercury")),
- Type = mlds__class_type(qual(ModuleName, "invalid"),
- 0, mlds__class).
-rval_to_type(binop(_, _, _), Type, I, I) :-
- ModuleName = mercury_module_name_to_mlds(unqualified("mercury")),
- Type = mlds__class_type(qual(ModuleName, "invalid"),
- 0, mlds__class).
-rval_to_type(mem_addr(_), Type, I, I) :-
- ModuleName = mercury_module_name_to_mlds(unqualified("mercury")),
- Type = mlds__class_type(qual(ModuleName, "invalid"),
- 0, mlds__class).
-rval_to_type(self(_), Type, I, I) :-
+rval_to_type(binop(_, _, _), _) :-
+ unexpected(this_file, "rval_to_type: binop").
+
+rval_to_type(mem_addr(_), _) :-
+ unexpected(this_file, "rval_to_type: mem_addr").
+
+rval_to_type(self(_), Type) :-
ModuleName = mercury_module_name_to_mlds(unqualified("mercury")),
Type = mlds__class_type(qual(ModuleName, "invalid"),
0, mlds__class).
-rval_to_type(const(Const), Type, I, I) :-
+
+rval_to_type(const(Const), Type) :-
Type = rval_const_to_type(Const).
:- func rval_const_to_type(mlds__rval_const) = mlds__type.
--
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