Text not verified for kermeta 2 | |
---|---|
Kermeta provides basic control structures : block, conditional branch, loop, and exception handling. Here there an excerpt of the Meta-model describing control structures. Each basic control structures derives from the Expression concept.
In the following example, the type of super[ParentClass](element) is CallSuperOperation :
class ParentClass { operation op(element : Integer) : Integer is do result := element + 1 end } class ChildClass inherits ParentClass { method op(element : Integer) : Integer is do result := super[ParentClass](element) end }
The type of callvar , below, is CallVariable:
var myvar : Integer var callvar : Integer init 4 // myvar := callvar
A special case, when calling a lambda expression : the type of lf in the assignment of res, is CallVariable.
var lf : <Integer->Integer> var res : Integerlf := function { i : Integer | i.plus(1) } // The type of lf, below, is CallVariable res := lf(4)
The type of result is CallResult
operation op() : Integer is do result := 61 end
The type of self is a SelfExpression!
The type of attr in the body of the operation myoperation is CallFeature (a callfeature on self ), and so is the type of myoperation(4) (a callfeature on a ).
class A { attribute attr : Integer operation myoperation(param : Integer) : Integer is do result := self.attr + param end } class B { operation anotheroperation() : Integer is do var a : A result := a.myoperation(4) end }
In the following example, thetarget is of type CallExpression and thevalue is of type Expression .
var num : Numeric var thetarget : Integer var thevalue : Integer // assignment : thetarget->target, thevalue->value thetarget := thevalue // casting : a is casted into the type of num which is Numeric. num ?= a
var i : Integer i := 5 // 5 is a IntegerLiteral var s : String s := "I am a string" // "I am a string" is a StringLiteral