| 
 | 
 
 
 
 | 
| // Minimal sample void foo() { } // Callee push Nil ret foo(); // Caller push "foo" // class name push "operator_popc" push 0 // argcount | flags invoke_static pop | 
 Named parameter
 Named parameter| void foo(int i = 0, String s = Nil); foo(s: "AAL", i: 2); push 2 push "i" push "AAL" push "s" push 2 // number of named params push 0 // number of unnamed params push "foo" callnp | 
 Member Access
 Member Access| class AClass { public: int foo; }; // AClass cls acls.foo = 2; push acls push 2 poke 'foo' // or push 2 push acdk push 'foo' getmemberlval assign // or push acls push 'foo' push 2 invoke | 
| acdk.lang.System.out.println("asdf"); push "acdk/lang/System" push "out" peek_static // top on stack is out push "println" push "asdf" push 1 invoke | 
 Type definitions
 Type definitions| class AClass { public void foo(int i); }; // Case 1 has no OpCode // Case 2 .defclass AClass extends BClass .defmethod void foo (int i) .endclass // Case 3 push "AClass" clsdef // class AClass is on top push "BClass" clsextends push "void" // return type push "foo" // method name push "int" push "i" push 1 // argument count, method flags defmethod pop // removes the class defintion // Case 4 | 
 Persistence
 Persistence String Ressource
 String Ressource Codes
 Codes SymbolTables
 SymbolTables Script
 Script| class AalClassFile { short magic; // 0xaacf int version_mayor; int version_minor; SymbolTableArray symbols; OpCodeArray symbols; CodeArray codes; // debug information }; | 
 ActivationFrame
 ActivationFrame General
 General| // AFS = ActivationFrameStack int foo(int i) // AFS[0] { int j; // AFS[1] { // // AFS[2] return i; } } AFS[1]: pop ScriptVar(int(0)); ret AFS[0][0]. // save AFS[0][0] value and unwind AFS until function will be leaved. | 
| void foo() { int i = 42; i = i + 1; if (i == 42) return; int j = i; return j; } | 
| lvar int push 42 store 0 ... lval int load 0 store 1 load 1 ret | 
 Function ActivationFrame
 Function ActivationFrame| foo(42, 41); push 41 push 42 push 2 // 2 arguments, 0 unnamed, standard call call foo int foo(int i, int j) { //Stack: i, j, Number of arguments (2) return i + j; pop AFS[0][2] pop AFS[0][1] add ret AFS[0][0] } // | 
| invokation flags = number of arguments (byte) | number of named arguments (byte) << 8 unused << 16 flags << 24 flags: enum InvokationFlags { StandardFrame = 0x00, }; | 
 Exceptions
 Exceptions Script
 Script| // function and global ActivationFrame class ActivationFrame : implements OpCode { ScriptVar _returnValue; RThrowable _activeException; ActivationFrame(ActivationFrame* parent = 0); void execute(); void unwind(); } // a block class ActivationFrameScope { ActivationFrame& _af; int _top; void unwind(); } | 
| createaf clvar int void foo(int i) { // createafscope int j = 1; // clval int // push 1 // store AF[1] { // createafscope int j = i; // clval int // load AF[0] // store AF[2] } // destroyafscope j = 2; // push 2 // store AF[1] int k = 1; // clval int // push 1 // store AF[2] } // destroyafscope // destroyaf | 
| int i; while (i < 3) i = i + 1; clval int // asume on AF[1] loopentry: load 1 push 3 lt brnull loopexit load 1 push 1 add store 1 br loopentry loopexit: | 
| Same now with block: while (i < 3) { i = i + 1; } clval int // asume on AF[1] loopentry: oopentry: load 1 push 3 lt brnull loopexit createafscope load 1 push 1 add store 1 destroyafscope br loopentry loopexit: | 
 ClazzInfo Ressource
 ClazzInfo Ressource OpStatements
 OpStatements Optimizations
 Optimizations Elimination of local temp vars
 Elimination of local temp vars| 0: clvr 0 1: push ""Hello "" 2: push "acdk/lang/StringBuffer" 3: push 1 4: new 5: store 0 lvar 0 will only used in next line (pop stack and store at 0) 6: load 0 (load 0 and push on stack 7: clvr 1 8: store 1 9: push ""ACDK"" 10: push "append" 11: load 1 12: push 1 13: invoke 14: pop Can be: 0: <deleted> 1: push ""Hello "" 2: push "acdk/lang/StringBuffer" 3: push 1 4: new 5: <deleted> 6: <deleted> 7: clvr 0 8: store 0 9: push ""ACDK"" 10: push "append" 11: load 0 12: push 1 13: invoke 14: pop | 
 Op Codes
 Op Codes Stack
 Stack| AAL | JVM | CIL | Explenation | 
|---|---|---|---|
| nop | ? | nop | No operation | 
| ldc | loadx | ldc | Load constant on stack | 
| dup | ? | dup | Duplicates the top most element | 
 Arithmetik and Logical Ops
 Arithmetik and Logical Ops| AAL | JVM | CIL | Explenation | 
|---|---|---|---|
| add | ? | add | Add both values on top | 
 Branches
 Branches| AAL | JVM | CIL | Explenation | 
|---|---|---|---|
| br | ? | br | Branch (goto) to label | 
| brtrue | ? | brtrue | Branch (goto) to label if true | 
| brfalse | ? | brtrue | Branch (goto) to label if false | 
 Invokation
 Invokation| AAL | JVM | CIL | Explenation | 
|---|---|---|---|
| inv | ? | callvirt | Call the virtual method | 
| invs | ? | ? | Invoke Static | 
| inve | ? | ? | Invoke with extended Invokation Frame | 
| invse | ? | ? | Invoke static with extended Invokation Frame | 
| new | ? | ? | create new Object. Also pass allocator | 
| newe | ? | ? | create new Object with extended Invokation Frame |