equal
deleted
inserted
replaced
1 "{ Package: 'stx:goodies/newcompiler' }" |
1 "{ Package: 'stx:goodies/newcompiler' }" |
2 |
2 |
3 Object subclass:#IRBytecodeGenerator |
3 Object subclass:#IRBytecodeGenerator |
4 instanceVariableNames:'seqOrder orderSeq jumps literals lastLiteral currentSeqId |
4 instanceVariableNames:'seqOrder orderSeq jumps literals lastLiteral currentSeqId |
5 currentSeqNum lastSpecialReturn instrMaps instrMap maxTemp stacks |
5 currentSeqNum lastSpecialReturn instrMaps instrMap maxTemp stacks |
6 stack primNum numArgs properties code seqCode' |
6 stack primNum numArgs properties code seqCode lastLine' |
7 classVariableNames:'BytecodeTable Bytecodes SpecialConstants SpecialSelectors' |
7 classVariableNames:'BytecodeTable Bytecodes SpecialConstants SpecialSelectors' |
8 poolDictionaries:'' |
8 poolDictionaries:'' |
9 category:'NewCompiler-Bytecode' |
9 category:'NewCompiler-Bytecode' |
10 ! |
10 ! |
11 |
11 |
69 maxTemp := 0. |
69 maxTemp := 0. |
70 primNum := 0. |
70 primNum := 0. |
71 numArgs := 0. |
71 numArgs := 0. |
72 currentSeqNum := 0. |
72 currentSeqNum := 0. |
73 orderSeq := OrderedDictionary new. "reverse map of seqOrder" |
73 orderSeq := OrderedDictionary new. "reverse map of seqOrder" |
|
74 lastLine := 0. |
74 |
75 |
75 "starting label in case one is not provided by client" |
76 "starting label in case one is not provided by client" |
76 self label: self newDummySeqId. |
77 self label: self newDummySeqId. |
77 |
78 |
78 "Modified: / 05-11-2008 / 10:33:30 / Jan Vrany <vranyj1@fel.cvut.cz>" |
79 "Modified: / 02-12-2008 / 09:08:44 / Jan Vrany <vranyj1@fel.cvut.cz>" |
79 ! |
80 ! |
80 |
81 |
81 numArgs: n |
82 numArgs: n |
82 |
83 |
83 numArgs := n |
84 numArgs := n |
150 stack := stacks at: seqId ifAbsentPut: [self initializeStackCounter] |
151 stack := stacks at: seqId ifAbsentPut: [self initializeStackCounter] |
151 |
152 |
152 "Modified: / 11-06-2008 / 13:58:56 / Jan Vrany <vranyj1@fel.cvut.cz>" |
153 "Modified: / 11-06-2008 / 13:58:56 / Jan Vrany <vranyj1@fel.cvut.cz>" |
153 ! |
154 ! |
154 |
155 |
|
156 line: line |
|
157 |
|
158 lastLine := line. |
|
159 |
|
160 (line < 256) |
|
161 ifTrue: |
|
162 [self |
|
163 nextPut: #lineno; |
|
164 nextPut: line] |
|
165 ifFalse: |
|
166 [self |
|
167 nextPut: #lineno16; |
|
168 nextPut: line] |
|
169 |
|
170 "Created: / 02-12-2008 / 09:02:30 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
171 ! |
|
172 |
155 popTop |
173 popTop |
156 |
174 |
157 stack pop. |
175 stack pop. |
158 |
176 |
159 self nextPut: #drop |
177 self nextPut: #drop |
303 stack pop: sendNumArgs. |
321 stack pop: sendNumArgs. |
304 |
322 |
305 |
323 |
306 self |
324 self |
307 nextPut: #send; |
325 nextPut: #send; |
308 nextPut: 0; "lineno" |
326 nextPut: lastLine; |
309 nextPut: (self addLiteral: selector); |
327 nextPut: (self addLiteral: selector); |
310 nextPut: sendNumArgs. |
328 nextPut: sendNumArgs. |
311 |
329 |
312 "Created: / 01-12-2008 / 19:47:43 / Jan Vrany <vranyj1@fel.cvut.cz>" |
330 "Created: / 01-12-2008 / 19:47:43 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
331 "Modified: / 02-12-2008 / 09:10:31 / Jan Vrany <vranyj1@fel.cvut.cz>" |
313 ! |
332 ! |
314 |
333 |
315 send: selector numArgs: sendNumArgs toSuperOf: behavior |
334 send: selector numArgs: sendNumArgs toSuperOf: behavior |
316 |
335 |
317 stack pop: sendNumArgs. |
336 stack pop: sendNumArgs. |
318 |
337 |
319 |
338 |
320 self |
339 self |
321 nextPut: #superSend; |
340 nextPut: #superSend; |
322 nextPut: 0; "lineno" |
341 nextPut: lastLine; |
323 nextPut: (self addLiteral: selector); |
342 nextPut: (self addLiteral: selector); |
324 nextPut: sendNumArgs; |
343 nextPut: sendNumArgs; |
325 nextPut: (self addLiteral: behavior superclass) |
344 nextPut: (self addLiteral: behavior superclass) |
326 |
345 |
327 "Created: / 01-12-2008 / 19:48:14 / Jan Vrany <vranyj1@fel.cvut.cz>" |
346 "Created: / 01-12-2008 / 19:48:14 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
347 "Modified: / 02-12-2008 / 09:10:37 / Jan Vrany <vranyj1@fel.cvut.cz>" |
328 ! |
348 ! |
329 |
349 |
330 storeInstVar: index |
350 storeInstVar: index |
331 |
351 |
332 self |
352 self |