@Override public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) { AttrReaderMethod attrReader = (AttrReaderMethod)method; String varName = attrReader.getVariableName(); // we getVariableAccessorForWrite here so it is eagerly created and we don't cache the DUMMY VariableAccessor accessor = cls.getRealClass().getVariableAccessorForWrite(varName); // Ruby to attr reader if (RubyInstanceConfig.LOG_INDY_BINDINGS) { if (accessor instanceof FieldVariableAccessor) { LOG.info(site.name() + "\tbound as field attr reader " + logMethod(method) + ":" + ((AttrReaderMethod)method).getVariableName()); } else { LOG.info(site.name() + "\tbound as attr reader " + logMethod(method) + ":" + ((AttrReaderMethod)method).getVariableName()); } } return createAttrReaderHandle(site, cls, accessor); } }
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { IRubyObject variable = (IRubyObject) verifyAccessor(self.getMetaClass().getRealClass()).get(self); return variable == null ? context.nil : variable; }
private void addAccessor(ThreadContext context, String internedName, Visibility visibility, boolean readable, boolean writeable) { assert internedName == internedName.intern() : internedName + " is not interned"; final Ruby runtime = context.runtime; if (visibility == PRIVATE) { //FIXME warning } else if (visibility == MODULE_FUNCTION) { visibility = PRIVATE; // FIXME warning } if (!(IdUtil.isLocal(internedName) || IdUtil.isConstant(internedName))) { throw runtime.newNameError("invalid attribute name", internedName); } final String variableName = ("@" + internedName).intern(); if (readable) { addMethod(internedName, new AttrReaderMethod(this, visibility, CallConfiguration.FrameNoneScopeNone, variableName)); callMethod(context, "method_added", runtime.fastNewSymbol(internedName)); } if (writeable) { internedName = (internedName + "=").intern(); addMethod(internedName, new AttrWriterMethod(this, visibility, CallConfiguration.FrameNoneScopeNone, variableName)); callMethod(context, "method_added", runtime.fastNewSymbol(internedName)); } }
private void addAccessor(ThreadContext context, String internedName, Visibility visibility, boolean readable, boolean writeable) { assert internedName == internedName.intern() : internedName + " is not interned"; final Ruby runtime = context.runtime; if (visibility == PRIVATE) { //FIXME warning } else if (visibility == MODULE_FUNCTION) { visibility = PRIVATE; // FIXME warning } if (!(IdUtil.isLocal(internedName) || IdUtil.isConstant(internedName))) { throw runtime.newNameError("invalid attribute name", internedName); } final String variableName = ("@" + internedName).intern(); if (readable) { addMethod(internedName, new AttrReaderMethod(this, visibility, CallConfiguration.FrameNoneScopeNone, variableName)); callMethod(context, "method_added", runtime.fastNewSymbol(internedName)); } if (writeable) { internedName = (internedName + "=").intern(); addMethod(internedName, new AttrWriterMethod(this, visibility, CallConfiguration.FrameNoneScopeNone, variableName)); callMethod(context, "method_added", runtime.fastNewSymbol(internedName)); } }
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { IRubyObject variable = (IRubyObject) verifyAccessor(self.getMetaClass().getRealClass()).get(self); return variable == null ? context.nil : variable; }
@Override public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) { AttrReaderMethod attrReader = (AttrReaderMethod)method; String varName = attrReader.getVariableName(); // we getVariableAccessorForWrite here so it is eagerly created and we don't cache the DUMMY VariableAccessor accessor = cls.getRealClass().getVariableAccessorForWrite(varName); // Ruby to attr reader if (RubyInstanceConfig.LOG_INDY_BINDINGS) { if (accessor instanceof FieldVariableAccessor) { LOG.info(site.name() + "\tbound as field attr reader " + logMethod(method) + ":" + ((AttrReaderMethod)method).getVariableName()); } else { LOG.info(site.name() + "\tbound as attr reader " + logMethod(method) + ":" + ((AttrReaderMethod)method).getVariableName()); } } return createAttrReaderHandle(site, cls, accessor); } }
private void addAccessor(ThreadContext context, RubySymbol identifier, Visibility visibility, boolean readable, boolean writeable) { String internedIdentifier = identifier.idString(); final Ruby runtime = context.runtime; if (visibility == MODULE_FUNCTION) { runtime.getWarnings().warn(ID.ACCESSOR_MODULE_FUNCTION, "attribute accessor as module_function"); visibility = PRIVATE; } if (!(IdUtil.isLocal(internedIdentifier) || IdUtil.isConstant(internedIdentifier))) { throw runtime.newNameError("invalid attribute name", internedIdentifier); } final String variableName = identifier.asInstanceVariable().idString(); if (readable) { addMethod(internedIdentifier, new AttrReaderMethod(methodLocation, visibility, variableName)); callMethod(context, "method_added", identifier); } if (writeable) { identifier = identifier.asWriter(); addMethod(identifier.idString(), new AttrWriterMethod(methodLocation, visibility, variableName)); callMethod(context, "method_added", identifier); } }
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { IRubyObject variable = (IRubyObject) verifyAccessor(self.getMetaClass().getRealClass()).get(self); return variable == null ? context.nil : variable; }
static MethodHandle buildAttrHandle(InvokeSite site, DynamicMethod method, IRubyObject self, RubyClass dispatchClass) { if (method instanceof AttrReaderMethod && site.arity == 0) { AttrReaderMethod attrReader = (AttrReaderMethod) method; String varName = attrReader.getVariableName(); LOG.info(site.name() + "\tbound as field attr reader " + logMethod(method) + ":" + ((AttrReaderMethod)method).getVariableName()); } else { LOG.info(site.name() + "\tbound as attr reader " + logMethod(method) + ":" + ((AttrReaderMethod)method).getVariableName());
private void addAccessor(ThreadContext context, RubySymbol identifier, Visibility visibility, boolean readable, boolean writeable) { String internedIdentifier = identifier.idString(); final Ruby runtime = context.runtime; if (visibility == MODULE_FUNCTION) { runtime.getWarnings().warn(ID.ACCESSOR_MODULE_FUNCTION, "attribute accessor as module_function"); visibility = PRIVATE; } if (!(IdUtil.isLocal(internedIdentifier) || IdUtil.isConstant(internedIdentifier))) { throw runtime.newNameError("invalid attribute name", internedIdentifier); } final String variableName = identifier.asInstanceVariable().idString(); if (readable) { addMethod(internedIdentifier, new AttrReaderMethod(methodLocation, visibility, variableName)); callMethod(context, "method_added", identifier); } if (writeable) { identifier = identifier.asWriter(); addMethod(identifier.idString(), new AttrWriterMethod(methodLocation, visibility, variableName)); callMethod(context, "method_added", identifier); } }
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { IRubyObject variable = (IRubyObject) verifyAccessor(self.getMetaClass().getRealClass()).get(self); return variable == null ? context.nil : variable; }
static MethodHandle buildAttrHandle(InvokeSite site, DynamicMethod method, IRubyObject self, RubyClass dispatchClass) { if (method instanceof AttrReaderMethod && site.arity == 0) { AttrReaderMethod attrReader = (AttrReaderMethod) method; String varName = attrReader.getVariableName(); LOG.info(site.name() + "\tbound as field attr reader " + logMethod(method) + ":" + ((AttrReaderMethod)method).getVariableName()); } else { LOG.info(site.name() + "\tbound as attr reader " + logMethod(method) + ":" + ((AttrReaderMethod)method).getVariableName());