--- a/compiler/PPCMethod.st Thu Apr 30 23:43:14 2015 +0200
+++ b/compiler/PPCMethod.st Sun May 10 06:28:36 2015 +0100
@@ -18,118 +18,87 @@
^ self basicNew initialize.
! !
-!PPCMethod methodsFor:'as yet unclassified'!
-
-add: string
- self nl.
- indentation timesRepeat: [ buffer nextPut: Character tab ].
- self addOnLine: string.
-!
-
-addOnLine: string
- buffer nextPutAll: string.
-!
-
-addVariable: name
- (variables includes: name) ifTrue:[
- self error:'Duplicate variable name, must rename'.
- ].
- variables add: name.
-
- "Modified: / 23-04-2015 / 12:29:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
+!PPCMethod methodsFor:'accessing'!
body
- ^ buffer contents
+ ^ buffer contents
!
bridge
- ^ PPCBridge on: self methodName.
-!
-
-call
- ^ 'self ', self methodName, '.'.
+ ^ PPCBridge on: self methodName.
!
code
- ^ self methodName, Character cr asString,
- self variables, Character cr asString,
- self profilingBegin, Character cr asString,
- self body, Character cr asString
+ ^ self methodName, Character cr asString,
+ self variables, Character cr asString,
+ self profilingBegin, Character cr asString,
+ self body, Character cr asString
" self profilingEnd"
"Modified: / 23-04-2015 / 19:26:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-dedent
- indentation := indentation - 1
-!
-
id: value
- id := value
-!
-
-indent
- indentation := indentation + 1
-!
-
-isInline
- ^ false
-!
-
-isMethod
- ^ true
+ id := value
!
methodName
- ^ id
-!
-
-nl
- ^ buffer nextPut: Character cr
+ ^ id
!
profile
- ^ profile
+ ^ profile
!
profile: aBoolean
- profile := aBoolean
+ profile := aBoolean
+! !
+
+!PPCMethod methodsFor:'as yet unclassified'!
+
+add: string
+ self nl.
+ indentation timesRepeat: [ buffer nextPut: Character tab ].
+ self addOnLine: string.
+!
+
+addOnLine: string
+ buffer nextPutAll: string.
+!
+
+call
+ ^ 'self ', self methodName, '.'.
+!
+
+nl
+ ^ buffer nextPut: Character cr
!
profilingBegin
- self profile ifTrue: [
+ self profile ifTrue: [
^ ' context methodInvoked: #', id, '.'
- ].
- ^ ''
+ ].
+ ^ ''
!
profilingEnd
- self profile ifTrue: [
+ self profile ifTrue: [
^ ' context methodFinished: #', id, '.'
- ].
- ^ ''
-!
-
-returnVariable
- ^ variableForReturn
-
- "Created: / 23-04-2015 / 20:50:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-returnVariable: 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>"
-!
-
-variables
- ^ ' | ', (variables inject: '' into: [ :s :e | s, ' ', e]), ' |'
+ ].
+ ^ ''
! !
!PPCMethod methodsFor:'code generation - variables'!
+addVariable: name
+ (variables includes: name) ifTrue:[
+ self error:'Duplicate variable name, must rename'.
+ ].
+ variables add: name.
+
+ "Modified: / 23-04-2015 / 12:29:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
allocateReturnVariable
^ variableForReturn isNil ifTrue:[
@@ -157,17 +126,52 @@
].
"Created: / 23-04-2015 / 17:37:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+returnVariable
+ ^ variableForReturn
+
+ "Created: / 23-04-2015 / 20:50:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+returnVariable: 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>"
+!
+
+variables
+ ^ ' | ', (variables inject: '' into: [ :s :e | s, ' ', e]), ' |'
+! !
+
+!PPCMethod methodsFor:'indentation'!
+
+dedent
+ indentation := indentation - 1
+!
+
+indent
+ indentation := indentation + 1
+!
+
+indentationLevel
+ ^ indentation
+!
+
+indentationLevel: value
+ indentation := value
! !
!PPCMethod methodsFor:'initialization'!
initialize
- buffer := WriteStream on: ''.
- indentation := 1.
- variables := OrderedCollection new.
+ buffer := WriteStream on: ''.
+ indentation := 1.
+ variables := OrderedCollection new.
! !
-!PPCMethod methodsFor:'printing & storing'!
+!PPCMethod methodsFor:'printing'!
printOn:aStream
"append a printed representation if the receiver to the argument, aStream"
@@ -179,6 +183,16 @@
"Modified: / 23-04-2015 / 12:32:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!PPCMethod methodsFor:'testing'!
+
+isInline
+ ^ false
+!
+
+isMethod
+ ^ true
+! !
+
!PPCMethod class methodsFor:'documentation'!
version_HG