On 24/09/2011 11:27, Holger Hans Peter Freyther wrote:
Hi,
when using the STCompiler I end up with a MessageNotUnderstood error:
STInST.STEvaluationDriver new parseSmalltalk: '[:each :ablock | (each) ifTrue:
ablock]!' with: STInST.STFileInParser
In STCompiler>>#compileBoolean: aNode will be '(each) ifTrue:..' the arguments
is the RBVariableNode and RBVariableNode does not understand arguments/body.
So somehow the bytecode for STCompiler>>#acceptVariableNode would need to end
up in bc1 and bc2?
_______________________________________________
help-smalltalk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Hi Zecke,
Can you try the following patch (ok not perfect but it works for me)
I've made some other changes for the compiler:
STInST.STCompiler class extend [
evaluate: aNode parser: aParser [
<category: 'evaluation'>
| cm methodNode sequenceNode |
sequenceNode := aNode isSequence ifFalse: [ RBSequenceNode
statements: {aNode} ] ifTrue: [ aNode ].
sequenceNode addReturn.
methodNode := (RBMethodNode new)
arguments: #();
body: sequenceNode;
selector: #Doit;
source: nil;
yourself.
cm := self
compile: methodNode
asMethodOf: UndefinedObject
classified: nil
parser: aParser
environment: Namespace current.
^nil perform: cm
]
]
STInST.STCompiler evaluate: (STInST.RBParser parseExpression: '[:each
:ablock | (each) ifTrue: ablock]') parser: STInST.RBParser new
Gwen
diff --git a/packages/stinst/parser/STCompiler.st b/packages/stinst/parser/STCompiler.st
index 620e019..a386c7e 100644
--- a/packages/stinst/parser/STCompiler.st
+++ b/packages/stinst/parser/STCompiler.st
@@ -793,6 +793,10 @@ indexed'' bytecode. The resulting stream is
compileBoolean: aNode [
<category: 'compiling'>
| bc1 ret1 bc2 selector |
+ aNode arguments do: [ :each |
+ each isVariable ifTrue: [ aNode receiver acceptVisitor: self.
+ self compileMessage: aNode.
+ ^ true ] ].
aNode arguments do:
[:each |
(each arguments isEmpty and: [each body temporaries isEmpty])
_______________________________________________
help-smalltalk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-smalltalk