Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Re: local variables: self=IN!<unnamed>
Re: local variables: self=IN!<unnamed> [message #1725478] Thu, 03 March 2016 18:21 Go to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5834
Registered: July 2009
Senior Member
Hi

Maybe someone on the ATL newsgroup can help.

Regards

Ed Willink


On 03/03/2016 17:15, Yi Zhu wrote:
> Hi
>
> I am working on a project for model transformation. I want to use the
> attribute of one class that is referenced by another
> class. Among them, Datatype is a class that includes an attribute
> (name) and a refference (datatypep), Pattern is another class that
> includes two attributes (pattern, constructor) and a refference
> (patternd), datatypep is the opposite reference for patternd.
> but the compiler always show bug. Please help me. Thanks.
>
> The bug:
>
> org.eclipse.m2m.atl.engine.emfvm.VMException
> at __initexpressions#125(Enumerative2Function.atl[64:51-64:84])
> local variables: self=IN!<unnamed>
>
> The ATL code:
>
> helper context Enumeratives!Pattern def: DatatypeName : String =
> if not self.datatypep.oclIsUndefined()
> then self.datatypep.name
> else
> ''
> endif;
> helper def: FunctionNameProfix : String = 'eval_';
>
> helper context Enumeratives!Pattern def: patterns : String =
> if not self.pattern.oclIsUndefined()
> then
> if self.pattern = 'int'
> then 'n'
> else if self.pattern = '(' + thisModule.DatatypeName + ')'
> then '(e)'
> else if self.pattern = '(' + thisModule.DatatypeName + ',
> ' + thisModule.DatatypeName + ')'
> then '(e1, e2)'
> else if self.pattern = '(' + thisModule.DatatypeName
> + ', ' + thisModule.DatatypeName + ', ' + thisModule.DatatypeName + ')'
> then '(e1, e2, e3)'
> else ''
> endif
> endif
> endif
> endif
> else
> ''
> endif;
>
>
> rule P2C {
> from s : Enumeratives!Pattern
> to t : Functions!Clause (
> clause <- s.constructor,
> pattern <- s.patterns,
> expression <- s.expressions
> )
> }
>
> Best,
>
> Yi
Re: local variables: self=IN!&lt;unnamed&gt; [message #1725529 is a reply to message #1725478] Fri, 04 March 2016 08:28 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 357
Registered: September 2012
Location: Belgium
Senior Member

We're missing some information if we want to pinpoint the cause or reproduce your problem. Can you provide a complete zipped Eclipse project for testing? If you cannot attach it here, you may also file a new bug on https://bugs.eclipse.org/bugs/enter_bug.cgi?product=MMT.ATL

Cheers,
Dennis
Re: local variables: self=IN!&lt;unnamed&gt; [message #1725530 is a reply to message #1725529] Fri, 04 March 2016 08:34 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 357
Registered: September 2012
Location: Belgium
Senior Member

Found one mistake already by reading your code: either your definition or your invocation of the DatatypeName helper is wrong. DatatypeName is defined in the context of a Enumeratives!Pattern, but you're invoking it without its context (using thisModule).

Cheers,
Dennis
Re: local variables: self=IN!&lt;unnamed&gt; [message #1725595 is a reply to message #1725530] Fri, 04 March 2016 16:12 Go to previous messageGo to next message
Yi Zhu is currently offline Yi ZhuFriend
Messages: 9
Registered: March 2016
Location: Boston
Junior Member
I have corrected the mistake according to your advice, but the output of pattern in func.xmi is still null. The complete zipped ATL project is attached, please help me to find the bug. I appreciate your help.

YI ZHU
Re: local variables: self=IN!&lt;unnamed&gt; [message #1726118 is a reply to message #1725595] Wed, 09 March 2016 19:54 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 357
Registered: September 2012
Location: Belgium
Senior Member

self.datatypep.oclIsUndefined()
is true for all Patterns in your input model, so the transformation output is correct.


Cheers,
Dennis
Re: local variables: self=IN!&lt;unnamed&gt; [message #1726135 is a reply to message #1726118] Thu, 10 March 2016 00:35 Go to previous message
Yi Zhu is currently offline Yi ZhuFriend
Messages: 9
Registered: March 2016
Location: Boston
Junior Member
Thanks Dennis,

I evaluate every datatypep with the datatype name in the input model, now the rule works. Maybe there is a better way to solve this problem.


YI ZHU
Previous Topic:Generate two targets from one source respectively
Next Topic:ATL metamodel registration
Goto Forum:
  


Current Time: Sun Apr 22 20:01:33 GMT 2018

Powered by FUDForum. Page generated in 0.02298 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software