0
|
1 |
"
|
4
|
2 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
53
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
StatementNode subclass:#PrimitiveNode
|
261
|
14 |
instanceVariableNames:'code primNumber optional'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'System-Compiler-Support'
|
0
|
18 |
!
|
|
19 |
|
20
|
20 |
!PrimitiveNode class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
53
|
25 |
All Rights Reserved
|
0
|
26 |
|
20
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
0
|
35 |
|
20
|
36 |
documentation
|
|
37 |
"
|
|
38 |
node for parse-trees, representing primitive code
|
261
|
39 |
This is a helper class for the compiler.
|
0
|
40 |
|
126
|
41 |
Primitives are (currently) not always supported by the incremental compiler
|
20
|
42 |
- if you want a primitive, you must use the stc-compiler and
|
|
43 |
link a new smalltalk.
|
|
44 |
|
126
|
45 |
On system which support dynamic object loading, methods with primitives are passed
|
|
46 |
to stc and the resulting binary is loaded into the image
|
|
47 |
(also a limited set of numeric primitives could be implemented for more ST-80
|
|
48 |
compatibility - if there is a need).
|
|
49 |
|
|
50 |
To allow autoloaded/filedIn code to be written for best performance, an optional
|
|
51 |
primitive directive (in the primitives first lines comment) may specify an
|
|
52 |
optional primitive; these are compiled on systems which do support binary code
|
|
53 |
loading, and ignored completely on others.
|
263
|
54 |
|
|
55 |
[author:]
|
|
56 |
Claus Gittinger
|
20
|
57 |
"
|
|
58 |
! !
|
0
|
59 |
|
|
60 |
!PrimitiveNode class methodsFor:'instance creation'!
|
|
61 |
|
|
62 |
code:aString
|
|
63 |
^ self basicNew code:aString
|
|
64 |
!
|
|
65 |
|
|
66 |
primitiveNumber:anInteger
|
|
67 |
^ self basicNew primitiveNumber:anInteger
|
|
68 |
! !
|
|
69 |
|
|
70 |
!PrimitiveNode methodsFor:'accessing'!
|
|
71 |
|
|
72 |
code:aString
|
126
|
73 |
"set the primitives code - check for the 'OPTIONAL' directive"
|
|
74 |
|
|
75 |
|firstLine commentPos words|
|
|
76 |
|
|
77 |
code := aString.
|
|
78 |
optional := false.
|
|
79 |
|
|
80 |
firstLine := aString readStream nextLine.
|
|
81 |
commentPos := firstLine indexOfSubCollection:'/*'.
|
|
82 |
commentPos ~~ 0 ifTrue:[
|
|
83 |
words := (firstLine copyFrom:(commentPos + 2)) asCollectionOfWords.
|
|
84 |
(words includes:'OPTIONAL') ifTrue:[
|
|
85 |
optional := true
|
|
86 |
]
|
|
87 |
]
|
|
88 |
|
|
89 |
"Modified: 24.10.1995 / 11:29:51 / cg"
|
0
|
90 |
!
|
|
91 |
|
|
92 |
primitiveNumber:anInteger
|
126
|
93 |
optional := false.
|
0
|
94 |
primNumber := anInteger
|
|
95 |
! !
|
|
96 |
|
|
97 |
!PrimitiveNode methodsFor:'code generation'!
|
|
98 |
|
104
|
99 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler
|
0
|
100 |
"catch code generation"
|
|
101 |
|
126
|
102 |
optional ifTrue:[^ self].
|
0
|
103 |
self error:'cannot compile primitives (as yet)'
|
|
104 |
!
|
|
105 |
|
104
|
106 |
codeOn:aStream inBlock:b for:aCompiler
|
0
|
107 |
"catch code generation"
|
|
108 |
|
126
|
109 |
optional ifTrue:[^ self].
|
0
|
110 |
self error:'cannot compile primitives (as yet)'
|
|
111 |
! !
|
140
|
112 |
|
|
113 |
!PrimitiveNode methodsFor:'evaluating'!
|
|
114 |
|
|
115 |
evaluate
|
|
116 |
"catch evaluation"
|
|
117 |
|
|
118 |
optional ifTrue:[^ nil].
|
|
119 |
self error:'cannot evaluate primitives'
|
|
120 |
!
|
|
121 |
|
|
122 |
evaluateExpression
|
|
123 |
"catch evaluation"
|
|
124 |
|
|
125 |
optional ifTrue:[^ nil].
|
|
126 |
self error:'cannot evaluate primitives'
|
|
127 |
! !
|
|
128 |
|
|
129 |
!PrimitiveNode methodsFor:'queries'!
|
|
130 |
|
|
131 |
isConstant
|
|
132 |
^ false
|
|
133 |
!
|
|
134 |
|
|
135 |
isOptional
|
|
136 |
^ optional
|
|
137 |
! !
|
|
138 |
|
148
|
139 |
!PrimitiveNode class methodsFor:'documentation'!
|
|
140 |
|
|
141 |
version
|
263
|
142 |
^ '$Header: /cvs/stx/stx/libcomp/PrimitiveNode.st,v 1.15 1996-04-25 17:08:39 cg Exp $'
|
148
|
143 |
! !
|