compiler/PPCMethod.st
changeset 488 19a9c25960ef
parent 481 34ee0d3c72e7
child 503 ff58cd9f1f3c
--- a/compiler/PPCMethod.st	Mon Jun 15 18:00:44 2015 +0100
+++ b/compiler/PPCMethod.st	Mon Jun 15 19:13:49 2015 +0100
@@ -156,15 +156,17 @@
 
 !PPCMethod methodsFor:'code generation - variables'!
 
-allocateReturnVariable    
-    ^ variableForReturn isNil ifTrue:[ 
-            variableForReturn := self allocateTemporaryVariableNamed: 'retval'  
-    ] ifFalse:[ 
-            variableForReturn
-    ].
+allocateReturnVariableNamed: name    
+    "Allocate temporary variable used for storing a parser's return value (the parsed object)"
 
-    "Created: / 23-04-2015 / 18:03:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified (format): / 01-06-2015 / 21:01:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    variableForReturn notNil ifTrue:[ 
+        self error: 'Return variable already allocated!!'.
+        ^ self.
+    ]. 
+    variableForReturn := self allocateTemporaryVariableNamed: name.
+    ^ variableForReturn
+
+    "Created: / 15-06-2015 / 17:52:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 allocateTemporaryVariableNamed:preferredName 
@@ -177,17 +179,21 @@
     "Modified: / 01-06-2015 / 21:04:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-returnVariable
-    ^  variableForReturn
+returnVariable    
+    ^ variableForReturn
 
     "Created: / 23-04-2015 / 20:50:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 15-06-2015 / 18:12:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 returnVariable: aString
-    ^ variableForReturn := aString
+    (variableForReturn notNil and:[variableForReturn ~= aString]) ifTrue:[ 
+         self error: 'Return variable already allocated with different name (''', variableForReturn , ''' vs ''', aString,''')'.
+    ].
+    variableForReturn := aString
 
     "Created: / 23-04-2015 / 18:23:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 23-04-2015 / 21:08:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 15-06-2015 / 18:14:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !PPCMethod methodsFor:'initialization'!