--- a/compiler/PPCMethod.st Fri Jul 24 15:06:54 2015 +0100
+++ b/compiler/PPCMethod.st Mon Aug 17 12:13:16 2015 +0100
@@ -3,7 +3,7 @@
"{ NameSpace: Smalltalk }"
Object subclass:#PPCMethod
- instanceVariableNames:'buffer id variableForReturn category profile'
+ instanceVariableNames:'selector source category variableForReturn'
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Compiler-Codegen'
@@ -21,7 +21,12 @@
!PPCMethod methodsFor:'accessing'!
body
+ self error: 'Should no longer be used'.
+ "
^ buffer contents
+ "
+
+ "Modified: / 17-08-2015 / 11:58:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
bridge
@@ -42,50 +47,79 @@
code
^ String streamContents: [ :s |
s nextPutAll: self methodName; cr.
- buffer codeOn: s.
+ source codeOn: s.
]
"Modified: / 01-06-2015 / 21:24:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
id: value
- id := value
+ selector := value
!
indentationLevel
- ^ buffer indentationLevel
+ ^ source indentationLevel
"Created: / 01-06-2015 / 21:38:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
indentationLevel: anInteger
- buffer indentationLevel: anInteger
+ source indentationLevel: anInteger
"Created: / 01-06-2015 / 21:38:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
methodName
- ^ id
+ ^ selector
!
profile
+ self error: 'Should no longer be used'.
+ "
^ profile
+ "
+
+ "Modified: / 17-08-2015 / 11:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
profile: aBoolean
+ self error: 'Should no longer be used'.
+ "
profile := aBoolean
+ "
+
+ "Modified: / 17-08-2015 / 11:58:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+source
+ ^ source isString ifTrue:[
+ source
+ ] ifFalse:[
+ String streamContents: [ :s |
+ s nextPutAll: self methodName; cr.
+ source sourceOn:s.
+ ]
+ ].
+
+ "Created: / 24-07-2015 / 19:46:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+source: aString
+ source := aString
+
+ "Created: / 24-07-2015 / 19:48:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPCMethod methodsFor:'as yet unclassified'!
add: string
- buffer add: string
+ source add: string
"Modified: / 01-06-2015 / 21:09:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
addOnLine: string
- buffer addOnLine: string
+ source addOnLine: string
"Modified: / 01-06-2015 / 21:09:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
@@ -94,16 +128,20 @@
^ 'self ', self methodName, '.'.
!
+callOn: receiver
+ ^ receiver, ' ', self methodName.
+!
+
profilingBegin
self profile ifTrue: [
- ^ ' context methodInvoked: #', id, '.'
+ ^ ' context methodInvoked: #', selector, '.'
].
^ ''
!
profilingEnd
self profile ifTrue: [
- ^ ' context methodFinished: #', id, '.'
+ ^ ' context methodFinished: #', selector, '.'
].
^ ''
! !
@@ -111,7 +149,7 @@
!PPCMethod methodsFor:'code generation'!
code: aStringOrBlockOrRBParseNode
- buffer code: aStringOrBlockOrRBParseNode.
+ source code: aStringOrBlockOrRBParseNode.
"Created: / 01-06-2015 / 22:31:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (format): / 01-06-2015 / 23:50:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -120,47 +158,66 @@
codeBlock: contents
| outerBlock innerBlock |
- outerBlock := buffer.
+ outerBlock := source.
innerBlock := PPCCodeBlock new.
innerBlock indentationLevel: outerBlock indentationLevel + 1.
[
outerBlock addOnLine:'['.
- buffer := innerBlock.
- self code: contents.
+ source := innerBlock.
+ self codeOnLine: contents.
] ensure:[
outerBlock
- code: (String streamContents:[:s | innerBlock codeOn: s]);
+ code: (String streamContents:[:s | innerBlock sourceOn:s]);
add:']'.
- buffer := outerBlock.
+ source := outerBlock.
]
"Created: / 01-06-2015 / 22:33:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 03-06-2015 / 06:11:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+codeOnLine: aStringOrBlockOrRBParseNode
+ source codeOnLine: aStringOrBlockOrRBParseNode.
+
+ "Created: / 01-06-2015 / 22:31:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (format): / 01-06-2015 / 23:50:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPCMethod methodsFor:'code generation - indenting'!
dedent
- buffer dedent
+ source dedent
"Created: / 01-06-2015 / 21:32:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
indent
- buffer indent
+ source indent
"Created: / 01-06-2015 / 21:32:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
nl
- buffer nl
+ source nl
"Created: / 01-06-2015 / 21:52:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPCMethod methodsFor:'code generation - variables'!
+addVariable: name
+ self error: 'Should no longer be used'
+ "
+ (variables includes: name) ifTrue:[
+ self error:'Duplicate variable name, must rename'.
+ ].
+ variables add: name.
+ "
+
+ "Modified: / 17-08-2015 / 11:56:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
allocateReturnVariable
^ variableForReturn isNil ifTrue:[
@@ -189,7 +246,7 @@
"Allocate a new variable with (preferably) given name.
Returns a real variable name that should be used."
- ^ buffer allocateTemporaryVariableNamed: preferredName
+ ^ source allocateTemporaryVariableNamed: preferredName
"Created: / 23-04-2015 / 17:37:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 01-06-2015 / 21:04:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
@@ -210,12 +267,21 @@
"Created: / 23-04-2015 / 18:23:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 15-06-2015 / 18:14:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+variables
+ self error: 'Should no longer be used'.
+ "
+ ^ ' | ', (variables inject: '' into: [ :s :e | s, ' ', e]), ' |'
+ "
+
+ "Modified: / 17-08-2015 / 11:54:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!PPCMethod methodsFor:'initialization'!
initialize
- buffer := PPCCodeBlock new.
+ source := PPCCodeBlock new.
"Modified: / 01-06-2015 / 21:33:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
@@ -227,7 +293,7 @@
super printOn:aStream.
aStream nextPutAll:' id: '.
- id printOn:aStream.
+ selector printOn:aStream.
"Modified: / 23-04-2015 / 12:32:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !