% Fetch field from Object

meth GetField =^ ( ·

var index : Int ·

var cl : ClassInfo ·

var fdname : String ·

var entry : CpList ·

var e : object ·

var Obj : ObjectInfo ·

var ref : Object ·

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 field name

currentFrame.FindCPList(index, entry);

 

entry.GetInfo(e);

if [] e isExactly CPentryFieldref ®

(CPentryFieldref) e.Getname(fdname)

[] not(e isExactly CPentryFieldref) ® miracle

fi

% getting the current class

currentFrame.GetcurrentClass(cl);

% getting the reference to the object that holds the field

currentFrame.Pop(ref);

if [] ref isExactly ObjectInfo ® Obj:= (ObjectInfo) ref;

[] not (ref isExactly ObjectInfo) ® miracle

fi

%searching the field name in the object

Obj.GetDataFd(fdname, Ref);

% the Object reference is pushed onto the Operand stack

currentFrame.Push(Ref);

TopFrame.SetFrame(CurrentFrame);

end end end end end end end end

)

end