@Override public Instr cloneForInlining(InlinerInfo inlinerInfo) { return new MethodIsPublicInstr((Variable) getResult().cloneForInlining(inlinerInfo), getObject().cloneForInlining(inlinerInfo), (StringLiteral) getName().cloneForInlining(inlinerInfo)); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { IRubyObject receiver = (IRubyObject) getObject().retrieve(context, self, currDynScope, temp); return context.runtime.newBoolean(isPublic(receiver, getName().string)); }
public Operand run(Object[] args) { /* -------------------------------------------------------------------------- * This basically combines checks from CALLNODE and FCALLNODE * * Generate IR for this sequence * * 1. r = receiver * 2. mc = r.metaClass * 3. v = mc.getVisibility(methodName) * 4. f = !v || v.isPrivate? || (v.isProtected? && receiver/self?.kindof(mc.getRealClass)) * 5. return !f && mc.methodBound(attrmethod) ? buildGetArgumentDefn(..) : false * * Hide the complexity of instrs 2-4 into a verifyMethodIsPublicAccessible call * which can executely entirely in Java-land. No reason to expose the guts in IR. * ------------------------------------------------------------------------------ */ IRScope s = (IRScope)args[0]; AttrAssignNode iVisited = (AttrAssignNode)args[1]; Label undefLabel = (Label)args[2]; StringLiteral attrMethodName = new StringLiteral(iVisited.getName()); Variable tmpVar = s.getNewTemporaryVariable(); Operand receiver = build(iVisited.getReceiverNode(), s); s.addInstr(new MethodIsPublicInstr(tmpVar, receiver, attrMethodName)); s.addInstr(BEQInstr.create(tmpVar, manager.getFalse(), undefLabel)); s.addInstr(new IsMethodBoundInstr(tmpVar, getSelf(s), attrMethodName)); s.addInstr(BEQInstr.create(tmpVar, manager.getFalse(), undefLabel)); Operand argsCheckDefn = buildGetArgumentDefinition(((AttrAssignNode) node).getArgsNode(), s, "assignment"); return buildDefnCheckIfThenPaths(s, undefLabel, argsCheckDefn); } };
public Operand run(Object[] args) { /* -------------------------------------------------------------------------- * This basically combines checks from CALLNODE and FCALLNODE * * Generate IR for this sequence * * 1. r = receiver * 2. mc = r.metaClass * 3. v = mc.getVisibility(methodName) * 4. f = !v || v.isPrivate? || (v.isProtected? && receiver/self?.kindof(mc.getRealClass)) * 5. return !f && mc.methodBound(attrmethod) ? buildGetArgumentDefn(..) : false * * Hide the complexity of instrs 2-4 into a verifyMethodIsPublicAccessible call * which can executely entirely in Java-land. No reason to expose the guts in IR. * ------------------------------------------------------------------------------ */ IRScope s = (IRScope)args[0]; AttrAssignNode iVisited = (AttrAssignNode)args[1]; Label undefLabel = (Label)args[2]; StringLiteral attrMethodName = new StringLiteral(iVisited.getName()); Variable tmpVar = s.getNewTemporaryVariable(); Operand receiver = build(iVisited.getReceiverNode(), s); s.addInstr(new MethodIsPublicInstr(tmpVar, receiver, attrMethodName)); s.addInstr(BEQInstr.create(tmpVar, manager.getFalse(), undefLabel)); s.addInstr(new IsMethodBoundInstr(tmpVar, getSelf(s), attrMethodName)); s.addInstr(BEQInstr.create(tmpVar, manager.getFalse(), undefLabel)); Operand argsCheckDefn = buildGetArgumentDefinition(((AttrAssignNode) node).getArgsNode(), s, "assignment"); return buildDefnCheckIfThenPaths(s, undefLabel, argsCheckDefn); } };
@Override public Instr cloneForInlining(InlinerInfo inlinerInfo) { return new MethodIsPublicInstr((Variable) getResult().cloneForInlining(inlinerInfo), getObject().cloneForInlining(inlinerInfo), (StringLiteral) getName().cloneForInlining(inlinerInfo)); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { IRubyObject receiver = (IRubyObject) getObject().retrieve(context, self, currDynScope, temp); return context.runtime.newBoolean(isPublic(receiver, getName().string)); }