compiler/PPCConfiguration.st
changeset 524 f6f68d32de73
parent 515 b5316ef15274
child 525 751532c8f3db
--- a/compiler/PPCConfiguration.st	Mon Aug 17 12:13:16 2015 +0100
+++ b/compiler/PPCConfiguration.st	Mon Aug 24 15:34:14 2015 +0100
@@ -32,8 +32,8 @@
 !PPCConfiguration methodsFor:'accessing'!
 
 arguments
- 				arguments isNil ifTrue: [ arguments := self defaultArguments ].
-				^ arguments
+     				arguments isNil ifTrue: [ arguments := self defaultArguments ].
+                    ^ arguments
 !
 
 arguments: args
@@ -46,7 +46,8 @@
 
 input: whatever
     ir := whatever.
-    self remember: #input.
+    
+    self remember: (self copyTree: ir) as: #input
 !
 
 ir
@@ -106,10 +107,6 @@
 
 !PPCConfiguration methodsFor:'compiling'!
 
-buildClass: compiler
-    self subclassResponsibility
-!
-
 compile: whatever
     | time |
     self input: whatever.
@@ -127,33 +124,33 @@
 !PPCConfiguration methodsFor:'debugging'!
 
 copy: somethingTransformable
+    self deprecated: 'copy on your own, or whatever, but dont use me'.
+    ^ somethingTransformable transform: [ :e | e copy ]
+!
+
+copyTree: somethingTransformable
     ^ somethingTransformable transform: [ :e | e copy ]
 !
 
 remember: key
+    self deprecated: 'use remember:as:'.
+    
     self arguments debug ifTrue: [ 
         history add: key -> (self copy: ir).
     ]
-! !
-
-!PPCConfiguration methodsFor:'hooks'!
-
-codeCompiler
-    ^ PPCCodeGen on: arguments 
 !
 
-codeCompilerOn: args
-    ^ PPCCodeGen on: args
-!
-
-codeGeneratorVisitorOn: compiler
-    ^ arguments codeGenerator on: compiler
+remember: value as: key
+    self arguments debug ifTrue: [ 
+        history add: key -> value.
+    ]
 ! !
 
 !PPCConfiguration methodsFor:'initialization'!
 
 initialize
-    history := OrderedCollection new
+    history := OrderedCollection new.
+    arguments := PPCArguments default.
 ! !
 
 !PPCConfiguration methodsFor:'phases'!
@@ -177,7 +174,8 @@
     ir :=  PPCRecognizerComponentDetector new
         arguments: arguments;
         visit: ir.
-    self remember: #recognizingComponents
+
+    self remember: (self copyTree: ir) as: #recognizingComponents
 !
 
 createTokens
@@ -186,24 +184,8 @@
     ir :=  PPCTokenDetector new
         arguments: arguments;
         visit: ir.
-    self remember: #createTokens
-!
 
-generate
-    |  compiler rootMethod compiledParser |
-    arguments generate ifFalse: [ ^ self ].
-    
-    compiler := self codeCompiler.
-    
-    rootMethod := (self codeGeneratorVisitorOn: compiler)
-        arguments: arguments;
-        visit: ir.
-    
-    compiledParser := self buildClass: compiler.
-    compiledParser startSymbol: rootMethod methodName.
-    compiledParser := compiledParser new.
-    
-    ir := compiledParser.
+    self remember: (self copyTree: ir) as: #createTokens
 !
 
 inline
@@ -212,7 +194,8 @@
     ir := PPCInliningVisitor new
         arguments: arguments;
         visit: ir.
-    self remember: #inline.
+        
+    self remember: (self copyTree: ir) as: #inline.
 !
 
 merge
@@ -222,7 +205,8 @@
     ir :=  PPCMergingVisitor new
         arguments: arguments;
         visit: ir.
-    self remember: #merge
+        
+    self remember: (self copyTree: ir) as: #merge
 !
 
 specialize
@@ -237,13 +221,15 @@
     ir :=  (PPCSpecializingVisitor new
         arguments: arguments;
         visit: ir).
-    self remember: #specialize
+        
+    self remember: (self copyTree: ir) as: #specialize
 !
 
 toPPCIr
     "Creates a PPCNodes from a PPParser"
     ir := ir asCompilerTree.
-    self remember: #ppcNodes
+    
+    self remember: (self copyTree: ir) as: #ppcNodes
 ! !
 
 !PPCConfiguration methodsFor:'reporting'!