"
COPYRIGHT (c) 1990 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
"{ Package: 'stx:libcomp' }"
StatementNode subclass:#PrimitiveNode
instanceVariableNames:'code primNumber optional'
classVariableNames:''
poolDictionaries:''
category:'System-Compiler-Support'
!
!PrimitiveNode class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1990 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
documentation
"
node for parse-trees, representing primitive code
This is a helper class for the compiler.
Primitives are (currently) not always supported by the incremental compiler
- if you want a primitive, you must use the stc-compiler and
link a new smalltalk.
On system which support dynamic object loading, methods with primitives are passed
to stc and the resulting binary is loaded into the image
(also a limited set of numeric primitives could be implemented for more ST-80
compatibility - if there is a need).
To allow autoloaded/filedIn code to be written for best performance, an optional
primitive directive (in the primitives first lines comment) may specify an
optional primitive; these are compiled on systems which do support binary code
loading, and ignored completely on others.
[author:]
Claus Gittinger
"
! !
!PrimitiveNode class methodsFor:'instance creation'!
code:aString
^ self basicNew code:aString
!
primitiveNumber:anInteger
^ self basicNew primitiveNumber:anInteger
! !
!PrimitiveNode methodsFor:'accessing'!
code:aString
"set the primitives code - check for the 'OPTIONAL' directive"
|firstLine commentPos words|
code := aString.
optional := false.
firstLine := aString readStream nextLine.
commentPos := firstLine indexOfSubCollection:'/*'.
commentPos ~~ 0 ifTrue:[
words := (firstLine copyFrom:(commentPos + 2)) asCollectionOfWords.
(words includes:'OPTIONAL') ifTrue:[
optional := true
]
]
"Modified: 24.10.1995 / 11:29:51 / cg"
!
primitiveNumber:anInteger
optional := false.
primNumber := anInteger
! !
!PrimitiveNode methodsFor:'code generation'!
codeForSideEffectOn:aStream inBlock:b for:aCompiler
"catch code generation"
optional ifTrue:[^ self].
aCompiler class newPrimitives == true ifTrue:[^ self].
self error:'cannot compile primitives (as yet)' mayProceed:true
!
codeOn:aStream inBlock:b for:aCompiler
"catch code generation"
optional ifTrue:[^ self].
aCompiler class newPrimitives == true ifTrue:[^ self].
self error:'cannot compile primitives (as yet)' mayProceed:true
! !
!PrimitiveNode methodsFor:'evaluation'!
evaluateExpressionIn:anEnvironment
"catch evaluation"
optional ifTrue:[^ nil].
self error:'cannot evaluate primitives' mayProceed:true
!
evaluateIn:anEnvironment
"catch evaluation"
optional ifTrue:[^ nil].
self error:'cannot evaluate primitives' mayProceed:true
! !
!PrimitiveNode methodsFor:'queries'!
isConstant
^ false
!
isOptional
^ optional
! !
!PrimitiveNode class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libcomp/PrimitiveNode.st,v 1.20 2003-03-28 14:39:00 cg Exp $'
! !