Skip to main content

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

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


Back to the top