Automatic Generation of Glue for Named Primitives

Andrew C. Greenberg werdna at gate.net
Wed Sep 15 06:38:05 UTC 1999


As much as I like Andreas' appeal to the existing infrastructure for 
specially compiled primitives, I think the desire to make it too much 
like pure Smalltalk may have gone too far.  The limitation of an 
Integer return value may be too great, and the automatic coercions 
seem, to me, something that ought to be at most optional, if there at 
all.  A decent, relatively orthogonal set of primitives ought to be 
easy to work with, and might be enough to make these prims accessable 
to a broader public.

This permits manipulation of globals as easily as locals, without 
mystifying the process.  Too much black magic can be scary.  The 
parameter and receiver loading can be automated, and returns 
automated likewise (with a test for primitive failure, permitting 
also a return of self), but always loading oops (unless, perhaps a 
special directive for coercion is given).  The following could then 
be implemented as straightline builtins (with corresponding 
definitions for interpretation).  InterpreterProxy would still be 
available, but used primarily for deeper hacking.  If we want to be 
really hardworking, we can (I suppose) provide "checked" verions of 
these operators.

For traditional Scalars:

oop asCInt
oop asCPositive32BitValue
oop asCBoolean
oop asCDouble

cIntOrChar asSmallIntegerObj
cIntOrChar asPositive32Obj
cIntOrChar asBooleanObj
doubleOrFloat asFloatObj

To get oops of named instance variables By Name:

oop asIf: Object var: 'string'
oop asIf: Object var: 'string' put: value

To get oops of named instance variables By FieldNumber:

oop field: aNumber
oop field: aNumber put: value

To get oops (or values when isBytesOrWords) of Indexable Objects:

oop size

(the easy way)
oop stAt: anIndex
oop stAt: anIndex put: value

(the faster way)
oop asCCharPtr
oop asCIntPtr

To test:

isFloat
isIndexable
isInteger
isWords
isBytes
isWordsOrBytes
isPointers
isNil

(Hopefully, we will some day harmonize the Behavior versions of these 
tests with the interpreter versions. . .)





More information about the Squeak-dev mailing list