1 28 29 package org.jruby.compiler; 30 31 import org.jruby.ast.Node; 32 import org.jruby.ast.NodeTypes; 33 34 38 public class NodeCompilerFactory { 39 public static YARVNodesCompiler getYARVCompiler() { 40 return new YARVNodesCompiler(); 41 } 42 public static NodeCompiler getCompiler(Node node) { 43 switch (node.nodeId) { 44 case NodeTypes.ALIASNODE: 45 return new AliasNodeCompiler(); 46 case NodeTypes.ANDNODE: 47 return new AndNodeCompiler(); 48 case NodeTypes.ARRAYNODE: 49 return new ArrayNodeCompiler(); 50 case NodeTypes.BEGINNODE: 51 return new BeginNodeCompiler(); 52 case NodeTypes.BIGNUMNODE: 53 return new BignumNodeCompiler(); 54 case NodeTypes.BLOCKNODE: 55 return new BlockNodeCompiler(); 56 case NodeTypes.CALLNODE: 57 return new CallNodeCompiler(); 58 case NodeTypes.CONSTNODE: 59 return new ConstNodeCompiler(); 60 case NodeTypes.DASGNNODE: 61 return new DAsgnNodeCompiler(); 62 case NodeTypes.DEFNNODE: 63 return new DefnNodeCompiler(); 64 case NodeTypes.DVARNODE: 65 return new DVarNodeCompiler(); 66 case NodeTypes.FALSENODE: 67 return new FalseNodeCompiler(); 68 case NodeTypes.FCALLNODE: 69 return new FCallNodeCompiler(); 70 case NodeTypes.FIXNUMNODE: 71 return new FixnumNodeCompiler(); 72 case NodeTypes.GLOBALASGNNODE: 73 return new GlobalAsgnNodeCompiler(); 74 case NodeTypes.GLOBALVARNODE: 75 return new GlobalVarNodeCompiler(); 76 case NodeTypes.IFNODE: 77 return new IfNodeCompiler(); 78 case NodeTypes.INSTASGNNODE: 79 return new InstAsgnNodeCompiler(); 80 case NodeTypes.INSTVARNODE: 81 return new InstVarNodeCompiler(); 82 case NodeTypes.LOCALASGNNODE: 85 return new LocalAsgnNodeCompiler(); 86 case NodeTypes.LOCALVARNODE: 87 return new LocalVarNodeCompiler(); 88 case NodeTypes.NEWLINENODE: 89 return new NewlineNodeCompiler(); 90 case NodeTypes.NILNODE: 91 return new NilNodeCompiler(); 92 case NodeTypes.NOTNODE: 93 return new NotNodeCompiler(); 94 case NodeTypes.ORNODE: 95 return new OrNodeCompiler(); 96 case NodeTypes.ROOTNODE: 97 return new RootNodeCompiler(); 98 case NodeTypes.SELFNODE: 99 return new SelfNodeCompiler(); 100 case NodeTypes.SPLATNODE: 101 return new SplatNodeCompiler(); 102 case NodeTypes.STRNODE: 103 return new StringNodeCompiler(); 104 case NodeTypes.SVALUENODE: 105 return new SValueNodeCompiler(); 106 case NodeTypes.SYMBOLNODE: 107 return new SymbolNodeCompiler(); 108 case NodeTypes.TRUENODE: 109 return new TrueNodeCompiler(); 110 case NodeTypes.VCALLNODE: 111 return new VCallNodeCompiler(); 112 case NodeTypes.WHILENODE: 113 return new WhileNodeCompiler(); 114 case NodeTypes.YIELDNODE: 115 return new YieldNodeCompiler(); 116 case NodeTypes.ZARRAYNODE: 117 return new ZArrayNodeCompiler(); 118 } 119 120 throw new NotCompilableException("Can't compile node: " + node); 121 } 122 123 public static NodeCompiler getArgumentsCompiler(Node node) { 124 switch (node.nodeId) { 125 case NodeTypes.ARRAYNODE: 126 return new ArrayNodeArgsCompiler(); 127 } 128 129 throw new NotCompilableException("Can't compile argument node: " + node); 130 } 131 132 public static NodeCompiler getAssignmentCompiler(Node node) { 133 switch (node.nodeId) { 134 } 138 139 throw new NotCompilableException("Can't compile assignment node: " + node); 140 } 141 } 142 | Popular Tags |