--- a/compiler/PPCCodeBlock.st Fri Jun 19 08:13:39 2015 +0100
+++ b/compiler/PPCCodeBlock.st Fri Jul 24 15:37:23 2015 +0100
@@ -39,26 +39,12 @@
code: aStringOrBlockOrRBParseNode
aStringOrBlockOrRBParseNode isString ifTrue:[
- buffer nextPutAll: aStringOrBlockOrRBParseNode
+ self emitCodeAsString: aStringOrBlockOrRBParseNode
] ifFalse:[
(aStringOrBlockOrRBParseNode isKindOf: RBProgramNode) ifTrue:[
- aStringOrBlockOrRBParseNode isSequence ifTrue:[
- aStringOrBlockOrRBParseNode temporaries do:[:e |
- (temporaries includes: e name) ifFalse:[
- temporaries add: e name
- ].
- ].
- aStringOrBlockOrRBParseNode statements do:[:e|
- buffer nextPutAll: e formattedCode; nextPut: $..
- self nl; codeIndent.
- ].
-
- ] ifFalse:[
- buffer nextPutAll: aStringOrBlockOrRBParseNode formattedCode.
- ].
-
+ self emitCodeAsRBNode: aStringOrBlockOrRBParseNode.
] ifFalse:[
- aStringOrBlockOrRBParseNode value
+ self emitCodeAsBlock: aStringOrBlockOrRBParseNode
].
].
@@ -143,7 +129,7 @@
((Smalltalk respondsTo:#isSmalltalkX) and:[ Smalltalk isSmalltalkX ]) ifTrue:[
indentation * 4 timesRepeat: [ aStream nextPut: Character space ].
] ifFalse:[
- indentation timesRepeat: [ buffer nextPut: Character tab ].
+ indentation timesRepeat: [ aStream nextPut: Character tab ].
].
aStream nextPut: $|.
temporaries do:[:e | aStream space; nextPutAll: e ].
@@ -160,3 +146,37 @@
"Created: / 01-06-2015 / 21:26:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!PPCCodeBlock methodsFor:'private'!
+
+emitCodeAsBlock: aBlock
+ aBlock value
+!
+
+emitCodeAsRBNode: anRBNode
+ anRBNode isSequence ifTrue:[
+ anRBNode temporaries do:[:e |
+ (temporaries includes: e name) ifFalse:[
+ temporaries add: e name
+ ].
+ ].
+ anRBNode statements do:[:e|
+ self add: (self formatRBNode: e);
+ addOnLine: '.'.
+ ].
+ ] ifFalse:[
+ buffer nextPutAll: anRBNode formattedCode.
+ ].
+
+!
+
+emitCodeAsString: aString
+ buffer nextPutAll: aString
+!
+
+formatRBNode: anRBNode
+ | formatter |
+ formatter := anRBNode formatterClass new.
+ formatter indent: indentation.
+ ^ formatter format: anRBNode
+! !
+