EMF TVM opcode list | |||||
# | Opcode | Arguments | Stack | Comment | |
0 | PUSH | 1: value ref | - | Push constant literal onto stack | |
1 | PUSHT | - | - | Push TRUE literal onto stack | |
2 | PUSHF | - | - | Push FALSE literal onto stack | |
3 | POP | - | 0: value | Pops top value from stack | |
4 | LOAD | 1: cb offset | - | Loads local variable value onto stack, given the parent code block offset (0 = this code block) | |
2: varIndex | (varIndex = index of local variable in the local variable table) | ||||
5 | STORE | 1: cb offset | 0: value | Stores top stack value into local variable (and pops), given the parent code block offset | |
2: varIndex | |||||
6 | SET | 1: propname | 0: object | Set object property value | |
1: value | |||||
7 | GET | 1: propname | 0: object | Get object property value onto stack | |
8 | GET_TRANS | 1: propname | 0: object | Get object property transitive closure value onto stack (always a collection) | |
9 | SET_STATIC | 1: fieldname | 0: type | Set static field value | |
1: value | |||||
10 | GET_STATIC | 1: fieldname | 0: type | Get static field value onto stack | |
11 | FINDTYPE | 1: modelname | - | Find type or metaclass in metamodel | |
2: typename | |||||
12 | FINDTYPE_S | - | 0: modelname | Find type or metaclass in metamodel given on the stack | |
1: typename | |||||
13 | NEW | 1: modelname | 0: type | Creates a new model element, given an output model name | |
14 | NEW_S | - | 0: modelname | Creates a new model element, given an output model name on the stack | |
1: type | |||||
15 | DELETE | - | 0: object | Deletes the object on the stack from its model | |
16 | DUP | - | - | Duplicates stack top value | |
17 | DUP_X1 | - | - | Pops top two values from stack, pushes top value, then pushes original two values back | |
18 | SWAP | - | - | Swaps top two values on the stack | |
19 | SWAP_X1 | - | - | Swaps third value over top two values on the stack (abc... → cab...) | |
20 | IF | 1: target offset | 0: boolean value | If stack top value is true, branch to target offset | |
21 | IFN | 1: target offset | 0: boolean value | If stack top value is false, branch to target offset | |
22 | GOTO | 1: target offset | - | Branch to target offset | |
23 | ITERATE | 1: target offset | 0: collection value | Runs the following instructions up to ENDITERATE for each element in the collection; | |
offset marks the matching ENDITERATE | |||||
24 | ENDITERATE | 1: target offset | - | Marks the end of an ITERATE run of instructions; offset marks the matching ITERATE | |
25 | INVOKE | 1: opname | 0..n: arguments | Regular dynamic method invocation, based on runtime type information | |
2: nr_of_args | |||||
26 | INVOKE_SUPER | 1: opname | 0..n: arguments | Dynamic method invocation of superclass, relative to current execution context | |
2: nr_of_args | |||||
27 | INVOKE_STATIC | 1: opname | 0..n: arguments | Static method invocation; first argument is a metaclass, or Java class for native static operations | |
2: nr_of_args | |||||
28 | ALLINST | - | 0: type | Finds all instances of the given type in all input models | |
29 | ALLINST_IN | - | 0: type | Finds all instances of the given type in given input model | |
1: modelname | |||||
30 | ISNULL | - | 0: value | Pushes TRUE if value is null, FALSE otherwise | |
31 | GETENVTYPE | - | - | Pushes the ExecEnv type on the stack | |
32 | NOT | - | 0: boolean value | Pushes TRUE if value is FALSE, FALSE otherwise | |
33 | AND | 1: code block # | 0: first value | Pushes the boolean AND result of the first value and the result of codeblock on the stack | |
34 | OR | 1: code block # | 0: first value | Pushes the boolean OR result of the first value and the result of codeblock on the stack | |
35 | XOR | - | 0: first value | Pushes the boolean XOR result on the stack | |
1: second value | |||||
36 | IMPLIES | 1: code block # | 0: first value | Pushes the boolean IMPLIES result of the first value and the result of codeblock on the stack | |
37 | IFTE | 1: then cb # | 0: boolean value | Executes “then” if TRUE, “else” otherwise | |
2: else cb # | |||||
38 | RETURN | - | - | Returns from a code block | |
39 | GETCB | 1: code block # | - | Pushes nested code block onto the stack (lambda expression) | |
40 | INVOKE_ALL_CBS | 1: nr_of_args | 0..n: arguments | Invokes all nested code blocks and pushes results on the stack | |
41 | INVOKE_CB | 1: code block # | 0..n: arguments | Invokes nested code block (lambda expression) | |
2: nr_of_args | |||||
42 | INVOKE_CB_S | 1: nr_of_args | 0: code block | Invokes code block on stack (lambda expression) | |
1..n: arguments | |||||
43 | MATCH | 1: rulename | 0..n: input elements | Matches the given rule, and invokes the pre-apply code for each match | |
2: nr_of_args | |||||
44 | MATCH_S | 1: nr_of_args | 0: rule | Matches the rule on the stack, and invokes the pre-apply code for each match | |
1..n: input elements | |||||
45 | ADD | 1: propname | 0: object | Adds object property value | |
1: value | |||||
46 | REMOVE | 1: propname | 0: object | Removes object property value | |
1: value | |||||
47 | INSERT | 1: propname | 0: object | Adds object property value at the given index (starting at 0) | |
1: value | |||||
2: index | |||||
Instructions marked in grey are not (yet) used by any compiler for EMFTVM | |||||
EMF TVM file format | |||
Name | Offset | Length | Comment |
Magic | 0 | 4 | “ETVM” in ASCII |
Cpcount | 4 | 4 | Constant pool count = number of entries in the constant pool |
Constant pool | 8 | cpsize | Constant pool table (see detailed description) |
Module name | 8+cpsize | 4 | Reference to module name string in constant pool |
Source name | 12+cpsize | 4 | Reference to source file name in constant pool |
Input model count | 16+cpsize | 4 | Number of input models |
Input model table | 20+cpsize | isz | Table of model declarations (see detailed description) |
Inout model count | 20+cpsize+isz | 4 | Number of input/output models |
Inout model table | 24+cpsize+isz | iosz | Table of model declarations (see detailed description) |
Output model count | 24+cpsize+isz+iosz | 4 | Number of output models |
Output model table | 28+cpsize+isz+iosz | osz | Table of model declarations (see detailed description) |
Import count | 28+cpsize+isz+iosz+osz | 4 | Number of imported modules |
Imports table | 32+cpsize+isz+iosz+osz | itsize | List of name references of imported modules |
Feature count | 32+cpsize+isz+iosz+osz+itsize | 4 | Number of features (fields, operations) |
Feature table | 36+cpsize+isz+iosz+osz+itsize | fsize | Feature table (see detailed description) |
Rule count | 36+cpsize+isz+iosz+osz+itsize+fsize | 4 | Number of transformation rules |
Rule table | 40+cpsize+isz+iosz+osz+itsize+fsize | rtsize | Rule table (see detailed description) |
Constant pool | |||
Name | Offset | Length | Comment |
Tag | 0 | 4 | Constant type tag |
Value | 4 | vsize | Constant value (size depends on tag) |
Tag | Size | Description | |
0 | stringsize | ||
1 | 4 | Integer (see DataInputStream.readInt()) | |
2 | 8 | Double (see DataInputStream.readDouble()) | |
3 | 1 | Byte | |
4 | 1 | Char | |
5 | 4 | Float | |
6 | 2 | Short | |
7 | 8 | Long | |
8 | stringsize | Enumeration literal encoded as a modified UTF-8 string | |
9 | 0 | Null | |
Model declaration table | |||
Name | Offset | Length | Comment |
Model name | 0 | 4 | Model name reference |
Metamodel name | 4 | 4 | Metamodel name reference |
Feature table | |||
Name | Offset | Length | Comment |
Tag | 0 | 4 | Feature type tag |
Feature description | 4 | fsize | Feature (format depends on tag) |
Tag | Description | Format | |
0 | Field | See field entry | |
1 | StaticField | See field entry | |
2 | Operation | See operation entry | |
3 | StaticOperation | See operation entry | |
4 | QueryOperation | See operation entry | |
5 | StaticQueryOperation | See operation entry | |
Field entry | |||
Name | Offset | Length | Comment |
Field name | 0 | 4 | Field name reference |
Field type | 4 | 4 | Field type name reference |
Field type model | 8 | 4 | Field type model name reference |
Field context | 12 | 4 | Field context type reference |
Field context model | 16 | 4 | Field context type model name reference |
Initialiser code block | 20 | csize | Initialisation code block (see code block) |
Operation entry | |||
Name | Offset | Length | Comment |
Operation name | 0 | 4 | Operation name reference |
Return type | 4 | 4 | Operation return type reference |
Return type model | 8 | 4 | Operation return type model name reference |
Operation context | 12 | 4 | Operation context type reference |
Operation context model | 16 | 4 | Operation context type model name reference |
Parameter count | 20 | 4 | Number of parameters |
Parameter table | 24 | ptsize | Parameter table (see static field table) |
Code block | 24+ptsize | csize | Code block (see detailed description) |
Code block | |||
Name | Offset | Length | Comment |
Max. locals | 0 | 4 | Maximum number of local variables (-1 if unknown) |
Max. stack size | 4 | 4 | Maximum number of stack elements (-1 if unknown) |
Local variable count | 8 | 4 | Number of local variables |
Local variable table | 12 | lvsize | Local variable table (see detailed description) |
Line number count | 12+lvsize | 4 | Number of line number table entries |
Line number table | 16+lvsize | lnsize | Line number table (see detailed description) |
Nested code block count | 16+lvsize+lnsize | 4 | Number of nested code blocks |
Nested code blocks | 20+lvsize+lnsize | nsize | Nested code blocks |
Instruction count | 20+lvsize+lnsize+nsize | 4 | Number of instructions |
Instruction list | 24+lvsize_lnsize+nsize | isize | List of instructions (see detailed description) |
Instruction list | |||
Name | Offset | Length | Comment |
Line number index | 0 | 4 | Line number table index, or -1 if no line number available |
Opcode | 4 | 4 | Instruction (see opcode reference) |
Parameter 1 | 8 | 4 | First parameter (depends on instruction) |
Parameter 2 | 12 | 4 | Second parameter (depends on instruction) |
… | |||
Line number table | |||
Name | Offset | Length | Comment |
Start line | 0 | 4 | Start line number |
Start column | 4 | 4 | Start column number |
End line | 8 | 4 | End line number |
End column | 12 | 4 | End column number |
Start character | 16 | 4 | Start character in the source file stream |
End character | 20 | 4 | End character in the source file stream |
Local variable table | |||
Name | Offset | Length | Comment |
Slot | 0 | 4 | Variable slot number (starting at 0) |
Name | 4 | 4 | Variable name reference |
Type | 8 | 4 | Type name reference |
Start instruction | 12 | 4 | Start instruction offset |
End instruction | 16 | 4 | End instruction offset |
Rule table | |||
Name | Offset | Length | Comment |
Rule name | 0 | 4 | Rule name reference |
Rule mode | 4 | 4 | Rule mode code (see detailed description) |
Abstract | 8 | 4 | Whether the rule is abstract (1 or 0) |
Default | 12 | 4 | Whether the rule creates a default trace (1 or 0) |
DistinctElements | 16 | 4 | Whether the rule matches distinct input elements (1 or 0) |
Input element count | 20 | 4 | Number of input model elements |
Input element table | 24 | iesz | Input model element table (see detailed description) |
Output element count | 24+iesz | 4 | Number of output model elements |
Output element table | 28+iesz | oesz | Output model element table (see output element table) |
Super-rule count | 28+iesz+oesz | 4 | Number of super-rules |
Super-rule table | 32+iesz+oesz | srsz | Super-rule table (list of super-rule name references) |
Rule field count | 32+iesz+oesz+srsz | 4 | Number of rule fields |
Rule field table | 36+iesz+oesz+srsz | fsz | Rule field table (see feature table) |
Matcher count | 36+iesz+oesz+srsz+fsz | 4 | Number of matcher code blocks to follow (0 or 1) |
Matcher code block | 40+iesz+oesz+srsz+fsz | msz | Matcher code block (see code block) |
Applier count | 40+iesz+oesz+srsz+fsz+msz | 4 | Number of applier code blocks to follow (0 or 1) |
Applier code block | 44+iesz+oesz+srsz+fsz+msz | asz | Applier code block (see code block) |
Post-apply count | 44+iesz+oesz+srsz+fsz+msz+asz | 4 | Number of post-apply code blocks to follow (0 or 1) |
Post-apply code block | 48+iesz+oesz+srsz+fsz+msz+asz | psz | Post-apply code block (see code block) |
Rule mode | Comment | ||
0 | Manual application | ||
1 | Automatic single application | ||
2 | Automatic recursive application (priority given by rule order of appearance) | ||
Input element table | |||
Name | Offset | Length | Comment |
Element name | 0 | 4 | Input element name reference |
Element type | 4 | 4 | Input element type reference |
Element type model | 8 | 4 | Input element type model name reference |
Element model count | 12 | 4 | Number of input element models |
Element models | 16 | iemsz | Input element model name references |
Output element table | |||
Name | Offset | Length | Comment |
Element name | 0 | 4 | Element name reference |
Element type | 4 | 4 | Element type reference |
Element type model | 8 | 4 | Element type model name reference |
Element model | 12 | 4 | Element model name reference |
Maps to element | 16 | 4 | Source element mapping name reference (or -1) |