@Override public Object execute(VirtualFrame frame) { final DynamicObject result; try { result = method.executeDynamicObject(frame); } catch (DoNotTaint e) { return e.getResult(); } catch (UnexpectedResultException e) { throw new UnsupportedOperationException(e); } if (result != nil()) { if (taintFromSelf) { maybeTaint((DynamicObject) RubyArguments.getSelf(frame.getArguments()), result); } // It's possible the taintFromParameter value was misconfigured by the user, but the far more // likely // scenario is that the argument at that position is a NotProvided argument, which doesn't // take up // a space in the frame. if (taintFromParameter < RubyArguments.getArgumentsCount(frame.getArguments())) { final Object argument = RubyArguments.getArgument(frame.getArguments(), taintFromParameter); if (argument instanceof DynamicObject) { final DynamicObject taintSource = (DynamicObject) argument; maybeTaint(taintSource, result); } } } return result; }
private DispatchNode doDynamicObject( VirtualFrame frame, DispatchNode first, Object receiverObject, Object methodName, Object[] argumentsObjects) { final DynamicObject callerClass; if (ignoreVisibility) { callerClass = null; } else if (getDispatchAction() == DispatchAction.RESPOND_TO_METHOD) { final Frame callerFrame = getContext() .getCallStack() .getCallerFrameIgnoringSend() .getFrame(FrameInstance.FrameAccess.READ_ONLY, true); callerClass = coreLibrary().getMetaClass(RubyArguments.getSelf(callerFrame.getArguments())); } else { callerClass = coreLibrary().getMetaClass(RubyArguments.getSelf(frame)); } final InternalMethod method = lookup(callerClass, receiverObject, toString(methodName), ignoreVisibility); if (method == null) { return createMethodMissingNode(first, methodName, receiverObject); } final DynamicObject receiverMetaClass = coreLibrary().getMetaClass(receiverObject); if (RubyGuards.isRubySymbol(receiverObject)) { return new CachedBoxedSymbolDispatchNode( getContext(), methodName, first, method, getDispatchAction()); } else if (Layouts.CLASS.getIsSingleton(receiverMetaClass)) { return new CachedSingletonDispatchNode( getContext(), methodName, first, ((DynamicObject) receiverObject), receiverMetaClass, method, getDispatchAction()); } else { return new CachedBoxedDispatchNode( getContext(), methodName, first, ((DynamicObject) receiverObject).getShape(), receiverMetaClass, method, getDispatchAction()); } }
protected static DynamicObject getCallerClass( RubyContext context, VirtualFrame callingFrame, boolean ignoreVisibility, boolean onlyLookupPublic) { if (ignoreVisibility || onlyLookupPublic) { return null; // No need to check visibility } else { InternalMethod method = RubyArguments.getMethod(callingFrame); if (!context.getCoreLibrary().isSend(method)) { return context.getCoreLibrary().getMetaClass(RubyArguments.getSelf(callingFrame)); } else { FrameInstance instance = context.getCallStack().getCallerFrameIgnoringSend(); Frame callerFrame = instance.getFrame(FrameInstance.FrameAccess.READ_ONLY, true); return context.getCoreLibrary().getMetaClass(RubyArguments.getSelf(callerFrame)); } } }
private DispatchNode doUnboxedObject( VirtualFrame frame, DispatchNode first, Object receiverObject, Object methodName) { final DynamicObject callerClass; if (ignoreVisibility) { callerClass = null; } else { callerClass = coreLibrary().getMetaClass(RubyArguments.getSelf(frame)); } final String methodNameString = toString(methodName); final InternalMethod method = lookup(callerClass, receiverObject, methodNameString, ignoreVisibility); if (method == null) { return createMethodMissingNode(first, methodName, receiverObject); } if (receiverObject instanceof Boolean) { final Assumption falseUnmodifiedAssumption = Layouts.MODULE.getFields(coreLibrary().getFalseClass()).getUnmodifiedAssumption(); final InternalMethod falseMethod = lookup(callerClass, false, methodNameString, ignoreVisibility); final Assumption trueUnmodifiedAssumption = Layouts.MODULE.getFields(coreLibrary().getTrueClass()).getUnmodifiedAssumption(); final InternalMethod trueMethod = lookup(callerClass, true, methodNameString, ignoreVisibility); assert falseMethod != null || trueMethod != null; return new CachedBooleanDispatchNode( getContext(), methodName, first, falseUnmodifiedAssumption, falseMethod, trueUnmodifiedAssumption, trueMethod, getDispatchAction()); } else { return new CachedUnboxedDispatchNode( getContext(), methodName, first, receiverObject.getClass(), Layouts.MODULE .getFields(coreLibrary().getLogicalClass(receiverObject)) .getUnmodifiedAssumption(), method, getDispatchAction()); } }
@Override public Object execute(VirtualFrame frame) { final DynamicObject module = (DynamicObject) definingModule.execute(frame); final InternalMethod definition = prepareLexicalScope(module, definitionMethod.executeMethod(frame)); return callModuleDefinitionNode.call( frame, definition.getCallTarget(), RubyArguments.pack( null, null, definition, DeclarationContext.MODULE, null, module, null, new Object[] {})); }
public InternalMethod executeMethod(VirtualFrame frame) { final DynamicObject dummyModule = getContext().getCoreLibrary().getObjectClass(); final Visibility dummyVisibility = Visibility.PUBLIC; final DynamicObject capturedBlock; if (captureBlock) { capturedBlock = RubyArguments.getBlock(frame.getArguments()); } else { capturedBlock = null; } return new InternalMethod( sharedMethodInfo, name, dummyModule, dummyVisibility, false, null, callTarget, capturedBlock, null); }
protected InternalMethod getCurrentMethod(VirtualFrame frame) { return RubyArguments.getMethod(frame.getArguments()); }