--- a/compiler/PPCMethod.st Fri Jun 19 08:13:39 2015 +0100
+++ b/compiler/PPCMethod.st Fri Jul 24 15:37:23 2015 +0100
@@ -3,7 +3,7 @@
"{ NameSpace: Smalltalk }"
Object subclass:#PPCMethod
- instanceVariableNames:'buffer id variableForReturn category'
+ instanceVariableNames:'buffer id variableForReturn category profile'
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Compiler-Codegen'
@@ -66,6 +66,14 @@
methodName
^ id
+!
+
+profile
+ ^ profile
+!
+
+profile: aBoolean
+ profile := aBoolean
! !
!PPCMethod methodsFor:'as yet unclassified'!
@@ -88,14 +96,14 @@
profilingBegin
self profile ifTrue: [
- ^ ' context methodInvoked: #', id, '.'
+ ^ ' context methodInvoked: #', id, '.'
].
^ ''
!
profilingEnd
self profile ifTrue: [
- ^ ' context methodFinished: #', id, '.'
+ ^ ' context methodFinished: #', id, '.'
].
^ ''
! !
@@ -116,17 +124,14 @@
innerBlock := PPCCodeBlock new.
innerBlock indentationLevel: outerBlock indentationLevel + 1.
[
- buffer addOnLine:'['; nl; codeIndent.
+ outerBlock addOnLine:'['.
buffer := innerBlock.
self code: contents.
] ensure:[
- buffer := outerBlock.
- buffer
+ outerBlock
code: (String streamContents:[:s | innerBlock codeOn: s]);
- nl;
- codeIndent.
-
- buffer addOnLine:']'.
+ add:']'.
+ buffer := outerBlock.
]
"Created: / 01-06-2015 / 22:33:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -156,6 +161,17 @@
!PPCMethod methodsFor:'code generation - variables'!
+allocateReturnVariable
+
+ ^ variableForReturn isNil ifTrue:[
+ variableForReturn := self allocateTemporaryVariableNamed: 'retval'
+ ] ifFalse:[
+ variableForReturn
+ ].
+
+ "Created: / 23-04-2015 / 18:03:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
allocateReturnVariableNamed: name
"Allocate temporary variable used for storing a parser's return value (the parsed object)"