compiler/PPCConfiguration.st
changeset 515 b5316ef15274
parent 502 1e45d3c96ec5
child 518 a6d8b93441b0
child 524 f6f68d32de73
--- a/compiler/PPCConfiguration.st	Fri Jul 24 15:06:54 2015 +0100
+++ b/compiler/PPCConfiguration.st	Mon Aug 17 12:13:16 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
@@ -41,7 +41,7 @@
 !
 
 defaultArguments
- 		^ PPCArguments default
+ 				^ PPCArguments default
 !
 
 input: whatever
@@ -98,7 +98,7 @@
 cacheFollowSetWithTokens
     "Creates a PPCNodes from a PPParser"
     | followSets |
-    followSets := ir firstSetsSuchThat: [:e | e isTerminal or: [ e isTokenNode ] ].
+    followSets := ir followSetsSuchThat: [:e | e isTerminal or: [ e isTokenNode ] ].
     ir allNodesDo: [ :node |
         node followSetWithTokens: (followSets at: node)
     ]
@@ -106,9 +106,17 @@
 
 !PPCConfiguration methodsFor:'compiling'!
 
+buildClass: compiler
+    self subclassResponsibility
+!
+
 compile: whatever
+    | time |
     self input: whatever.
-    self invokePhases.
+    
+    time := [ self invokePhases ] timeToRun asMilliSeconds.
+    self reportTime: time.
+    
     ^ ir
 !
 
@@ -130,8 +138,12 @@
 
 !PPCConfiguration methodsFor:'hooks'!
 
+codeCompiler
+    ^ PPCCodeGen on: arguments 
+!
+
 codeCompilerOn: args
-    ^ PPCCompiler on: args
+    ^ PPCCodeGen on: args
 !
 
 codeGeneratorVisitorOn: compiler
@@ -178,18 +190,18 @@
 !
 
 generate
-    | compiler rootMethod compiledParser |
+    |  compiler rootMethod compiledParser |
     arguments generate ifFalse: [ ^ self ].
     
-    compiler := self codeCompilerOn: arguments.
+    compiler := self codeCompiler.
     
     rootMethod := (self codeGeneratorVisitorOn: compiler)
         arguments: arguments;
         visit: ir.
     
-    compiler compileParser.
-    compiler compiledParser startSymbol: rootMethod methodName.
-    compiledParser := compiler compiledParser new.
+    compiledParser := self buildClass: compiler.
+    compiledParser startSymbol: rootMethod methodName.
+    compiledParser := compiledParser new.
     
     ir := compiledParser.
 !
@@ -234,3 +246,11 @@
     self remember: #ppcNodes
 ! !
 
+!PPCConfiguration methodsFor:'reporting'!
+
+reportTime: timeInMs
+    arguments profile ifTrue: [ 
+        Transcript show: 'Time to compile: ', timeInMs asString, ' ms'; cr.
+    ]
+! !
+