artefaktur
software engineer &        architecture

 
 
 
 

AAL OpCode Class

| Expressions | Statements | Class | DMI Interface |

Intermediate OpCode for AAL.

Content of this chapter:

   Class definitions and DMI
   Activation Frame
     Format
     Sample
   invoke
     Caller
     Callee
   peek
   Constructor
     new
       Caller
       Callee
   Destructor

 Class definitions and DMI

In the first implementation a class invocation should be handled via DMI. Later it may be usefull to implement a native OpCode interface. See also:  DMI Interface.

 Activation Frame

  • Safe PC
  • Pop Arguments and load them into current frame.
  • Jump to first PC of frunction

 Format


 Sample

This is a very simple Activation Frame.
cls.foo("a", 42);

// Caller
push 42
push "a"
load [cls]
push "foo"
push 3 // flags = 2 arguments + this
invoke
pop // return value

// Callee
// Activation Frame
// "foo" and flags (2) will be consumed by invoke
clvr 0
store 0 // this = cls
clvr 1
store 1 // "a"
clvr 2
store 2 // 42


 invoke

 Caller

class AClass 

  String foo(int i) 
  { 
    return acdk.lang.Integer.toString(i) } 
  }
}
s = acls.foo(42);

push 42
load [acls]
push "foo"
push 2    // 2 arguments
invoke
store [s]

 Callee

// code sample see above
ActivateFrame[0] = this
ActivateFrame[1] = int i

 peek

AClass acls = new AClass(42);
int i = acls._ivar;
clvr [x]
load [acls]
push "_ivar"
push 0 // flags
peekr
store [i]

 Constructor

 new

 Caller

Top of Stack before call
----------------------------
int       Invocation flags
str       ClassName
arg n     Last Argument
arg n-1
arg 0     First Argument

Top of Stack after call
----------------------------
obj       new created Object

 Callee

class AClass
{
  AClass() {}
}

// static AClass.AClass
load 0 // load this
push "_init_AClass"
push 0 // args+flags
invoke
ret

// __init_AClass
load 0
ret

<rs>
class AClass
{
  int _var;
  AClass(int v)
  : _var(v)
  {
  }
}

class BClass extends AClass
{
  public BClass(int var)
  : AClass(var)
  {
  }
}

The new already created an Object is in ActivationFrame at index 0
// __init_Bclass(int var)
load 1 // argument
push "__init_AClass"
load 0 // this
push 1
invoke
pop // remove this from stack leaved by __init_AClass
push 0 // push this
ret

// __init_AClass
load 1
push "_var"
load 0 // this
push 0 // flags
poke 
push 0
ret

 Destructor

 
Last modified 2005-05-08 22:35 by SYSTEM By Artefaktur, Ing. Bureau Kommer