Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] : Insertion Order in Sequence ?
[ATL] : Insertion Order in Sequence ? [message #39609] Mon, 21 May 2007 09:57 Go to next message
Eclipse UserFriend
Originally posted by: tristan.faure.c-s.fr

I have a question about the insertion in a Sequence

I have an attribute fparamters where i have to insert parameters if i code
in a matched rule

fparameters <- thisModule.newVariable ('1'),
fparameters <- thisModule.newVariable ('2'),
fparameters <- thisModule.newVariable ('3'),
fparameters <- thisModule.newVariable ('4')

Is the insertion order is guarantee ? because i checked in the xml
generated and it is in the invert order . . . what is precnised by ATL for
insertion ?
Re: [ATL] : Insertion Order in Sequence ? [message #39642 is a reply to message #39609] Mon, 21 May 2007 10:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tristan.faure.c-s.fr

hum sorry i think my question was a little stupid i didn't checked
correctly . . . the order is good in my xml
Re: [ATL] : Insertion Order in Sequence ? [message #39735 is a reply to message #39642] Mon, 21 May 2007 15:51 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hi Tristan,

> I have a question about the insertion in a Sequence
>
> I have an attribute fparamters where i have to insert parameters if i
> code in a matched rule
>
> fparameters <- thisModule.newVariable ('1'),
> fparameters <- thisModule.newVariable ('2'),
> fparameters <- thisModule.newVariable ('3'),
> fparameters <- thisModule.newVariable ('4')
>
> Is the insertion order is guarantee ? because i checked in the xml
> generated and it is in the invert order . . . what is precnised by ATL
> for insertion ?

You should rather write something like:

fparameters <- Sequence {
thisModule.newVariable ('1'),
thisModule.newVariable ('2'),
thisModule.newVariable ('3'),
thisModule.newVariable ('4')
}

This way, you explicitly state that you use a Sequence and initialize
fparameters only once, which results in simpler code.

Note that the fparameters reference must also be ordered in the
metamodel for this to work.

> hum sorry i think my question was a little stupid i didn't checked
> correctly . . . the order is good in my xml

Considering that I still have something to say about this issue even
though you reported it was solved, I do think your question is
interesting anyway :-).


Best regards,

Frédéric Jouault
Re: [ATL] : Insertion Order in Sequence ? [message #39827 is a reply to message #39735] Tue, 22 May 2007 08:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tristan.faure.c-s.fr

Thank you for your answer but i have something strange with this solution
...

I've this code =>

rule Package2System {
from
p : UML!Package (p.oclIsTypeOf(UML!Package))
using {
seq : Sequence(UML!Operations) = p.getOperations() ;
}
to
s : _IF!System (
id <- p.name,
signal <- completesignal,
signal <- callsignal,
signal <- returnsignal,
process <- p.getProcesses(),
process <- thisModule.createGroupManager(),
),
completesignal : _IF!Signal (
id <- 'u2i__complete'
),
callsignal : distinct _IF!Signal foreach (e in seq)(
id <- 'u2i__call_' + e.owner.name + '_' + e.name,
-- default parameters for a call signal
fparameters <- Sequence {
thisModule.newVariable ('waiting','pid'),
thisModule.newVariable ('caller','pid'),
thisModule.newVariable ('callerObj','pid'),
thisModule.newVariable ('callee','pid')
}
),
returnsignal : distinct _IF!Signal foreach (i in seq)(
id <- 'u2i__return_' + i.owner.name + '_' + i.name,
-- default parameters for a return signal
fparameters <- Sequence{ thisModule.newVariable ('callerObj','pid'),
thisModule.newVariable ('callee','pid')
}
)
}

and the code for newVariable :

rule newVariable(sid : String, thetype : String) {
to
v : _IF!Vars (
name <- sid,
type <- thetype
)
do {
v ;
}
}

and i have a null pointer execution ...
the most strange is the xml state at the end of the execution each
variable is in a different signal

<signal id="u2i__call_Stack_opcs_pop">
<fparameters type="pid" name="waiting"/>
</signal>
<signal id="u2i__call_Stack_opcs_push">
<fparameters type="pid" name="caller"/>
</signal>
<signal id="u2i__call_Stack_pop">
<fparameters type="pid" name="callerObj"/>
</signal>
<signal id="u2i__call_Stack_push">
<fparameters type="pid" name="callee"/>

and what i want is all the variable in each state ....
It worked correctly without the Sequence {....

Regards

Tristan FAURE
Re: [ATL] : Insertion Order in Sequence ? [message #40012 is a reply to message #39827] Tue, 22 May 2007 11:03 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

Your problem seems to be with the iterative target pattern element
(i.e., "distinct"-"foreach").

Please, see the following post, which deals with a similar issue:

http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg00815.html


Regards,

Frédéric Jouault


Tristan FAURE wrote:
> Thank you for your answer but i have something strange with this
> solution ...
>
> I've this code =>
> rule Package2System {
> from
> p : UML!Package (p.oclIsTypeOf(UML!Package))
> using {
> seq : Sequence(UML!Operations) = p.getOperations() ;
> }
> to
> s : _IF!System (
> id <- p.name,
> signal <- completesignal,
> signal <- callsignal,
> signal <- returnsignal,
> process <- p.getProcesses(),
> process <- thisModule.createGroupManager(),
> ),
> completesignal : _IF!Signal (
> id <- 'u2i__complete'
> ),
> callsignal : distinct _IF!Signal foreach (e in seq)(
> id <- 'u2i__call_' + e.owner.name + '_' + e.name,
> -- default parameters for a call signal
> fparameters <- Sequence {
> thisModule.newVariable ('waiting','pid'),
> thisModule.newVariable ('caller','pid'),
> thisModule.newVariable ('callerObj','pid'),
> thisModule.newVariable ('callee','pid')
> }
> ),
> returnsignal : distinct _IF!Signal foreach (i in seq)(
> id <- 'u2i__return_' + i.owner.name + '_' + i.name,
> -- default parameters for a return signal
> fparameters <- Sequence{ thisModule.newVariable
> ('callerObj','pid'),
> thisModule.newVariable ('callee','pid')
> }
> )
> }
>
> and the code for newVariable :
>
> rule newVariable(sid : String, thetype : String) {
> to v : _IF!Vars (
> name <- sid,
> type <- thetype
> )
> do {
> v ;
> }
> }
>
> and i have a null pointer execution ... the most strange is the xml
> state at the end of the execution each variable is in a different signal
>
> <signal id="u2i__call_Stack_opcs_pop">
> <fparameters type="pid" name="waiting"/>
> </signal>
> <signal id="u2i__call_Stack_opcs_push">
> <fparameters type="pid" name="caller"/>
> </signal>
> <signal id="u2i__call_Stack_pop">
> <fparameters type="pid" name="callerObj"/>
> </signal>
> <signal id="u2i__call_Stack_push">
> <fparameters type="pid" name="callee"/>
>
> and what i want is all the variable in each state .... It worked
> correctly without the Sequence {....
>
> Regards
>
> Tristan FAURE
>
Re: [ATL] : Insertion Order in Sequence ? [message #40074 is a reply to message #40012] Tue, 22 May 2007 12:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tristan.faure.c-s.fr

I'm sorry my two posts seems equivalent but i think you answer to my other
post. (that i'm trying to resolve with your solution) but here I applied
Sequence {thisModule.NewVariable, .... } and it doesn't work

I'm sorry :s
Re: [ATL] : Insertion Order in Sequence ? [message #40167 is a reply to message #40074] Tue, 22 May 2007 12:59 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

> I'm sorry my two posts seems equivalent but i think you answer to my
> other post. (that i'm trying to resolve with your solution) but here I
> applied Sequence {thisModule.NewVariable, .... } and it doesn't work

It does not work because of the semantics of "distinct"-"foreach".
I had not realized you were using it when I suggested the modification.

Anyway, my advice is to use lazy rules instead: the code should be
cleaner and simpler :-).


> I'm sorry :s

No problem ;-).


Regards,

Frédéric Jouault
Re: [ATL] : Insertion Order in Sequence ? [message #40277 is a reply to message #40167] Tue, 22 May 2007 13:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tristan.faure.c-s.fr

Okay it works too

I am now a lazy rules fan !
Re: [ATL] : Insertion Order in Sequence ? [message #40494 is a reply to message #40277] Tue, 22 May 2007 14:34 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
> Okay it works too
>
> I am now a lazy rules fan !

And now you understand why they are called lazy rules: not only are they
lazily evaluated, but using them requires less code => you can be lazy
too ;-)


Best regards,

Frédéric Jouault
Re: [ATL] : Insertion Order in Sequence ? [message #59362 is a reply to message #39735] Fri, 24 August 2007 14:19 Go to previous message
Eclipse UserFriend
Originally posted by: r.c.ladan.tue.nl

Frédéric Jouault wrote:
> Hi Tristan,
>
> > I have a question about the insertion in a Sequence
> >
> > I have an attribute fparamters where i have to insert parameters if i
> > code in a matched rule
> >
> > fparameters <- thisModule.newVariable ('1'),
> > fparameters <- thisModule.newVariable ('2'),
> > fparameters <- thisModule.newVariable ('3'),
> > fparameters <- thisModule.newVariable ('4')
> >
> > Is the insertion order is guarantee ? because i checked in the xml
> > generated and it is in the invert order . . . what is precnised by ATL
> > for insertion ?
>
> You should rather write something like:
>
> fparameters <- Sequence {
> thisModule.newVariable ('1'),
> thisModule.newVariable ('2'),
> thisModule.newVariable ('3'),
> thisModule.newVariable ('4')
> }
>
> This way, you explicitly state that you use a Sequence and initialize
> fparameters only once, which results in simpler code.
>
> Note that the fparameters reference must also be ordered in the
> metamodel for this to work.
>
[hijacking the thread...]

I have these definitions in my .km3 file :

class BehaviourElement {
...
}
class ClassInstance extends BehaviourElement {
...
reference message[*] : Message oppositeOf classinstance;
...
}
class Message extends BehaviourElement {
...
reference classinstance[1-2] ordered : ClassInstance oppositeOf message;
...
}

but if I assign a Sequence value to the classinstance reference it sometimes comes out reversed
i.e. Sequence{1,2} becomes Sequence{2,1}, but other times the assignment is in order. It seems
to happen when assigning the Sequence value to a reference which also got assigned to in its parent
ATL rule, i.e. :

rule a {
from be : BehaviourElement
to be1 : BehaviourElement(
...
classinstance <- Sequence{r1}
...
)
...
}

rule b extends a {
from be : BehaviourElement(strict)
to be1 : BehaviourElement(
...
classinstance <- Sequence{r2,r3} -- outcome could be anything
...
},
be2 : BehaviourElement(
...
classinstance <- Sequence{r2,r3} -- ok
...
)
}

I guess the ATL engine looses track of order when merging the old and new sequences?
Since I need to filter out some elements, having a fixed order would be quite convenient.

This is with atl2006 and ATL 2.0RC2 (CVS 2007-08-24).

Thanks,
Rene
Previous Topic:ATL Newbie
Next Topic:[ATL] Metamodel reference
Goto Forum:
  


Current Time: Mon Jan 25 15:01:42 GMT 2021

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

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

Back to the top