--- a/compiler/PPCCodeGenerator.st Wed Aug 26 21:41:20 2015 +0100
+++ b/compiler/PPCCodeGenerator.st Wed Aug 26 23:01:00 2015 +0100
@@ -2,7 +2,7 @@
"{ NameSpace: Smalltalk }"
-PPCNodeVisitor subclass:#PPCCodeGenerator
+PPCPass subclass:#PPCCodeGenerator
instanceVariableNames:'codeGen'
classVariableNames:''
poolDictionaries:''
@@ -25,15 +25,6 @@
!PPCCodeGenerator methodsFor:'accessing'!
-options: args
- super options: args.
- codeGen options: args.
-!
-
-clazz: aPPCClass
- codeGen clazz: aPPCClass
-!
-
codeGen
^ codeGen
!
@@ -43,7 +34,9 @@
!
guards
- ^ options guards
+ ^ context options guards
+
+ "Modified: / 26-08-2015 / 22:17:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPCCodeGenerator methodsFor:'code generation'!
@@ -206,6 +199,26 @@
"Created: / 27-07-2015 / 14:50:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!PPCCodeGenerator methodsFor:'running'!
+
+run: ir
+ "Actually run the pass on given IR (tree of PPCNode) and return
+ (possibly transformed or completely new) another IR."
+
+ | entry |
+
+ context isNil ifTrue:[
+ PPCCompilationError new signal: 'oops, no context set, use #context: before running a pass!!'.
+ ].
+ codeGen options: context options.
+ codeGen clazz: context parserClass.
+ entry := self visit: ir.
+ context parserClass propertyAt:#rootMethod put:entry.
+ ^ ir
+
+ "Created: / 26-08-2015 / 22:38:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!PPCCodeGenerator methodsFor:'support'!
compileTokenWhitespace: node
@@ -951,7 +964,7 @@
self compileTokenWhitespace: node.
- (options guards and: [(guard := PPCGuard on: node) makesSense]) ifTrue: [
+ (context options guards and: [(guard := PPCGuard on: node) makesSense]) ifTrue: [
guard id: id, '_guard'.
codeGen code: 'context atEnd ifTrue: [ self error ].'.
guard compileGuard: codeGen.
@@ -963,14 +976,14 @@
codeGen codeAssign: 'context position + 1.' to: startVar.
codeGen codeEvaluateAndAssign:[ self visit:node child ] to:#whatever.
- (options guards and: [(guard := PPCGuard on: node) makesSense]) ifTrue: [
+ (context options guards and: [(guard := PPCGuard on: node) makesSense]) ifTrue: [
codeGen dedent.
codeGen code: '].'.
].
codeGen codeIf: 'error' then: nil else: [
codeGen codeAssign: 'context position.' to: endVar.
- " self compileSecondWhitespace: compiler."
+ " self compileSecondWhitespace: compiler."
self compileTokenWhitespace: node.
codeGen codeReturn: node tokenClass asString, ' on: (context collection)
@@ -978,6 +991,8 @@
stop: ', endVar, '
value: nil'.
]
+
+ "Modified: / 26-08-2015 / 22:18:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
visitUnknownNode: node