Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Potential bug with resolveTemp()(it may generate RTE depending on where it is located)
Potential bug with resolveTemp() [message #1839624] Wed, 24 March 2021 18:13 Go to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 152
Registered: July 2014
Senior Member
Hi all,

I get a strange issue. Let's assume that I write the followings rules:

unique lazy rule rule_for_A {
from
src: MM1!A

to
tgt: MM2!X

}

rule rule_for_Bv1 {
from
src: MM1!B

to
tgt: MM2!Y (
a_set <- Set{thisModule.rule_for_A(src.a)},
one_a <- thisModule.resolveTemp(src.a, 'rule_forA', 'tgt')
)
}

rule rule_for_Bv2 {
from
src: MM1!B

to
tgt: MM2!Y (
one_a <- thisModule.resolveTemp(src.a, 'rule_forA', 'tgt'),
a_set <- Set{thisModule.rule_for_A(src.a)}
)
}

Of course, I can only have one of the two "rules for B" in my transformation. The point is that I didn't get the same result with two versions. In the transformation I'm writing, the rules written like the v1 (i.e. resolveTemp *after* the call to the lazy rule) work fine while the ones written like the v2 (i.e. resolveTemp *before* the call to the lazy rule) generate a runtime error.

Did I missed something or is it actually a (known?) bug?

Thanks,
Yves


Yves

[Updated on: Wed, 24 March 2021 18:15]

Report message to a moderator

Re: Potential bug with resolveTemp() [message #1839628 is a reply to message #1839624] Wed, 24 March 2021 20:00 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

This is a limitation of how lazy rules work: resolveTemp() does not trigger any rules. Only invoking the lazy rule does that. Therefore, resolveTemp() cannot find 'tgt' before the unique lazy rule is executed.

Normally, if you only need the default "to" element of a unique lazy rule, you just invoke the rule again on the same input. Instead of creating new output elements every time it is invoked, it will return the same (unique) output for a given (unique) input.

The special version of resolveTemp() with three parameters has been added in EMFTVM to be able to also access other output elements of a unique lazy rule, apart from the first one. However, it "leaks" the implementation detail of whether or not a unique lazy rule has been invoked before. A relatively clean way to insulate against this, is to invoke the unique lazy rule you depend on within the "using" clause of a rule:

unique lazy rule rule_for_A {
  from
    src : MM1!A
  to
    tgt : MM2!X,
    tgt2 : MM2!Y
}

rule rule_for_Bv2 {
  from
    src : MM1!B
  using {
    tgt : MM2!X = thisModule.rule_for_A(src.a);
  }
  to
    tgt : MM2!Y (
      one_a <- thisModule.resolveTemp(src.a, 'rule_forA', 'tgt2'),
      a_set <- Set{tgt}
    )
}


Cheers,
Dennis
Previous Topic:Redefinitions in an extending rule
Next Topic:Public2Private Example
Goto Forum:
  


Current Time: Fri Apr 26 21:16:55 GMT 2024

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

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

Back to the top