This section defines the functions available in user primitives:
These functions enable users to allocate new objects from within a user primitive.
Error cases: If the object could not be allocated for any reason, returns NULL.
Smalltalk equivalent: allocateClass new: size
Side effects: This operation can cause a garbage collection.
Error cases: If the object could not be allocated for any reason, returns NULL.
Smalltalk equivalent: (allocateClass new: size) makeFixed
This function enables users to send a message from within a user primitive and retrieve the result.
Error cases: Returns an EsPrimErr code.
Side effects: This operation can cause a garbage collection.
These functions enable users to determine what the class and type (immediate, bytes, words, longs, or pointers) of an object are.
Smalltalk equivalent: object class
These functions enable users to convert Smalltalk objects into C values for processing in a user primitive.
Error cases: smallInteger is assumed to be a smallInteger.
Error cases: character is assumed to be a character. Some IBM Smalltalk characters will not fit in a char. The return value in this case is unspecified.
Error cases: character is assumed to be a character.
Error cases: An error occurs if object is not a smallInteger or largeInteger. An error occurs if the value of the number cannot fit in 32 bits signed.
Error cases: An error occurs if object is not a smallInteger or largeInteger. An error occurs if the value of the number cannot fit in 32 bits unsigned.
Error cases: An error occurs if object is not a Float.
These functions enable users to convert C values into their corresponding objects for returning to Smalltalk.
Error cases: Not all signed 32-bit values can fit in a smallInteger. No range check is done on value. Use EsI32ToInteger or EsU32ToInteger if you are not certain that value fits.
Error cases: An error occurs if the new integer object cannot be allocated.
Side effects: This operation can cause a garbage collection.
Error cases: An error occurs if the new integer object cannot be allocated.
Side effects: This operation can cause a garbage collection.
Error cases: An error occurs if the new Float object cannot be allocated.
Side effects: This operation can cause a garbage collection.
These functions enable users to access the instance variables of an object. For all of the following functions that use an instance variable index, the first instance variable is numbered 1.
Smalltalk equivalent: object class instSize
Smalltalk equivalent: object basicHash
Smalltalk equivalent: object basicSize
Error cases: Assumes that object consists of not immediate.
Error cases: Assumes that object consists of pointers. index is not validated.
Smalltalk equivalent: object instVarAt: index
Error cases: Assumes that object consists of pointers. index is not validated. Stores into read-only objects are not checked.
Smalltalk equivalent: object instVarAt: index put: storedObject
Error cases: Assumes that object consists of pointers and is indexable. index is not validated.
Smalltalk equivalent: object basicAt: index
Error cases: Assumes that object consists of pointers and is indexable. index is not validated. Stores into read-only objects are not checked.
Smalltalk equivalent: object basicAt: index put: storedObject
Error cases: Assumes that object consists of bytes. index is not validated.
Smalltalk equivalent: object basicAt: index
Error cases: Assumes that object consists of bytes. index is not validated. Stores into read-only objects are not checked.
Smalltalk equivalent: object basicAt: index put: value
Error cases: Assumes that object consists of words. index is not validated.
Smalltalk equivalent: object basicAt: index
Error cases: Assumes that object consists of words. index is not validated. Stores into read-only objects are not checked.
Smalltalk equivalent: object basicAt: index put: value
Error cases: Assumes that object consists of longs. index is not validated.
Smalltalk equivalent: object basicAt: index
Error cases: Assumes that object consists of longs. index is not validated. Stores into read-only objects are not checked.
Smalltalk equivalent: object basicAt: index put: value
Error cases: Assumes that object consists of bytes. index is not validated.
Smalltalk equivalent: object basicAt: index
Error cases: Assumes that object consists of bytes. index is not validated. Stores into read-only objects are not checked.
Smalltalk equivalent: object basicAt: index put: value
Error cases: Assumes that object consists of words. index is not validated.
Smalltalk equivalent: object basicAt: index
Error cases: Assumes that object consists of words. index is not validated. Stores into read-only objects are not checked.
Smalltalk equivalent: object basicAt: index put: value
Error cases: Assumes that object consists of longs. index is not validated.
Smalltalk equivalent: object basicAt: index
Error cases: Assumes that object consists of longs. index is not validated. Stores into read-only objects are not checked.
Smalltalk equivalent: object basicAt: index put: value
Whenever an object is allocated, a garbage collection might be required. If this happens, all non-immediate object pointers stored in user primitive variables are invalidated. If new objects are allocated in user primitives, they must be explicitly protected from garbage collection using the EsSaveObject / EsRestoreObject protocol.
Each object that is referenced only by the user primitive variables must be saved before any operation that could cause a garbage collection. After that operation completes, the objects must be restored in the reverse order from that in which they were saved. All saved objects must be restored before the user primitive succeeds or fails.
The virtual machine provides the following miscellaneous functions.
For example,
EsObject myObject; EsObject storedObject; EsObject * instVar; instVar = (EsObject *) EsInstVarAddr(myObject); *instVar = storedObject; EsRememberObjectStore(EsPrimVMContext, myObject, storedObject);
Note: | EsAtPut and EsInstVarAtPut automatically call this function. |
U_32 versionNumber; U_16 versionMajor; U_16 versionMinor; versionNumber = EsVMVersion(); versionMajor = versionNumber >> 16; versionMinor = versionNumber & 0xFFFF;
The minor version number should be interpreted as a two-digit decimal number. For example, version 1.21 of the interpreter has minor version 21. Version 1.3 has minor version 30. Both have a major version of 1.
Smalltalk equivalent: System scavenge
Smalltalk equivalent: System globalGarbageCollect
The following classes (all of type EsBehavior) are available during a user primitive: