@Override public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) { AttrWriterMethod attrReader = (AttrWriterMethod)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 writer " + logMethod(method) + ":" + ((AttrWriterMethod) method).getVariableName()); } else { LOG.info(site.name() + "\tbound as attr writer " + logMethod(method) + ":" + ((AttrWriterMethod) method).getVariableName()); } } return createAttrWriterHandle(site, cls, accessor); } }
public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg1) { verifyAccessor(self.getMetaClass().getRealClass()).set(self, arg1); return arg1; }
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 arg1) { verifyAccessor(self.getMetaClass().getRealClass()).set(self, arg1); return arg1; }
@Override public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) { AttrWriterMethod attrReader = (AttrWriterMethod)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 writer " + logMethod(method) + ":" + ((AttrWriterMethod) method).getVariableName()); } else { LOG.info(site.name() + "\tbound as attr writer " + logMethod(method) + ":" + ((AttrWriterMethod) method).getVariableName()); } } return createAttrWriterHandle(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 arg1) { verifyAccessor(self.getMetaClass().getRealClass()).set(self, arg1); return arg1; }
} else if (method instanceof AttrWriterMethod && site.arity == 1) { AttrWriterMethod attrReader = (AttrWriterMethod)method; String varName = attrReader.getVariableName(); LOG.info(site.name() + "\tbound as field attr writer " + logMethod(method) + ":" + ((AttrWriterMethod) method).getVariableName()); } else { LOG.info(site.name() + "\tbound as attr writer " + logMethod(method) + ":" + ((AttrWriterMethod) 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 arg1) { verifyAccessor(self.getMetaClass().getRealClass()).set(self, arg1); return arg1; }
} else if (method instanceof AttrWriterMethod && site.arity == 1) { AttrWriterMethod attrReader = (AttrWriterMethod)method; String varName = attrReader.getVariableName(); LOG.info(site.name() + "\tbound as field attr writer " + logMethod(method) + ":" + ((AttrWriterMethod) method).getVariableName()); } else { LOG.info(site.name() + "\tbound as attr writer " + logMethod(method) + ":" + ((AttrWriterMethod) method).getVariableName());