Automatic Generation of Glue for Named Primitives

Marcel Weiher marcel at system.de
Tue Sep 14 07:29:58 UTC 1999


> From: "Andrew C. Greenberg" <werdna at gate.net>
>
> My initial reaction to Andreas' excellent suggestions were
> disappointingly clueless.  It is now apparent to me that something of  
> this sort could be relatively straightforward, no less general, and  
> therefore clearly superior to the separate specification approach.  
> Slightly less sugary solutions may even be downright easy.
>
> Thanks, Andreas for tweaking me on the point.  I agree that the
> inline primitive approach is best, and the one used for existing
> primitives is even better.

Andrew,

I actually liked your idea of out-of-line primitive specification a  
lot, except that the method body should simply reference a method  
already implemented in the system.  That would get us closer to  
writing all our code in plain Smalltalk and just adding small amounts  
of information to create compiled representations for speed.

So for example, FlipArrayPlugin would implement

glueSpecification
	^super glueSpecification
		primitive: 'primReverse' on: FlippyArray returns:  
FlippyArray;
			parameter: 'from' as: SmallInteger;
			parameter: 'to' as: SmallInteger;
			instVar: 't' declareC: 'int t';
			instVar: 'a' declareC: 'int a';
			instVar: 'b' declareC: 'int b';
			method: #stReverseFrom:to:.

The primtive invocation code generated from this could then be:

reverseFrom:a to:b
	<primitive: 'primReverse' module: 'flippyArrayPlugin'>
	^self reverseFrom:a to:b.


Marcel





More information about the Squeak-dev mailing list