[m-rev.] Where to check foreign_proc attributes?
Julien Fischer
juliensf at csse.unimelb.edu.au
Fri Jan 12 22:57:13 AEDT 2007
On Fri, 12 Jan 2007, Ben Schmidt wrote:
> Hi,
>
> I need to implement some checking of foreign_proc attributes. Certain
> combinations of attributes need to generate compile-time warnings or errors.
> They should be errors in agc grades and warnings in other grades. They don't
They should be errors in all grades.
> really depend on anything except for the list of attributes and the grade.
> So...
>
> 1. It could probably be done at parsing-time, while conflicting attributes
> are checked for (prog_io_pragma.m), except there isn't a way to access
> globals there, so I couldn't differentiate between warnings and errors based
> on the gc method, or at least, not as far as I can tell. And actually, I'm
> not sure warnings can be output at all at this stage.
>
> 2. It could be done at code-generation time (while converting HLDS->MLDS;
> ml_code_gen.m), but that's not really the right place to be detecting errors,
> and they won't be detected at all unless the right backend is being used.
>
> 3. They could be done as checks on the HLDS...but where should they be
> incorporated (submodule of check_hlds.m)? They are not type, mode or
> determinism checks, nor are they various code simplifications or module-level
> checks. One thought is to incorporate them in clause_to_proc.m, as they are
> essentially procedure-based checks...but...as that operation is abstracted
> away from implementation detail, the globals and hence gc method aren't
> available there either, so the warning/error distinction can't be drawn.
The appropriate place would be in the predicate
module_add_pragma_foreign_proc/15 in the file add_pragma.m,
i.e. do it as part of the parse that converts the parse tree into the
HLDS.
> 4. Maybe they could be done in an optimisation pass (transform_hlds.m)--but
> is there an appropriate one which can't be turned off (or can all of them be
> turned off), as they are semantic errors that need to be picked up?
> dead_proc_elim.m is potentially a place it could be done, I think, but it may
> be turned off. I don't think the tiny amount of checking that needs to be
> done warrants an extra pass.
>
> So...I'm a bit stuck as to where is the best place to slot this in. Anyone
> have any ideas?
Yes, see above.
Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list