|
[ATL] Re: What is the meaning of "mapsTo"? [message #24829 is a reply to message #24559] |
Tue, 20 March 2007 16:32 |
Dennis Wagelaar Messages: 147 Registered: July 2009 |
Senior Member |
|
|
Matthias Bohlen schreef:
> Hi Dennis,
>
> in some of your transformations, I see the keyword "mapsTo":
>
> rule DurationInterval {
> from s : UML2!uml::DurationInterval (thisModule.inElements->includes(s))
> to t : UML2!uml::DurationInterval mapsTo s ( ... )
> }
>
> What does this keyword do?
>
> Cheers
> Matthias
>
Short answer:
The keyword currently does nothing. You may ignore it.
Long answer:
The "mapsTo" keyword is meant to specify that "s" is replaced by "t" for
every reference to "s". The current behaviour of ATL is to always
replace the source element by the first target element. Consider the
following example:
rule A {
from s : UML!Class
to t : RDB!Table (
columns <- s.ownedAttribute)
}
rule B {
from s : UML!Attribute
to t : RDB!Column (
name <- s.name),
index : RDB!Index (
name <- s.name)
}
RDB!Table cannot contain UML!Attribute elements as columns (rule A).
That's why s.ownedAttribute is replaced with what it "mapsTo". This is
defined in rule B: each UML!Attribute is mapped to a RDB!Column. So,
what happens when I change the order of "t" and "index" in rule B?
Remember that only the first target element in each rule gets this
special "mapsTo" treatment: if each UML!Attribute maps to an RDB!Index,
rule A becomes invalid: it tries to assign a Sequence of RDB!Index to
columns.
I found this special treatment of the first target element too
significant to remain implicit and I've added the "mapsTo" keyword to
make it explicit.
I'm not sure if this was a wise decision, since it likely makes you
believe that you can use "mapsTo" on other target elements as well. This
is not true, since "mapsTo" does nothing at the moment. It also provokes
questions like "What does this keyword do?" ;-). I suppose Frédéric
should just take it out of the parser and force me to update my
transformations, so I can stop shooting myself in the foot with this ;-).
--
Regards,
Dennis
|
|
|
|
Powered by
FUDForum. Page generated in 0.01510 seconds