--- a/compiler/PPCCodeGenerator.st Tue Jun 02 17:25:57 2015 +0100
+++ b/compiler/PPCCodeGenerator.st Wed Jun 03 06:23:49 2015 +0100
@@ -400,6 +400,44 @@
compiler add: '].'.
!
+visitMappedActionNode: node
+ | blockNode blockBody |
+
+ blockNode := node block ast copy.
+ blockBody := blockNode body.
+
+ "Block return value is return value of last statement.
+ So if the method is not inline, make last statement a return.
+ if the method is inline, make it assignment to retvalVar."
+ compiler currentMethod isInline ifTrue:[
+ | assignment |
+
+ assignment := RBAssignmentNode variable: (RBVariableNode named: self retvalVar) value: blockBody statements last.
+ blockBody replaceNode: blockBody statements last withNode: assignment.
+ ] ifFalse:[
+ | return |
+
+ return := RBReturnNode value: blockBody statements last.
+ blockBody replaceNode: blockBody statements last withNode: return.
+ ].
+
+ compiler codeStoreValueOf: [ self visit: node child ] intoVariable: self retvalVar.
+ compiler codeIf: 'error' then: [
+ compiler codeReturn: 'failure'.
+ ] else: [
+ "First, extract mapped elements to variable..."
+ blockNode arguments withIndexDo:[ :arg :idx |
+ compiler allocateTemporaryVariableNamed: arg name.
+ compiler codeAssign: (self retvalVar , ' at: ', idx printString) to: arg name.
+ compiler add: '.'.
+ ].
+ compiler code: blockBody.
+ ]
+
+ "Created: / 02-06-2015 / 17:28:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 03-06-2015 / 06:10:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
visitMessagePredicateNode: node
compiler add: '(context peek ', node message, ') ifFalse: ['.
compiler codeError: 'predicate not found'.