Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2m-atl-dev] Using "self" in a helper without declared context

Dear Dennis,

I agree with your analysis of the problem.

Note that self can also technically be used instead of thisModule in
rules when Regular VM or EMFVM.

My preference goes to forbidding it.

However, some transformations may rely on this "feature".
We could remove it gracefully by first reporting a deprecation warning
instead of an error when using old compilers.
It can directly (i.e., without deprecation phase) be reported as an
error with EMFTVM compiler, because no existing transformation may
make use of this with EMFTVM compiler.


Best regards,

Frédéric







On Fri, Nov 29, 2013 at 10:54 AM, Dennis Wagelaar <dwagelaar@xxxxxxxxx> wrote:
> Dear ATL devs,
>
> I'd like to discuss how to solve
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=422408 :
>
> The KM32DSL.atl transformation uses "self" in a helper that does not have a
> context definition, e.g.:
>
> -- This helper get the list of all references
> -- CONTEXT: thisModule
> -- RETURN: Sequence(KM3!Reference)
> helper def: getRefs() : Sequence(KM3!Reference) =
>         self.getClasses()
>                 ->iterate(e; acc : Sequence(KM3!Reference) = Sequence {} |
>                         acc->union(e.getRefs())
>                 );
>
> Currently, the ATL-to-EMFTVM compiler crashes on this - it compiles helpers
> without context to a static field/operation (so no "self" in the local
> variables).I find the most intuitive solution is to not support "self" on a
> helper without context. I'd just add a rule to ATLWFR.atl, and you'll have a
> compile error instead of a crash.
>
> However, the regular ATL compiler seems to support this, so I'm considering it
> too for EMFTVM. If EMFTVM supports "self" in this case, it should also support
> "super". "self" can simply be interpreted as "thisModule" by the compiler,
> which translates into EMFTVM's ExecEnv.class (static). "super" is problematic
> on EMFTVM static operations/fields. A workaround would be to fetch the "env :
> ExecEnv" instance instead using EMFTVM's GETENV instruction
> (http://tinyurl.com/EMFTVM-html), and call INVOKE_SUPER on that.
>
> I suppose mapping ATL helpers without context to static operations/fields
> wasn't an ideal decision, but it made sense at the time: I hadn't seen anyone
> accessing "self" from such a helper, so why pass it in as a parameter?
>
> What are your thoughts on this?
>
> Kind regards,
> Dennis Wagelaar
> _______________________________________________
> m2m-atl-dev mailing list
> m2m-atl-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/m2m-atl-dev


Back to the top