On 29 March 2012 11:03, Francisco Garau <[email protected]> wrote: > Hi - in porting the Type Inference Engine to Pharo, I came across this > problem. > > I was using the Interpreter class to help translate from the number of a > primitive into a meaningful selector (eg from 1 to primitiveAdd). > > Any ideas how to achieve something similar in Pharo? > > Assuming primitive numbers haven't changed, I could just copy that > method... >
It is changed, of course, you'd better use Cog's primitive table(s). And i am +100000 for the idea. If you read vm-dev list , i recently pointed out on same thing. It would be nice to replace numbers with selectors. And change the compiler to translate them. > - Francisco > > > In Squeak 2.8: > > Interpreter class >> initializePrimitiveTable > > "This table generates a C switch statement for primitive > dispatching." > > > > "NOTE: The real limit here is 2047, but our C compiler > currently barfs over 700" > > MaxPrimitiveIndex _ 700. > > PrimitiveTable _ Array new: MaxPrimitiveIndex + 1. > > self table: PrimitiveTable from: > > #( "Integer Primitives (0-19)" > > (0 primitiveFail) > > (1 primitiveAdd) > > (2 primitiveSubtract) > > (3 primitiveLessThan) > > (4 primitiveGreaterThan) > > (5 primitiveLessOrEqual) > > (6 primitiveGreaterOrEqual) > > (7 primitiveEqual) > > (8 primitiveNotEqual) > > (9 primitiveMultiply) > > (10 primitiveDivide) > > (11 primitiveMod) > > : > > <and so on> > > -- Best regards, Igor Stasenko.
