EMFTVM/ATL How to assign the result of a rule matching several elements [message #1053440] |
Sun, 05 May 2013 20:49 |
EtienneB Mising name Messages: 35 Registered: June 2011 |
Member |
|
|
Dear all,
progressing in the implementation of a model transformation with EMFTVM, I am facing a new issue: I wrote a matched rule that matches 2 elements but I didn't find out how to store the result of this rule in my model.
Here is a snippet of code to illustrate what I have in my code (sorry if it is not correct, I wrote it directly on the forum):
rule R1
{
from
c: AADL!ComponentInstance
to
implImg: AADL!ThreadImplementation
(
calls <- c.calls -- list of SubprogramCall
)
}
rule R2
{
from
call: AADL!SubprogramCall
to
callImg: AADL!SubprogramCall
}
rule R3
{
from
c: AADL!ComponentInstance,
call: AADL!SubprogramCall
(c.entryPoint = call)
to
callImg: AADL!SubprogramCall
}
Basically, what I would like is that the element created by R1 (implImg) contains in it attribute "calls" the list of SubprogramCall created by R2 or R3. I tried using inheritence (R3 inherits R2) but it did not work. Maybe a "special" resolveTemp could solve my problem...
Any suggestion?
Thanks a lot,
Etienne.
[Updated on: Mon, 06 May 2013 20:34] Report message to a moderator
|
|
|
|
|
Re: EMFTVM/ATL How to assign the result of a rule matching several elements [message #1053607 is a reply to message #1053537] |
Mon, 06 May 2013 19:49 |
|
EMFTVM uses a Sequence instead of a Tuple as trace key, which contains the source elements in order.
In your specific case, you don't need to transform the Cartesian product of 'c' and 'call' in R3. Therefore you can use an explicit mapsTo:
rule R3 {
from
c: AADL!ComponentInstance,
call: AADL!SubprogramCall
(c.entryPoint = call)
to
callImg: AADL!SubprogramCall mapsTo call
}
Cheers,
Dennis
|
|
|
Re: EMFTVM/ATL How to assign the result of a rule matching several elements [message #1053611 is a reply to message #1053607] |
Mon, 06 May 2013 20:33 |
EtienneB Mising name Messages: 35 Registered: June 2011 |
Member |
|
|
Dennis, your solution just works perfectly, this is awesome!
Just for my information, I tried this:
rule R1
{
from
c: AADL!ComponentInstance
to
implImg: AADL!ThreadImplementation
(
calls <- c.calls->collect(e| thisModule.resolveTemp(Sequence{c,e}, 'callImg'))
)
}
and I get an exception: Cannot resolve default trace target 'callImg' for [the_sender:ComponentInstance, the_call:SubprogramCall]
Is there a mistake in my code? Or do I make a conceptual mistake? Or is it a feature not yet supported?
Thanks again,
Etienne.
[Updated on: Mon, 06 May 2013 20:34] Report message to a moderator
|
|
|
|
|
Re: EMFTVM/ATL How to assign the result of a rule matching several elements [message #1057956 is a reply to message #1053657] |
Fri, 10 May 2013 06:06 |
EtienneB Mising name Messages: 35 Registered: June 2011 |
Member |
|
|
Dear Dennis,
in some cases I have to use the Cartesian product of my model elements. Let's imagine we withdraw R2 from my previous example; can I write R1 like this then?
rule R1
{
from
c: AADL!ComponentInstance
to
implImg: AADL!ThreadImplementation
(
calls <- c.calls->collect(e| thisModule.resolveTemp(Sequence{c,e}, 'callImg'))
)
}
I tried but I get an exception: Cannot resolve default trace target 'callImg' for [the_sender:ComponentInstance, the_call:SubprogramCall]. But I know that R3 matches on this sequence of elements...
Is there a mistake in my code? Or do I make a conceptual mistake? Or is it a feature not yet supported?
Thanks,
Etienne.
[Updated on: Fri, 10 May 2013 07:19] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05641 seconds