2005/5/10

     
 

AAL OpCode DMI Interface

artefaktur

| Expressions | Statements | Class | DMI Interface |

Intermediate OpCode for AAL.

Content of this chapter:

   Basics
   Implementation
   DMI Client
     invoke
     peek
     peek_static
   DMI Server

 Basics

In connection with the StandardDispatch DMI interface an connector as DMI Server and DMI client should be used. In the first implementation of internal AAL objects this interface should also be used for internal object invocation.

 Implementation

A ClazzInfo can have an Attribute __acdk_cls_rtext which holds static extension of the class. ClazzInfo->attributeRes[instd_acdk_dmi][objaddrs] == attributeRes and __acdk_obj_rtext which holds instance related extensions:

class InstanceAttributeData
: acdk::lang::Object
{
  typedef core_vector<KeyValue<Object*, ClazzAttributesRes> InstanceAttrMap;
  InstanceAttrMap _data;
  ~InstanceAttributeData()
  {
  }
  KeyValue<StringRes, ClazzAttributeResValue> getAttribute(MetaInfo* mi, Object* o, IN(RString) key)
  {
    
  }
  void releaseObject(Object* o)
  {
    InstanceAttrMap::iterator it = find(o);
    if (it == _data.end())
      return;
    _data.erase(it, it);
  }
};

class DmiRuntimeExt 
{
  RObject _dmiServer;
  RDClazzInfo _clazzInfo;
  core_vector<pair<name, ScriptVar> > _static_fields;
}
extend acdk.lang.Object with String foo(int i) { return i; }
//will add the method to the acdk.lang.Object class
acdk.lang.Object o = new acdk.lang.Object();
extend o with String foo(int i) { return i; }
// will add the method to object instance o only.

 DMI Client

 invoke

Top of Stack before call
----------------------------
int       Invocation flags
obj       Target Object to call
method    String of Method name
arg n     Last Argument
arg n-1
arg 0     First Argument

Top of Stack after call
----------------------------
any       return value of method (can be void)
// method with 2 arguments
str.substr(0, 1);

push 1
push 0
push "substr"
push Var(str)
push 2 // count of arguments and flags
invoke
pop // return value

 peek

 peek_static

Top of Stack before call
----------------------------
int       Invocation flags
str       ClassName
str       MemberName

Top of Stack after call
----------------------------
any       return value of member

 DMI Server