The Object Interface Library is a collection of patterns that forms a
lowlevel runtime interface to objects. It allows the user to read and
manipulate the runtime state of objects and prototypes.
This is a short description of the functionality. Please refer to the
interface file for parameters etc.
Each object-descriptor in a BETA fragments gives rise to a prototype.
The library defines the following patterns for dealing with prototypes:
- protoType: Prototype is a highlevel model of the lowlevel
prototype. It has the following attributes:
- address: is the memory address of the actual prototype.
- GCtab: is the distance to allocation tables, used by garbage collector.
- OriginOff: is the offset of the origin field.
- GPart: is the address of the generation entry point
corresponding to the prototype.
- Size: is the size of the objects with this prototype.
- Prefix: is the address of the prefix (super) pattern.
- LabId: is the name of objects used in dumps.
- GroupId: is the name of the file, where the pattern is declared.
- ScanRefs: scans through references in this prototype. See later.
- ScanSimples: scans through simple attributes in this prototype.
- AstIndex: is the ast-index corresponding to this prototype. Must
be doubled before used with indexToNode. Eg. pt.astIndex*2->ff.indexToNode;
- formIndex: this is the index of the form containing the
descriptor corresponding to this prototype.
- getProtoTypeForStruc: Returns the prototype corresponding to a
pattern-variable.
- getProtoType: Returns the prototype corresponding to a object.
- getProtoField: Returns the prototype-field of a object. Will not
work on components.
- putProtoField: Sets the prototype-field of a object.
- IsPrototypeOfProcess: Returns true if the address is a prototype
in the program.
ScanRefs:
The ScanRefs scans a prototype for references. You can use it
to investigate the references in a object. It calls INNER for every
reference. IsStatic is true if the reference is static. thisProto is
the prototype address of static inlined objects. refType is the type
of the dynamic reference.
Here is an example from the sysutils/demo/objectinterface/objint.bet
demo:
proto.scanRefs
(#
do (if isStatic then
'\tStatic reference at offset ' -> puttext
else
'\tDynamic reference at offset ' -> puttext
if);
thisOffset -> putint; newline
#); |
The library defines the following patterns for
- isComponent: Determines if a object is a BETA component.
- objectToComponent: Used to convert a object reference to a
component reference.
- componentToObject: Used to convert a component reference to a
object reference.
ObjectToComponent is often needed in situation where the THIS construct
is used on components. Eg:
(# mySystem:System
(# ...
myfork:
(#
do THIS(system)[]->objectToComponent->fork;
(* fork is in basicsystemenv.bet *)
#);
#)
#); |
"THIS(System)" is a object reference and fork needs a component reference.
The library defines the following patterns for
- getPatternName: Return the name of the pattern this object is
instance of.
- getOrigin: Returns the origin (enclosing) object.
- getGCField: Return the GC field of the object.
- addressToObject: Converts a address (integer) to a object reference.
- printObject: Prints a low-level textual form of a object.
- assignRef: Assigns a object reference to a object field using
integer addresses.
- getOIDforObject: Returns a unique integer object ID.
- getObjectByOID: Return a object reference from a integer object ID.
The library defines the following patterns for handling groups.
These are only for very advanced use.
- group_header: is a highlevel description of objectcode-groups.
- NextGroup: returns the next/first group in the executable.
- NameOfGroup: returns address of the groups groupname.
- AddGroup: Appends a new groups to the list.
- IsPrototypeOfGroup: returns true if a prototype is in a group.
The library also contains this pattern:
- extGetCstring: converts a address of a c-string to a BETA char repetition.
System Utilities - Reference Manual |
© 1994-2004 Mjølner Informatics |
[Modified: Friday April 6th 2001 at 12:43]
|