Permalink
Browse files

[332198] integrated contribution

  • Loading branch information...
1 parent 143e1a5 commit 414c528f2d557aa4f64d8878113e727de824bf89 wpiers committed May 5, 2011
Showing with 99 additions and 23 deletions.
  1. +87 −21 dsls/ATL/Compiler/ATL.acg
  2. +5 −0 dsls/ATL/Metamodel/ATL.km3
  3. +2 −1 dsls/ATL/RuntimeSupport/RefiningTrace.km3
  4. +5 −1 dsls/ATL/Syntax/ATL.tcs
View
@@ -249,6 +249,7 @@ acg ATL startsWith Unit {
pop
next:
enditerate
+ dup -- We dup refining trace to loop again and execute deletion
iterate
-- traceElement
dup -- traceElement, traceElement
@@ -277,6 +278,24 @@ acg ATL startsWith Unit {
enditerate
pop
enditerate
+ iterate -- Iteration to delete everything. We do another loop to be sure to do the deletion
+ -- after all the other modifications to prevent errors
+ -- traceElement
+ dup -- traceElement, traceElement
+ get 'toDelete' -- traceElement, boolean
+ call 'B.not():B' -- traceElement, boolean
+ if noDelete
+ dup -- traceElement, traceElement
+ get 'sourceElement' -- traceElement, element
+ delete -- traceElement
+ push 'Sequence'
+ push '#native'
+ new
+ call 'QJ.first():J' -- traceElement, OclUndefined
+ set 'sourceElement' -- Unset sourceElement reference to avoid problems when serializing the refining trace
+ noDelete:
+
+ enditerate
}
operation
context 'A'
@@ -741,8 +760,17 @@ acg ATL startsWith Unit {
[
let opes = self.mostConcreteOutPatternElements() {
if(self.module.isRefining) {
- analyze opes.first() mode matchFirstRefining
- analyze opes.subSequence(2, opes.size()) mode match
+ if (not opes.first().oclIsUndefined()){
+ -- there is no first element because the first element is going to be dropped
+ -- so no different treatment for the first element
+ if (not self.outPattern.dropPattern.oclIsUndefined()){
+ analyze opes mode match
+ } else {
+ analyze opes.first() mode matchFirstRefining
+ analyze opes.subSequence(2, opes.size()) mode match
+ }
+
+ }
} else {
analyze opes mode match
}
@@ -751,6 +779,10 @@ acg ATL startsWith Unit {
}
}
+ if (not self.outPattern.dropPattern.oclIsUndefined()){
+ analyze self.outPattern.dropPattern
+ }
+
if(self.isNoDefault) {
pushf
} else {
@@ -834,25 +866,7 @@ acg ATL startsWith Unit {
new
}
}
- -- transientLink, varName, element
- foreach(rb in self.reverseBindings) {
- dup -- transientLink, varName, element, element
- if(rb isa NavigationOrAttributeCallExp) {
- analyze rb.source -- transientLink, varName, element, element, value
- if(self.isRefiningMode) {
- call 'J.__asElement():J' -- transientLink, varName, traceElement, traceElement, valueTraceElement
- swap -- transientLink, varName, traceElement, valueTraceElement, traceElement
- push rb.name -- transientLink, varName, traceElement, valueTraceElement, traceElement, propertyName
- swap -- transientLink, varName, traceElement, valueTraceElement, propertyName, traceElement
- pcall 'MRefiningTrace!Element;.setProperty(SJ):V'
- } else {
- swap -- transientLink, varName, element, value, element
- set rb.name -- transientLink, varName, element
- }
- } else {
- report error 'only navigations are allowed in reversebindings'
- }
- }
+ analyze self mode matchReverseBindings
pcall 'NTransientLink;.addTargetElement(SJ):V'
}
@@ -874,9 +888,37 @@ acg ATL startsWith Unit {
load self.outPattern.rule.inPatternElements().first()
set 'sourceElement'
+ analyze self mode matchReverseBindings
+
pcall 'NTransientLink;.addTargetElement(SJ):V'
}
+ -- We create a normal template instead of a code template because this template will be
+ -- called from another code template matching the same model element. If this were
+ -- a code template an error will be raised when the vm tries to remove the entrance
+ -- for this code template (it is registered twice, but as it is a map is has no effect
+ -- so we can not remove twice)
+ SimpleOutPatternElement mode matchReverseBindings {
+ foreach(rb in self.reverseBindings) {
+ dup -- transientLink, varName, element, element
+ if(rb isa NavigationOrAttributeCallExp) {
+ analyze rb.source -- transientLink, varName, element, element, value
+ if(self.isRefiningMode) {
+ call 'J.__asElement():J' -- transientLink, varName, traceElement, traceElement, valueTraceElement
+ swap -- transientLink, varName, traceElement, valueTraceElement, traceElement
+ push rb.name -- transientLink, varName, traceElement, valueTraceElement, traceElement, propertyName
+ swap -- transientLink, varName, traceElement, valueTraceElement, propertyName, traceElement
+ call 'MRefiningTrace!Element;.setProperty(SJ):V'
+ } else {
+ swap -- transientLink, varName, element, value, element
+ set rb.name -- transientLink, varName, element
+ }
+ } else {
+ report error 'only navigations are allowed in reversebindings'
+ }
+ }
+ }
+
function MatchedRule::getBindings(varName, ret) =
if self.outPattern.oclIsUndefined() then
Sequence {}
@@ -1018,6 +1060,30 @@ acg ATL startsWith Unit {
set self.propertyName
}
-- @end ForEachOutPatternElement
+
+-- @begin DropPattern
+ --
+ -- We have to set toDelete flag to true
+ --
+ code DropPattern {
+ push 'Element'
+ push 'RefiningTrace'
+ new
+ dup
+ push self.outPattern.rule.inPatternElements().first().type.name
+ set 'type'
+ dup
+ push self.outPattern.rule.inPatternElements().first().type.model.name
+ set 'metamodel'
+ dup
+ pusht
+ set 'toDelete'
+ load self.outPattern.rule.inPatternElements().first()
+ set 'sourceElement'
+ }
+
+-- @end DropPattern
+
-- @end Standard Rules
-- @begin Lazy Rules
@@ -85,9 +85,14 @@ package ATL {
class OutPattern extends LocatedElement {
reference rule : Rule oppositeOf outPattern;
+ reference dropPattern[0-1] container : DropPattern oppositeOf outPattern;
reference elements[1-*] ordered container : OutPatternElement oppositeOf outPattern;
}
+ class DropPattern extends LocatedElement {
+ reference outPattern : OutPattern oppositeOf dropPattern;
+ }
+
-- @begin PatternElements
abstract class PatternElement extends VariableDeclaration {}
@@ -17,10 +17,11 @@ package RefiningTrace {
class Element {
attribute type : String;
attribute metamodel : String;
+ attribute toDelete : Boolean;
reference slots[*] ordered container : Slot;
-- The source element weaving helper may be persisted in this attribute
- attribute persistedSourceElement[0-1] : String;
+ attribute persistedSourceElement[0-1] : String;
}
class Slot {
View
@@ -161,7 +161,7 @@ syntax ATL(k = 0) {
-- @begin OutPattern
template OutPattern
- : "to" [ elements{separator = ","} ] {endNL = false}
+ : "to" (isDefined(dropPattern) ? dropPattern) [ (isDefined(elements) ? elements{separator = ","}) ] {endNL = false}
;
template OutPatternElement abstract addToContext;
@@ -192,6 +192,10 @@ syntax ATL(k = 0) {
: propertyName{as = identifierOrKeyword}
(isAssignment ? "<:=" : "<-") 'value'
;
+
+ template DropPattern
+ : "drop"
+ ;
-- @end OutPattern
template ActionBlock

0 comments on commit 414c528

Please sign in to comment.