1 9 10 package org.jruby.compiler; 11 12 import java.util.Collections ; 13 import java.util.Iterator ; 14 import org.jruby.ast.ListNode; 15 import org.jruby.ast.MultipleAsgnNode; 16 import org.jruby.ast.Node; 17 import org.jruby.ast.StarNode; 18 19 23 public class MultipleAsgnNodeAsgnCompiler implements NodeCompiler { 24 25 26 public MultipleAsgnNodeAsgnCompiler() { 27 } 28 29 public void compile(Node node, Compiler context) { 30 31 33 context.lineNumber(node.getPosition()); 34 35 MultipleAsgnNode multipleAsgnNode = (MultipleAsgnNode)node; 36 37 int varLen = multipleAsgnNode.getHeadNode() == null ? 0 : multipleAsgnNode.getHeadNode().size(); 38 39 Iterator iter = multipleAsgnNode.getHeadNode() != null ? multipleAsgnNode.getHeadNode().iterator() : Collections.EMPTY_LIST.iterator(); 40 41 { ArrayCallback headAssignCallback = new ArrayCallback() { 43 public void nextValue(Compiler context, Object sourceArray, 44 int index) { 45 ListNode headNode = (ListNode)sourceArray; 46 Node assignNode = headNode.get(index); 47 48 NodeCompilerFactory.getAssignmentCompiler(assignNode).compile(assignNode, context); 50 } 51 }; 52 53 context.ensureRubyArray(); 54 context.forEachInValueArray(multipleAsgnNode.getHeadNode().size(), 0, multipleAsgnNode.getHeadNode(), headAssignCallback); 55 } 56 57 62 { Node argsNode = multipleAsgnNode.getArgsNode(); 64 if (argsNode != null) { 65 if (argsNode instanceof StarNode) { 66 } else { 68 BranchCallback trueBranch = new BranchCallback() { 69 public void branch(Compiler context) { 70 71 } 72 }; 73 74 context.loadRubyArraySize(); 77 context.loadInteger(varLen); 78 } 80 } 81 } 82 } 83 } 84 | Popular Tags |