compiler/PPCConfiguration.st
changeset 531 dc3d13c2837d
parent 530 e36906742693
child 532 132d7898a2a1
--- a/compiler/PPCConfiguration.st	Tue Aug 25 01:30:32 2015 +0100
+++ b/compiler/PPCConfiguration.st	Wed Aug 26 21:41:20 2015 +0100
@@ -3,7 +3,7 @@
 "{ NameSpace: Smalltalk }"
 
 Object subclass:#PPCConfiguration
-	instanceVariableNames:'context options ir history'
+	instanceVariableNames:'context ir history'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'PetitCompiler-Core'
@@ -49,15 +49,6 @@
 
 ir: whatever
     ir := whatever
-!
-
-options
-     				options isNil ifTrue: [ options := self defaultArguments ].
-                    ^ options
-!
-
-options: args
-    options := args
 ! !
 
 !PPCConfiguration methodsFor:'caching'!
@@ -154,21 +145,35 @@
     ]
 ! !
 
+!PPCConfiguration methodsFor:'error handling'!
+
+options
+    ^ context options
+
+    "Modified: / 26-08-2015 / 19:48:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+options: aPPCCompilationOptions
+    context options: aPPCCompilationOptions
+
+    "Created: / 26-08-2015 / 19:56:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !PPCConfiguration methodsFor:'initialization'!
 
 initialize
     history := OrderedCollection new.
     context := PPCCompilationContext new.
-    options := PPCCompilationOptions default.
 
-    "Modified: / 25-08-2015 / 00:02:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 26-08-2015 / 19:49:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !PPCConfiguration methodsFor:'phases'!
 
 cacheFirstFollow
-    options cacheFirstFollow ifFalse: [ ^ self ] .
-    
+    context options cacheFirstFollow ifFalse:[
+        ^ self
+    ].
     self cacheFirstSet.
     self cacheFollowSet.
     self cacheFirstSetWithTokens.
@@ -180,60 +185,61 @@
 !
 
 createRecognizingComponents
-    options recognizingComponents ifFalse: [ ^ self ] .
-    
-    ir :=  PPCRecognizerComponentDetector new
-        options: options;
-        visit: ir.
-
-    self remember: (self copyTree: ir) as: #recognizingComponents
+    context options recognizingComponents ifFalse:[
+        ^ self
+    ].
+    ir := (PPCRecognizerComponentDetector new)
+            options:context options;
+            visit:ir.
+    self remember:(self copyTree:ir) as:#recognizingComponents
 !
 
 createTokens
-    options detectTokens ifFalse: [ ^ self ] .
-    
-    ir :=  PPCTokenDetector new
-        options: options;
-        visit: ir.
-
-    self remember: (self copyTree: ir) as: #createTokens
+    context options detectTokens ifFalse:[
+        ^ self
+    ].
+    ir := (PPCTokenDetector new)
+            options:context options;
+            visit:ir.
+    self remember:(self copyTree:ir) as:#createTokens
 !
 
 inline
-    options inline ifFalse: [ ^ self ].
-    
-    ir := PPCInliningVisitor new
-        options: options;
-        visit: ir.
-        
-    self remember: (self copyTree: ir) as: #inline.
+    context options inline ifFalse:[
+        ^ self
+    ].
+    ir := (PPCInliningVisitor new)
+            options:context options;
+            visit:ir.
+    self remember:(self copyTree:ir) as:#inline.
 !
 
 merge
     "Merge equivalent nodes under one object with single identity"
-    options merge ifFalse: [ ^ self ].
     
-    ir :=  PPCMergingVisitor new
-        options: options;
-        visit: ir.
-        
-    self remember: (self copyTree: ir) as: #merge
+    context options merge ifFalse:[
+        ^ self
+    ].
+    ir := (PPCMergingVisitor new)
+            options:context options;
+            visit:ir.
+    self remember:(self copyTree:ir) as:#merge
 !
 
 specialize
-    options specialize ifFalse: [ ^ self ].
-
-    " 
-        Invokes a visitor that creates specialized nodes
-        for some patterns of PPCNodes, 
-        
-        e.g. $a astar can be represented by PPCCharacterStarNode
+    context options specialize ifFalse:[
+        ^ self
+    ].
+     "
+     Invokes a visitor that creates specialized nodes
+     for some patterns of PPCNodes,
+     
+     e.g. $a astar can be represented by PPCCharacterStarNode
     "
-    ir :=  (PPCSpecializingVisitor new
-        options: options;
-        visit: ir).
-        
-    self remember: (self copyTree: ir) as: #specialize
+    ir := ((PPCSpecializingVisitor new)
+            options:context options;
+            visit:ir).
+    self remember:(self copyTree:ir) as:#specialize
 !
 
 toPPCIr
@@ -246,8 +252,10 @@
 !PPCConfiguration methodsFor:'reporting'!
 
 reportTime: timeInMs
-    options profile ifTrue: [ 
+    context options profile ifTrue: [ 
         Transcript show: 'Time to compile: ', timeInMs asString, ' ms'; cr.
     ]
+
+    "Modified: / 26-08-2015 / 16:35:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !