author | Claus Gittinger <cg@exept.de> |
Sat, 11 Nov 1995 16:31:47 +0100 | |
changeset 135 | aa4f7b8f121e |
parent 126 | aca2139a3526 |
child 140 | 1ef1d1395146 |
permissions | -rw-r--r-- |
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 |
|
126 | 14 |
instanceVariableNames:'code primNumber optional' |
0 | 15 |
classVariableNames:'' |
16 |
poolDictionaries:'' |
|
17 |
category:'System-Compiler-Support' |
|
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 |
version |
135
aa4f7b8f121e
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
126
diff
changeset
|
37 |
^ '$Header: /cvs/stx/stx/libcomp/PrimitiveNode.st,v 1.11 1995-11-11 15:31:26 cg Exp $' |
20 | 38 |
! |
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
node for parse-trees, representing primitive code |
|
0 | 43 |
|
126 | 44 |
Primitives are (currently) not always supported by the incremental compiler |
20 | 45 |
- if you want a primitive, you must use the stc-compiler and |
46 |
link a new smalltalk. |
|
47 |
||
126 | 48 |
On system which support dynamic object loading, methods with primitives are passed |
49 |
to stc and the resulting binary is loaded into the image |
|
50 |
(also a limited set of numeric primitives could be implemented for more ST-80 |
|
51 |
compatibility - if there is a need). |
|
52 |
||
53 |
To allow autoloaded/filedIn code to be written for best performance, an optional |
|
54 |
primitive directive (in the primitives first lines comment) may specify an |
|
55 |
optional primitive; these are compiled on systems which do support binary code |
|
56 |
loading, and ignored completely on others. |
|
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 |
||
53 | 70 |
!PrimitiveNode methodsFor:'queries'! |
71 |
||
72 |
isConstant |
|
73 |
^ false |
|
126 | 74 |
! |
75 |
||
76 |
isOptional |
|
77 |
^ optional |
|
53 | 78 |
! ! |
79 |
||
0 | 80 |
!PrimitiveNode methodsFor:'accessing'! |
81 |
||
82 |
code:aString |
|
126 | 83 |
"set the primitives code - check for the 'OPTIONAL' directive" |
84 |
||
85 |
|firstLine commentPos words| |
|
86 |
||
87 |
code := aString. |
|
88 |
optional := false. |
|
89 |
||
90 |
firstLine := aString readStream nextLine. |
|
91 |
commentPos := firstLine indexOfSubCollection:'/*'. |
|
92 |
commentPos ~~ 0 ifTrue:[ |
|
93 |
words := (firstLine copyFrom:(commentPos + 2)) asCollectionOfWords. |
|
94 |
(words includes:'OPTIONAL') ifTrue:[ |
|
95 |
optional := true |
|
96 |
] |
|
97 |
] |
|
98 |
||
99 |
"Modified: 24.10.1995 / 11:29:51 / cg" |
|
0 | 100 |
! |
101 |
||
102 |
primitiveNumber:anInteger |
|
126 | 103 |
optional := false. |
0 | 104 |
primNumber := anInteger |
105 |
! ! |
|
106 |
||
107 |
!PrimitiveNode methodsFor:'evaluating'! |
|
108 |
||
109 |
evaluateExpression |
|
110 |
"catch evaluation" |
|
111 |
||
126 | 112 |
optional ifTrue:[^ nil]. |
0 | 113 |
self error:'cannot evaluate primitives' |
114 |
! |
|
115 |
||
116 |
evaluate |
|
117 |
"catch evaluation" |
|
118 |
||
126 | 119 |
optional ifTrue:[^ nil]. |
0 | 120 |
self error:'cannot evaluate primitives' |
121 |
! ! |
|
122 |
||
123 |
!PrimitiveNode methodsFor:'code generation'! |
|
124 |
||
104 | 125 |
codeForSideEffectOn:aStream inBlock:b for:aCompiler |
0 | 126 |
"catch code generation" |
127 |
||
126 | 128 |
optional ifTrue:[^ self]. |
0 | 129 |
self error:'cannot compile primitives (as yet)' |
130 |
! |
|
131 |
||
104 | 132 |
codeOn:aStream inBlock:b for:aCompiler |
0 | 133 |
"catch code generation" |
134 |
||
126 | 135 |
optional ifTrue:[^ self]. |
0 | 136 |
self error:'cannot compile primitives (as yet)' |
137 |
! ! |