% Invoke methods

meth Invoke =^ (

var count : Int

var index : Int

var Found : Boolean

var b : Bytecode

var MtdName : String

var MtdDescriptor : String

var entry : CpList

var e : Object

var objref : Object

var Mtd : MethodInfo

var objcl : ClassInfo

var frame : FrameInfo

var CurrentFrame : FrameInfo

TopFrame.GetFrame(CurrentFrame);

% getting the entry number of the Constant Pool

currentFrame.GetNextBytecode(b);

b.GetCode(index);

% searching the constant pool – Finding the Methodref entry

currentFrame.FindCPList(index, entry);

entry.GetInfo(e);

if [] e isExactly CpentryMethodref

(CpentryMethodref)e.Getcl(CPcl)

(CpentryMethodref)e.GetName(MtdName);

(CpentryMethodref)e.GetDescriptor(MtdDescriptor);

[] not(e isExactly CpentryMethodref) miracle

fi

% retrieving the actual class of objectref

currentFrame.Pop(Objref);

currentFrame.push(Obfref);

if [] Objref isExactly ObjectInfo

(ObjectInfo)Objref.Getcl(Objcl)

[] not(Objref isExactly ObjectInfo) miracle

fi

% Locating a method

found:= False;

Objcl.MtdLookup(Mtdname, MtdDescriptor, Mtd, Found);

% creating a new frame

frame:= new FrameInfo;

Mtd.GetfstBytecode(b);

frame.SetPC(b);

frame.SetcurrentClass(cl);

frame.SetcurrentMethod(Mtd);

% the nargs arguments are popped from the current

% operand stack. A new stack frame is created for the method

% being invoked, and the arguments are made the values of its

% first nargs local variables.

entry.Getnargs(count);

Rec Loop

If [] Count > 0

Count: = count –1;

currentFrame.Pop(D);

Frame.AppendLocal(D);

Loop;

[] Count = 0 skip;

Fi

end

% pushing the new stack Frame

TopFrame.SetFrame(CurrentFrame);

TopFrame.Push(TopFrame,Frame);

end end end end end end end end end end end end end

)

end