public AsString(Operand source) { if (source == null) source = new StringLiteral(""); this.source = source; }
public AsString(Operand source) { if (source == null) source = new StringLiteral(""); this.source = source; }
public Operand run(Object[] args) { build((Node)args[0], (IRScope)args[1]); // always an expression as long as we get through here without an exception! return new StringLiteral("expression"); } };
public Operand run(Object[] args) { build((Node)args[0], (IRScope)args[1]); // always an expression as long as we get through here without an exception! return new StringLiteral("expression"); } };
public Operand buildLiteral(LiteralNode literalNode) { return new StringLiteral(literalNode.getSymbolName()); }
public Operand buildVAlias(Node node, IRScope s) { VAliasNode valiasNode = (VAliasNode) node; s.addInstr(new GVarAliasInstr(new StringLiteral(valiasNode.getNewName()), new StringLiteral(valiasNode.getOldName()))); return manager.getNil(); }
public Operand buildVAlias(Node node, IRScope s) { VAliasNode valiasNode = (VAliasNode) node; s.addInstr(new GVarAliasInstr(new StringLiteral(valiasNode.getNewName()), new StringLiteral(valiasNode.getOldName()))); return manager.getNil(); }
public Operand buildVAlias(VAliasNode valiasNode) { addInstr(new GVarAliasInstr(new StringLiteral(valiasNode.getNewName()), new StringLiteral(valiasNode.getOldName()))); return manager.getNil(); }
public Operand buildDefn(MethodDefNode node, IRScope s) { // Instance method IRMethod method = defineNewMethod(node, s, true); s.addInstr(new DefineInstanceMethodInstr(new StringLiteral("--unused--"), method)); return manager.getNil(); }
public Operand buildDefn(MethodDefNode node, IRScope s) { // Instance method IRMethod method = defineNewMethod(node, s, true); s.addInstr(new DefineInstanceMethodInstr(new StringLiteral("--unused--"), method)); return manager.getNil(); }
public Operand run(Object[] args) { IRScope s = (IRScope)args[0]; Node n = (Node)args[1]; String name = (String)args[2]; Operand v = (n instanceof Colon2Node) ? build(((Colon2Node)n).getLeftNode(), s) : new ObjectClass(); Variable tmpVar = s.getNewTemporaryVariable(); s.addInstr(new GetDefinedConstantOrMethodInstr(tmpVar, v, new StringLiteral(name))); return tmpVar; } };
public Operand run(Object[] args) { IRScope s = (IRScope)args[0]; Node n = (Node)args[1]; String name = (String)args[2]; Operand v = (n instanceof Colon2Node) ? build(((Colon2Node)n).getLeftNode(), s) : new ObjectClass(); Variable tmpVar = s.getNewTemporaryVariable(); s.addInstr(new GetDefinedConstantOrMethodInstr(tmpVar, v, new StringLiteral(name))); return tmpVar; } };
public Operand run(Object[] args) { IRScope s = (IRScope)args[0]; CallNode iVisited = (CallNode)args[1]; String methodName = iVisited.getName(); Variable tmpVar = s.getNewTemporaryVariable(); Operand receiver = build(iVisited.getReceiverNode(), s); s.addInstr(new MethodDefinedInstr(tmpVar, receiver, new StringLiteral(methodName))); return buildDefnCheckIfThenPaths(s, (Label)args[2], tmpVar); } };
public Operand run(Object[] args) { IRScope s = (IRScope)args[0]; CallNode iVisited = (CallNode)args[1]; String methodName = iVisited.getName(); Variable tmpVar = s.getNewTemporaryVariable(); Operand receiver = build(iVisited.getReceiverNode(), s); s.addInstr(new MethodDefinedInstr(tmpVar, receiver, new StringLiteral(methodName))); return buildDefnCheckIfThenPaths(s, (Label)args[2], tmpVar); } };
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { IRubyObject value = (IRubyObject) getObject().retrieve(context, self, currDynScope, temp); String name = getName().string; RubyString definedType = Helpers.getDefinedConstantOrBoundMethod(value, name); return definedType == null ? context.nil : new StringLiteral(definedType.getByteList()).retrieve(context, self, currDynScope, temp); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { IRubyObject value = (IRubyObject) getObject().retrieve(context, self, currDynScope, temp); String name = getName().string; RubyString definedType = Helpers.getDefinedConstantOrBoundMethod(value, name); return definedType == null ? context.nil : new StringLiteral(definedType.getByteList()).retrieve(context, self, currDynScope, temp); }
protected Variable buildDefinitionCheck(IRScope s, ResultInstr definedInstr, String definedReturnValue) { Label undefLabel = s.getNewLabel(); s.addInstr((Instr) definedInstr); s.addInstr(BEQInstr.create(definedInstr.getResult(), manager.getFalse(), undefLabel)); return buildDefnCheckIfThenPaths(s, undefLabel, new StringLiteral(definedReturnValue)); }
protected Variable buildDefinitionCheck(IRScope s, ResultInstr definedInstr, String definedReturnValue) { Label undefLabel = s.getNewLabel(); s.addInstr((Instr) definedInstr); s.addInstr(BEQInstr.create(definedInstr.getResult(), manager.getFalse(), undefLabel)); return buildDefnCheckIfThenPaths(s, undefLabel, new StringLiteral(definedReturnValue)); }
public Operand buildStrRaw(StrNode strNode) { if (strNode instanceof FileNode) return new Filename(); int line = strNode.getLine(); if (strNode.isFrozen()) return new FrozenString(strNode.getValue(), strNode.getCodeRange(), scope.getFile(), line); return new StringLiteral(strNode.getValue(), strNode.getCodeRange(), scope.getFile(), line); }
public Operand buildStrRaw(StrNode strNode) { if (strNode instanceof FileNode) return new Filename(); int line = strNode.getLine(); if (strNode.isFrozen()) return new FrozenString(strNode.getValue(), strNode.getCodeRange(), scope.getFile(), line); return new StringLiteral(strNode.getValue(), strNode.getCodeRange(), scope.getFile(), line); }