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