compiler/PPCCompiler.st
changeset 503 ff58cd9f1f3c
parent 489 0ca7a70db0f5
parent 502 1e45d3c96ec5
child 505 19d830b74322
--- a/compiler/PPCCompiler.st	Fri Jun 19 08:13:39 2015 +0100
+++ b/compiler/PPCCompiler.st	Fri Jul 24 15:37:23 2015 +0100
@@ -17,21 +17,15 @@
 new
     "return an initialized instance"
 
-    ^ self basicNew initializeForCompiledClassName: 'PPGeneratedParser'
-!
-
-newForCompiledClassName: aString
-    "return an initialized instance"
-	self halt: 'deprecated'.
-    ^ self basicNew initializeForCompiledClassName: aString
+    ^ self on: PPCArguments default
 !
 
 on: aPPCArguments
     "return an initialized instance"
 
     ^ self basicNew
-		arguments: aPPCArguments;
-		initializeForCompiledClassName: aPPCArguments name
+                arguments: aPPCArguments;
+                initializeForCompiledClassName: aPPCArguments parserName
 ! !
 
 !PPCCompiler methodsFor:'accessing'!
@@ -133,6 +127,12 @@
     currentMethod addOnLine: string.
 !
 
+addVariable: name
+    ^ self currentNonInlineMethod addVariable: name
+
+    "Modified: / 23-04-2015 / 17:34:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 call: anotherMethod
     currentMethod add: anotherMethod call.
 !
@@ -199,6 +199,7 @@
     method := [
             aBlock value
         ] ensure:[ returnVariable := tmpVarirable ].
+    self assert: (method isKindOf: PPCMethod).
     method isInline ifTrue:[
         self callOnLine:method
     ] ifFalse:[
@@ -243,9 +244,9 @@
     (variable == #whatever) ifFalse: [ 
         "Do not assign, if somebody does not care!!"
         self add: variable, ' ', selector,' ', argument.
- 	] ifTrue: [ 
+ 		] ifTrue: [ 
         "In case argument has a side effect"
- 		self add: argument	
+ 				self add: argument	
     ]
 !
 
@@ -336,16 +337,16 @@
 
 codeReturn
    currentMethod isInline ifTrue: [
-        "If inlined, the return variable already holds the value"
-    ] ifFalse: [
-        arguments profile ifTrue:[ 
-            self codeProfileStop.
-        ]. 
-        self add: '^ ', currentMethod returnVariable  
-    ].
+		"If inlined, the return variable already holds the value"
+	] ifFalse: [
+		arguments profile ifTrue:[ 
+			self codeProfileStop.
+		]. 
+		self add: '^ ', currentMethod returnVariable  
+	].
 
-    "Created: / 23-04-2015 / 18:01:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 01-06-2015 / 21:49:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+	"Created: / 23-04-2015 / 18:01:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+	"Modified: / 01-06-2015 / 21:49:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 codeReturn: code
@@ -364,6 +365,47 @@
     "Modified: / 01-06-2015 / 21:48:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+codeReturnParsedValueOf:aBlock 
+    | tmpVarirable  method |
+
+    self assert:aBlock isBlock.	
+    tmpVarirable := returnVariable.
+    method := aBlock value. 
+    self assert: returnVariable == tmpVarirable.
+    self assert: (method isKindOf: PPCMethod).
+    method isInline ifTrue:[
+        self callOnLine:method.
+        self codeReturn: returnVariable.
+    ] ifFalse:[
+        self codeReturn: method call.
+        
+    ]
+
+    "Created: / 23-04-2015 / 18:21:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+codeStoreValueOf: aBlock intoVariable: aString
+    | tmpVarirable method |
+    self assert: aBlock isBlock.
+    self assert: aString isNil not.
+    
+    tmpVarirable := returnVariable.
+    returnVariable := aString.
+    method := [  
+        aBlock value 
+    ] ensure: [ 
+        returnVariable := tmpVarirable 
+    ].
+    
+    method isInline ifTrue: [ 
+        self callOnLine: method 
+    ] ifFalse: [ 
+        self codeEvaluateAndAssign: (method call) to: aString.
+    ]	
+    
+    "Created: / 23-04-2015 / 18:21:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 codeTokenGuard: node ifFalse: codeBlock
     | guard id |
     guard := PPCTokenGuard on: node.
@@ -523,11 +565,11 @@
 
 stopMethod
    self cache: currentMethod methodName as: currentMethod.
-    
-    "arguments profile ifTrue: [ Transcript show: currentMethod code; cr. ]."
-    ^ self pop.
+	
+	"arguments profile ifTrue: [ Transcript show: currentMethod code; cr. ]."
+	^ self pop.
 
-    "Modified: / 01-06-2015 / 21:38:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+	"Modified: / 01-06-2015 / 21:38:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 top