Re: local variables: self=IN!<unnamed> [message #1725478] |
Thu, 03 March 2016 18:21 |
Ed Willink Messages: 7655 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!<unnamed> [message #1725530 is a reply to message #1725529] |
Fri, 04 March 2016 08:34 |
|
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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05398 seconds