equal
deleted
inserted
replaced
1 "{ Package: 'stx:goodies/petitparser/compiler' }" |
1 "{ Package: 'stx:goodies/petitparser/compiler' }" |
2 |
2 |
3 "{ NameSpace: Smalltalk }" |
3 "{ NameSpace: Smalltalk }" |
4 |
4 |
5 PPCNodeVisitor subclass:#PPCTokenCodeGenerator |
5 PPCPass subclass:#PPCTokenCodeGenerator |
6 instanceVariableNames:'codeGen' |
6 instanceVariableNames:'codeGen' |
7 classVariableNames:'' |
7 classVariableNames:'' |
8 poolDictionaries:'' |
8 poolDictionaries:'' |
9 category:'PetitCompiler-Visitors-CodeGenerators' |
9 category:'PetitCompiler-Visitors-CodeGenerators' |
10 ! |
10 ! |
11 |
|
12 !PPCTokenCodeGenerator methodsFor:'accessing'! |
|
13 |
|
14 options: args |
|
15 super options: args. |
|
16 codeGen options: args. |
|
17 ! |
|
18 |
|
19 clazz: aPPCClass |
|
20 codeGen clazz: aPPCClass |
|
21 ! ! |
|
22 |
11 |
23 !PPCTokenCodeGenerator methodsFor:'code support'! |
12 !PPCTokenCodeGenerator methodsFor:'code support'! |
24 |
13 |
25 consumeWhitespace: node |
14 consumeWhitespace: node |
26 self assert: node isTokenNode. |
15 self assert: node isTokenNode. |
86 super initialize. |
75 super initialize. |
87 |
76 |
88 codeGen := PPCCodeGen new. |
77 codeGen := PPCCodeGen new. |
89 ! ! |
78 ! ! |
90 |
79 |
|
80 !PPCTokenCodeGenerator methodsFor:'running'! |
|
81 |
|
82 run: ir |
|
83 "Actually run the pass on given IR (tree of PPCNode) and return |
|
84 (possibly transformed or completely new) another IR." |
|
85 |
|
86 context isNil ifTrue:[ |
|
87 PPCCompilationError new signal: 'oops, no context set, use #context: before running a pass!!'. |
|
88 ]. |
|
89 codeGen options: context options. |
|
90 codeGen clazz: context scannerClass. |
|
91 self visit: ir. |
|
92 ^ ir |
|
93 |
|
94 "Created: / 26-08-2015 / 22:39:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
95 ! ! |
|
96 |
91 !PPCTokenCodeGenerator methodsFor:'visiting'! |
97 !PPCTokenCodeGenerator methodsFor:'visiting'! |
92 |
98 |
93 visitToken: tokenNode |
99 visitToken: tokenNode |
94 | scanId id | |
100 | scanId id | |
95 self assert: tokenNode isMarkedForInline not. |
101 self assert: tokenNode isMarkedForInline not. |