--- a/compiler/PPCScannerCodeGenerator.st Wed Aug 26 23:34:48 2015 +0100
+++ b/compiler/PPCScannerCodeGenerator.st Sat Aug 29 07:56:14 2015 +0100
@@ -2,8 +2,8 @@
"{ NameSpace: Smalltalk }"
-Object subclass:#PPCScannerCodeGenerator
- instanceVariableNames:'codeGen fsa options incommingTransitions resultStrategy fsaCache'
+PPCPass subclass:#PPCScannerCodeGenerator
+ instanceVariableNames:'codeGen fsa incommingTransitions resultStrategy fsaCache'
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Scanner'
@@ -25,15 +25,6 @@
compiler
^ self codeGen
-!
-
-options
- ^ options
-!
-
-options: anObject
- options := anObject.
- codeGen options: anObject.
! !
!PPCScannerCodeGenerator methodsFor:'analysis'!
@@ -409,12 +400,14 @@
builder := PPCClassBuilder new.
- builder compiledClassName: options scannerName.
- builder compiledSuperclass: options scannerSuperclass.
+ builder compiledClassName: context options scannerName.
+ builder compiledSuperclass: context options scannerSuperclass.
builder methodDictionary: codeGen clazz methodDictionary.
builder constants: codeGen clazz constants.
- ^ builder compileClass.
+ ^ builder compileClass.
+
+ "Modified: / 03-09-2015 / 22:00:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPCScannerCodeGenerator methodsFor:'initialization'!
@@ -423,9 +416,38 @@
super initialize.
codeGen := PPCFSACodeGen new.
- options := PPCCompilationOptions default.
+ context := PPCCompilationContext new.
fsaCache := IdentityDictionary new.
- "Modified: / 24-08-2015 / 23:39:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 03-09-2015 / 22:27:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!PPCScannerCodeGenerator methodsFor:'running'!
+
+run: ir
+ "Actually run the pass on given IR (tree of PPCNode) and return
+ (possibly transformed or completely new) another IR."
+
+ | fsas |
+
+ fsas := IdentitySet new.
+ fsaCache := IdentityDictionary new.
+ fsas addAll:(ir allNodes
+ select:[:node | node hasFsa ]
+ thenCollect:[:node | node fsa ]).
+ fsas addAll:(ir allNodes
+ select:[:node | node hasNextFsa ]
+ thenCollect:[:node | node nextFsa ]).
+ fsas := fsas select:[:each | each hasDistinctRetvals].
+ codeGen clazz:context scannerClass.
+ codeGen options: context options.
+
+ fsas do:[:each |
+ self generate:each
+ ].
+ ^ ir
+
+ "Created: / 03-09-2015 / 21:55:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 04-09-2015 / 06:21:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+