blob: aa6bde03979120c9cb90f96a68a824b169113cec [file] [log] [blame]
import '/resource/org.eclipse.ocl.pivot/model/Lookup.ecore'
import '/resource/org.eclipse.ocl.pivot/model/Pivot.ecore'
import '/resource/org.eclipse.ocl.pivot/model/PivotLookup.ocl'
import 'ImperativeOCL.ecore'
package imperativeocl
context BlockExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv().nestedEnv()
-- FIXME OMG issue. It's not clear if the variable is available to be used by further expressions (sibling elements) or only for inner body expression
-- in essence if a compute expression opens a new scope or not
context ComputeExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
if self._body = child then
parentEnv().addElement(self.returnedElement)
else
parentEnv()
endif
-- Overwritten. This will be autogenerated
context WhileExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- FIXME (Abstract)
-- Overwritten. This will be autogenerated
context ImperativeLoopExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
context ForExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
if self.condition = child then
parentEnv().nestedEnv()
.addElements(self.ownedIterators)
else if self.ownedBody = child then
parentEnv().nestedEnv()
.addElements(self.ownedIterators)
else if self.ownedIterators->includes(child) then
parentEnv().nestedEnv()
.addElements(self.ownedIterators->select(x | self.ownedIterators->indexOf(x) < self.ownedIterators->indexOf(child)))
else
parentEnv()
endif endif endif
-- FIXME OMG issue. Messy in the spec. Shouldn't be an (OCL) IterateExp + ImperativeExp ?. Very confusing. Need deeper thought.
-- Besides, the logic seems to be different to the OCL one. OCL assigns the body to the accumulator (the acc var is normally used
-- in the body expressions), whereas QVTo concats (adds) the body to the accumulator (is the acc needed by the body? -> specify/clarify)
context ImperativeIterateExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
if self.condition = child then
parentEnv().nestedEnv()
.addElements(self.ownedIterators)
.addElement(self.target)
else if self.ownedBody = child then
parentEnv().nestedEnv()
.addElements(self.ownedIterators)
else if self.ownedIterators->includes(child) then
parentEnv().nestedEnv()
.addElements(self.ownedIterators->select(x | self.ownedIterators->indexOf(x) < self.ownedIterators->indexOf(child)))
else
parentEnv()
endif endif endif
-- Overwritten. This will be autogenerated
context SwitchExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context AltExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Note, since we have a Top-Down description, the VariableInitExp doesn't contribute nothing to the environment
-- Parents will have to handle when a VariableInitExp is encountered.
-- Overwritten. This will be autogenerated
context VariableInitExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context AssignExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context UnlinkExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
context TryExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
if (self.tryBody->includes(child)) then
parentEnv().nestedEnv()
else
parentEnv()
endif
-- FIXME Issue OMG. Smelly spec and pivot implementation. Think deeper.
--context CatchExp
--def : _env(child : pivot::Element) : lookup::LookupEnvironment =
-- if (self._body = child) then
-- parentEnv().nestedEnv()
-- .addElement(self.ex)
-- else
-- parentEnv()
-- endif
-- Overwritten. This will be autogenerated
context CatchExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context RaiseExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context ReturnExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context BreakExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context LogExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context AssertExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context InstantiationExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context OrderedTupleLiteralPart
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context OrderedTupleType
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context ContinueExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context UnpackExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context DictLiteralExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context ListLiteralExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context Typedef
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context OrderedTupleLiteralExp
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context DictionaryType
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context ImperativeExpression
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context ListType
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
-- Overwritten. This will be autogenerated
context DictLiteralPart
def : _env(child : pivot::Element) : lookup::LookupEnvironment =
parentEnv()
endpackage