public boolean isImplicitBlockArg() { return getName().equals(BLOCK); }
public boolean isImplicitBlockArg() { return getName().equals(BLOCK); }
public int local(Variable variable) { String newName = variable.getName().replace('%', '$'); return local(newName, JVM.OBJECT_TYPE); }
public int local(Variable variable) { String newName = variable.getName().replace('%', '$'); return local(newName, JVM.OBJECT_TYPE); }
public boolean canBeDeleted(IRScope s) { if (hasSideEffects() || getOperation().isDebugOp() || getOperation().canRaiseException() || transfersControl()) { return false; } else if (this instanceof ResultInstr) { Variable r = ((ResultInstr)this).getResult(); if (s.bindingHasEscaped() && !r.getName().equals(Variable.BLOCK)) { // If the binding of this scope has escaped, then we have to preserve writes to // all local variables because anyone who uses the binding might query any of the // local variables from the binding. This is safe, but extremely conservative. return !(r instanceof LocalVariable); } else if (s.usesEval() && r.getName().equals(Variable.BLOCK)) { // If this scope (or any nested scope) has any evals, then the eval might have a yield which // would use %block. In that scenario, we cannot delete the '%block = recv_closure' instruction. // This is safe, but conservative. return false; } else if (s.usesZSuper() && getOperation().isArgReceive()) { // If this scope (or any nested scope) has a ZSuperInstr, then the arguments of this // scope could be used by any of those ZSuper instructions. If so, we cannot delete // the argument receive. return false; } else { return true; } } else { return true; } }
public boolean canBeDeleted(IRScope s) { if (hasSideEffects() || getOperation().isDebugOp() || getOperation().canRaiseException() || transfersControl()) { return false; } else if (this instanceof ResultInstr) { Variable r = ((ResultInstr)this).getResult(); if (s.bindingHasEscaped() && !r.getName().equals(Variable.BLOCK)) { // If the binding of this scope has escaped, then we have to preserve writes to // all local variables because anyone who uses the binding might query any of the // local variables from the binding. This is safe, but extremely conservative. return !(r instanceof LocalVariable); } else if (s.usesEval() && r.getName().equals(Variable.BLOCK)) { // If this scope (or any nested scope) has any evals, then the eval might have a yield which // would use %block. In that scenario, we cannot delete the '%block = recv_closure' instruction. // This is safe, but conservative. return false; } else if (s.usesZSuper() && getOperation().isArgReceive()) { // If this scope (or any nested scope) has a ZSuperInstr, then the arguments of this // scope could be used by any of those ZSuper instructions. If so, we cannot delete // the argument receive. return false; } else { return true; } } else { return true; } }
public Object receiveKWArg(ThreadContext context, int kwArgHashCount, IRubyObject[] args) { if (kwArgHashCount == 0) { return UndefinedValue.UNDEFINED; } else { RubyHash lastArg = (RubyHash)args[args.length - 1]; if (numUsedArgs == args.length) { /* throw ArgumentError */ Arity.raiseArgumentError(context.getRuntime(), args.length-1, numUsedArgs, -1); } // If the key exists in the hash, delete and return it. RubySymbol argName = context.getRuntime().newSymbol(getResult().getName()); if (lastArg.fastARef(argName) != null) { // SSS FIXME: Can we use an internal delete here? return lastArg.delete(context, argName, Block.NULL_BLOCK); } else { return UndefinedValue.UNDEFINED; } } } }
public Object receiveKWArg(ThreadContext context, int kwArgHashCount, IRubyObject[] args) { if (kwArgHashCount == 0) { return UndefinedValue.UNDEFINED; } else { RubyHash lastArg = (RubyHash)args[args.length - 1]; if (numUsedArgs == args.length) { /* throw ArgumentError */ Arity.raiseArgumentError(context.getRuntime(), args.length-1, numUsedArgs, -1); } // If the key exists in the hash, delete and return it. RubySymbol argName = context.getRuntime().newSymbol(getResult().getName()); if (lastArg.fastARef(argName) != null) { // SSS FIXME: Can we use an internal delete here? return lastArg.delete(context, argName, Block.NULL_BLOCK); } else { return UndefinedValue.UNDEFINED; } } } }