author | Claus Gittinger <cg@exept.de> |
Mon, 19 Aug 2019 16:21:27 +0200 | |
changeset 4497 | 25868e8ec797 |
parent 4207 | 546b3e3e3df9 |
permissions | -rw-r--r-- |
98 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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 |
" |
|
1785 | 12 |
"{ Package: 'stx:libcomp' }" |
13 |
||
4207 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
1785 | 16 |
Object subclass:#ProgramNodeBuilder |
17 |
instanceVariableNames:'' |
|
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'System-Compiler ST-80-compatibility' |
|
98 | 21 |
! |
22 |
||
23 |
!ProgramNodeBuilder class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
This is a pure mimicri class. |
|
42 |
It is not used by ST/X, but provided to support limited |
|
43 |
compatibility for applications which build up codetrees, |
|
44 |
knowing internals of ST-80's compiler class hierarchy. |
|
45 |
This classes protocol is not (not meant to be) fully covering |
|
46 |
the corresponding ST-80's classes protocol. It maps ST-80 messages |
|
47 |
to corresponding ST/X messages (as far as possible). |
|
48 |
||
49 |
NO WARRANTY and GUARANTEE; this class may be removed without notice. |
|
50 |
" |
|
51 |
! ! |
|
52 |
||
4207 | 53 |
!ProgramNodeBuilder class methodsFor:'tree building'! |
54 |
||
55 |
newMessageReceiver: receiverNode selector: selector arguments: arguments |
|
56 |
selector isUnarySelector ifTrue:[ |
|
57 |
self assert:(arguments isEmptyOrNil). |
|
58 |
^ UnaryNode receiver:receiverNode selector: selector args: arguments |
|
59 |
]. |
|
60 |
selector isBinarySelector ifTrue:[ |
|
61 |
self assert:(arguments size == 1). |
|
62 |
^ BinaryNode receiver:receiverNode selector: selector args: arguments |
|
63 |
]. |
|
64 |
self assert:(arguments notEmptyOrNil). |
|
65 |
^ MessageNode receiver:receiverNode selector: selector args: arguments |
|
66 |
||
67 |
"Created: / 06-08-2006 / 03:02:33 / cg" |
|
68 |
"Modified: / 06-08-2006 / 14:00:47 / cg" |
|
69 |
! ! |
|
70 |
||
98 | 71 |
!ProgramNodeBuilder methodsFor:'tree building'! |
72 |
||
1785 | 73 |
newBlockBody:statements |
74 |
^ (BlockNode arguments:#() home:nil variables:#()) statements:statements |
|
75 |
||
76 |
"Created: / 06-08-2006 / 23:25:36 / cg" |
|
77 |
! |
|
78 |
||
79 |
newGlobal:name |
|
80 |
"return a treeNode for a global variable" |
|
81 |
||
82 |
^ VariableNode globalNamed:name |
|
83 |
||
84 |
"Created: / 06-08-2006 / 01:37:56 / cg" |
|
85 |
! |
|
86 |
||
98 | 87 |
newLiteralValue:aConstantValue |
88 |
"return a treeNode for a literal constant" |
|
89 |
||
2900
a1349983b2e7
Avoid #isKindOf: where possible
Stefan Vogel <sv@exept.de>
parents:
2117
diff
changeset
|
90 |
aConstantValue isAssociation ifTrue:[ |
2117 | 91 |
"/ happens when I am used by ST/80 or VW code, which assumes that a |
92 |
"/ global is stored as association (which it is not in ST/X) |
|
93 |
"/ check the caller and rewrite there. |
|
94 |
self halt:'incompatibility warning' |
|
95 |
]. |
|
1785 | 96 |
|
98 | 97 |
^ ConstantNode value:aConstantValue |
1785 | 98 |
|
99 |
"Modified: / 06-08-2006 / 15:16:04 / cg" |
|
100 |
! |
|
101 |
||
102 |
newMessageReceiver: receiverNode selector: selector |
|
103 |
^ self newMessageReceiver: receiverNode selector: selector arguments: #() |
|
104 |
||
105 |
"Created: / 06-08-2006 / 02:59:55 / cg" |
|
106 |
"Modified: / 06-08-2006 / 13:29:33 / cg" |
|
107 |
! |
|
108 |
||
4207 | 109 |
newMessageReceiver:arg1 selector:arg2 arguments:arg3 |
110 |
^ self class newMessageReceiver:arg1 selector:arg2 arguments:arg3 |
|
1785 | 111 |
! |
112 |
||
113 |
newMethodArgument:name |
|
114 |
"return a treeNode for a method arg" |
|
115 |
||
116 |
^ VariableNode methodArgumentNamed:name |
|
117 |
||
118 |
"Created: / 06-08-2006 / 01:15:33 / cg" |
|
119 |
"Modified: / 06-08-2006 / 13:29:42 / cg" |
|
120 |
! |
|
121 |
||
122 |
newMethodLocal:name |
|
123 |
"return a treeNode for a method local" |
|
124 |
||
125 |
^ VariableNode methodLocalNamed:name |
|
126 |
||
127 |
"Created: / 06-08-2006 / 02:10:52 / cg" |
|
128 |
"Modified: / 06-08-2006 / 13:29:46 / cg" |
|
129 |
! |
|
130 |
||
131 |
newMethodSelector:sel |
|
132 |
^ MethodNode new selector:sel |
|
133 |
||
134 |
"Created: / 06-08-2006 / 01:17:16 / cg" |
|
135 |
"Modified: / 06-08-2006 / 13:29:56 / cg" |
|
136 |
! |
|
137 |
||
138 |
newMethodSelector:sel arguments:argVars temporaries:localVars statements:statementNodes |
|
139 |
^ MethodNode new |
|
140 |
selector:sel |
|
141 |
arguments:argVars |
|
142 |
locals:localVars |
|
143 |
statements:statementNodes. |
|
144 |
||
145 |
"Modified: / 06-08-2006 / 13:30:01 / cg" |
|
146 |
! |
|
147 |
||
148 |
newParameterVariable:aNode |
|
149 |
^ Variable name:(aNode name) |
|
150 |
||
151 |
"Created: / 06-08-2006 / 14:23:25 / cg" |
|
98 | 152 |
! |
153 |
||
154 |
newReturnValue:anExpressionNode |
|
155 |
"return a treeNode for a method-return" |
|
156 |
||
157 |
^ ReturnNode expression:anExpressionNode |
|
158 |
! |
|
159 |
||
1785 | 160 |
newSelf |
161 |
^ SelfNode new |
|
162 |
||
163 |
"Created: / 06-08-2006 / 13:51:17 / cg" |
|
98 | 164 |
! ! |
1785 | 165 |
|
166 |
!ProgramNodeBuilder class methodsFor:'documentation'! |
|
167 |
||
168 |
version |
|
4207 | 169 |
^ '$Header$' |
1785 | 170 |
! ! |
4207 | 171 |