re-execute rule to duplicate object generation [message #632517] |
Wed, 13 October 2010 05:53  |
Eclipse User |
|
|
|
Hi Chaps,
I need to be able to create certain elements more than once. To do this I thought it would just be necessary to write:
cProc.definesParameters := vProc.reactsTo.equivalent();
cProcPrime.definesParameters := vProc.reactsTo.equivalent();
However this shifts the ownership of the generate objects, how can I force ETL to re-run the rule and regenerate the elements?
Also is there a way of specifying using equivalent() or equivalents() a method for calling certain rules which have a particular output.
My translation requires that I distinguish between different port types by thier direction and create different target elements accordingly. How can I separate the calling of these two rules?
Many Thanks,
James
|
|
|
|
|
Re: re-execute rule to duplicate object generation [message #632605 is a reply to message #632595] |
Wed, 13 October 2010 10:56   |
Eclipse User |
|
|
|
Hi Dimitris,
Sorry but this doesn't seem to have worked - I had left a line commented out that I shouldn't have.
I have the line:
c.containsChannels.addAll(v.containsEntity.definesPort.equiv alent());
This should in theory call the lazy rule:
@lazy
rule OutputPort2Channel
transform port : vhdl!Port
to channel : csp!Channel {
guard : port.hasDirection.name.toLowerCase() == "out"
channel.name = port.name;
channel.definesParameters := new csp!ChannelParameterList;
only one element assigned to OutputPorts
var typeRef = new csp!TypeRef;
typeRef.containsType := GetDataType(port);
channel.definesParameters.parameterTypes.add(typeRef);
}
However it seems that the result of the equivalent() that I am using here is returning the following:
Bag {TypeRef [], TypeRef [], TypeRef [], TypeRef [], Channel [name=ready, ], Channel [name=dispense, ], Channel [name=ret, ], Channel [name=coin, ]}
This is returning the values not only from the rule specified above but also from one of the normal rules as well. How can I stop this equivalent() from running on a normal rule? Or just ensure that only the lazy rule abore is run?
Many Thanks,
James
|
|
|
Re: re-execute rule to duplicate object generation [message #632621 is a reply to message #632605] |
Wed, 13 October 2010 11:22   |
Eclipse User |
|
|
|
Hi James,
I'm afraid you can't. You should either filter the results of
v.containsEntity.definesPort.equivalent() or replace the Port->Channel
rules with operations so that you get more fine-grained control.
Cheers,
Dimitris
James Sharp wrote:
> Hi Dimitris,
>
> Sorry but this doesn't seem to have worked - I had left a line commented
> out that I shouldn't have.
>
> I have the line:
>
> c.containsChannels.addAll(v.containsEntity.definesPort.equiv alent());
>
> This should in theory call the lazy rule:
> @lazy
> rule OutputPort2Channel
> transform port : vhdl!Port
> to channel : csp!Channel {
> guard : port.hasDirection.name.toLowerCase() == "out"
> channel.name = port.name;
> channel.definesParameters := new csp!ChannelParameterList;
> only one element assigned to OutputPorts
> var typeRef = new csp!TypeRef;
> typeRef.containsType := GetDataType(port);
>
> channel.definesParameters.parameterTypes.add(typeRef);
>
> }
> However it seems that the result of the equivalent() that I am using
> here is returning the following:
> Bag {TypeRef [], TypeRef [], TypeRef [], TypeRef [], Channel
> [name=ready, ], Channel [name=dispense, ], Channel [name=ret, ], Channel
> [name=coin, ]}
>
> This is returning the values not only from the rule specified above but
> also from one of the normal rules as well. How can I stop this
> equivalent() from running on a normal rule? Or just ensure that only the
> lazy rule abore is run?
>
> Many Thanks,
>
> James
|
|
|
|
Re: re-execute rule to duplicate object generation [message #632630 is a reply to message #632626] |
Wed, 13 October 2010 12:00  |
Eclipse User |
|
|
|
Hi James,
I think you'll still need the guard. To reduce duplication you could
define an operation vhdl!Port isOut() { return
self.hasDirection.name..toLowerCase() == "out";} and call it from both
places in your code.
Cheers,
Dimitris
James Sharp wrote:
> Hi Dimitris,
>
> Thanks, didn't realise a restirction before a .equivalent() was possible:
>
> c.containsChannels.addAll(v.containsEntity.definesPort.selec t(port :
> vhdl!Port|port.hasDirection.name.toLowerCase() == "out").equivalent());
>
>
> If I have placed this restriction before the equivalent, is the guard
> still required within the lazy rule now (as seen below)?
>
> @lazy
> rule OutputPort2Channel
> transform port : vhdl!Port
> to channel : csp!Channel {
> guard : port.hasDirection.name.toLowerCase() == "out"
> Cheers,
>
> James
|
|
|
Powered by
FUDForum. Page generated in 0.04711 seconds