@Override public String toString() { return "module<" + scope.getName() + ">"; }
private RubySymbol methodNameFor() { IRScope method = scope.getNearestMethod(); return method == null ? null : method.getName(); }
@Override public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) { StaticScope staticScope = scope.getStaticScope(); return staticScope != null ? staticScope.getModule() : context.runtime.getClass(scope.getName()); }
@Override public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) { StaticScope staticScope = scope.getStaticScope(); return staticScope != null ? staticScope.getModule() : context.runtime.getClass(scope.getName()); }
@Override public String toString() { return getScopeName() + " " + getName() + "[" + getFileName() + ":" + getLineNumber() + "]"; }
@Override public String toString() { return getScopeName() + " " + getName() + "[" + getFileName() + ":" + getLineNumber() + "]"; }
private static RubyClass checkClassForDef(ThreadContext context, IRScope method, IRubyObject obj) { if (obj instanceof RubyFixnum || obj instanceof RubySymbol || obj instanceof RubyFloat) { throw context.runtime.newTypeError(str(context.runtime, "can't define singleton method \"", method.getName(), "\" for ", obj.getMetaClass().rubyBaseName())); } // if (obj.isFrozen()) throw context.runtime.newFrozenError("object"); return obj.getSingletonClass(); }
private static RubyClass checkClassForDef(ThreadContext context, IRScope method, IRubyObject obj) { if (obj instanceof RubyFixnum || obj instanceof RubySymbol || obj instanceof RubyFloat) { throw context.runtime.newTypeError(str(context.runtime, "can't define singleton method \"", method.getName(), "\" for ", obj.getMetaClass().rubyBaseName())); } // if (obj.isFrozen()) throw context.runtime.newFrozenError("object"); return obj.getSingletonClass(); }
@JIT public static void defCompiledInstanceMethod(ThreadContext context, MethodHandle handle, IRScope method, DynamicScope currDynScope, IRubyObject self) { Ruby runtime = context.runtime; RubySymbol methodName = method.getName(); RubyModule clazz = findInstanceMethodContainer(context, currDynScope, self); Visibility currVisibility = context.getCurrentVisibility(); Visibility newVisibility = Helpers.performNormalMethodChecksAndDetermineVisibility(runtime, clazz, methodName, currVisibility); DynamicMethod newMethod = new CompiledIRMethod(handle, method, newVisibility, clazz); // FIXME: needs checkID and proper encoding to force hard symbol Helpers.addInstanceMethod(clazz, methodName, newMethod, currVisibility, context, runtime); }
@JIT public static void defCompiledInstanceMethod(ThreadContext context, MethodHandle variable, MethodHandle specific, int specificArity, IRScope method, DynamicScope currDynScope, IRubyObject self) { Ruby runtime = context.runtime; RubySymbol methodName = method.getName(); RubyModule clazz = findInstanceMethodContainer(context, currDynScope, self); Visibility currVisibility = context.getCurrentVisibility(); Visibility newVisibility = Helpers.performNormalMethodChecksAndDetermineVisibility(runtime, clazz, methodName, currVisibility); DynamicMethod newMethod = new CompiledIRMethod(variable, specific, specificArity, method, newVisibility, clazz); // FIXME: needs checkID and proper encoding to force hard symbol Helpers.addInstanceMethod(clazz, methodName, newMethod, currVisibility, context, runtime); }
@JIT public static void defCompiledInstanceMethod(ThreadContext context, MethodHandle handle, IRScope method, DynamicScope currDynScope, IRubyObject self) { Ruby runtime = context.runtime; RubySymbol methodName = method.getName(); RubyModule clazz = findInstanceMethodContainer(context, currDynScope, self); Visibility currVisibility = context.getCurrentVisibility(); Visibility newVisibility = Helpers.performNormalMethodChecksAndDetermineVisibility(runtime, clazz, methodName, currVisibility); DynamicMethod newMethod = new CompiledIRMethod(handle, method, newVisibility, clazz); // FIXME: needs checkID and proper encoding to force hard symbol Helpers.addInstanceMethod(clazz, methodName, newMethod, currVisibility, context, runtime); }
@JIT public static void defCompiledInstanceMethod(ThreadContext context, MethodHandle variable, MethodHandle specific, int specificArity, IRScope method, DynamicScope currDynScope, IRubyObject self) { Ruby runtime = context.runtime; RubySymbol methodName = method.getName(); RubyModule clazz = findInstanceMethodContainer(context, currDynScope, self); Visibility currVisibility = context.getCurrentVisibility(); Visibility newVisibility = Helpers.performNormalMethodChecksAndDetermineVisibility(runtime, clazz, methodName, currVisibility); DynamicMethod newMethod = new CompiledIRMethod(variable, specific, specificArity, method, newVisibility, clazz); // FIXME: needs checkID and proper encoding to force hard symbol Helpers.addInstanceMethod(clazz, methodName, newMethod, currVisibility, context, runtime); }
@JIT public static void defCompiledClassMethod(ThreadContext context, MethodHandle handle, IRScope method, IRubyObject obj) { RubySymbol methodName = method.getName(); RubyClass rubyClass = checkClassForDef(context, method, obj); // FIXME: needs checkID and proper encoding to force hard symbol rubyClass.addMethod(methodName.idString(), new CompiledIRMethod(handle, method, Visibility.PUBLIC, rubyClass)); if (!rubyClass.isRefinement()) { // FIXME: needs checkID and proper encoding to force hard symbol obj.callMethod(context, "singleton_method_added", methodName); } }
@JIT public static void defCompiledClassMethod(ThreadContext context, MethodHandle variable, MethodHandle specific, int specificArity, IRScope method, IRubyObject obj) { RubyClass rubyClass = checkClassForDef(context, method, obj); rubyClass.addMethod(method.getId(), new CompiledIRMethod(variable, specific, specificArity, method, Visibility.PUBLIC, rubyClass)); if (!rubyClass.isRefinement()) obj.callMethod(context, "singleton_method_added", method.getName()); }
@JIT public static void defCompiledClassMethod(ThreadContext context, MethodHandle handle, IRScope method, IRubyObject obj) { RubySymbol methodName = method.getName(); RubyClass rubyClass = checkClassForDef(context, method, obj); // FIXME: needs checkID and proper encoding to force hard symbol rubyClass.addMethod(methodName.idString(), new CompiledIRMethod(handle, method, Visibility.PUBLIC, rubyClass)); if (!rubyClass.isRefinement()) { // FIXME: needs checkID and proper encoding to force hard symbol obj.callMethod(context, "singleton_method_added", methodName); } }
@JIT public static void defCompiledClassMethod(ThreadContext context, MethodHandle variable, MethodHandle specific, int specificArity, IRScope method, IRubyObject obj) { RubyClass rubyClass = checkClassForDef(context, method, obj); rubyClass.addMethod(method.getId(), new CompiledIRMethod(variable, specific, specificArity, method, Visibility.PUBLIC, rubyClass)); if (!rubyClass.isRefinement()) obj.callMethod(context, "singleton_method_added", method.getName()); }
@Override public void setName(RubySymbol name) { ByteList newName = getLexicalParent().getName().getBytes().dup(); newName.append(name.getBytes()); super.setName(getManager().getRuntime().newSymbol(newName)); }
@Override public void setName(RubySymbol name) { ByteList newName = getLexicalParent().getName().getBytes().dup(); newName.append(name.getBytes()); super.setName(getManager().getRuntime().newSymbol(newName)); }
@Interp public static void defInterpretedClassMethod(ThreadContext context, IRScope method, IRubyObject obj) { RubySymbol methodName = method.getName(); RubyClass rubyClass = checkClassForDef(context, method, obj); DynamicMethod newMethod; if (context.runtime.getInstanceConfig().getCompileMode() == RubyInstanceConfig.CompileMode.OFF) { newMethod = new InterpretedIRMethod(method, Visibility.PUBLIC, rubyClass); } else { newMethod = new MixedModeIRMethod(method, Visibility.PUBLIC, rubyClass); } rubyClass.addMethod(methodName.idString(), newMethod); if (!rubyClass.isRefinement()) obj.callMethod(context, "singleton_method_added", methodName); }
@Interp public static void defInterpretedClassMethod(ThreadContext context, IRScope method, IRubyObject obj) { RubySymbol methodName = method.getName(); RubyClass rubyClass = checkClassForDef(context, method, obj); DynamicMethod newMethod; if (context.runtime.getInstanceConfig().getCompileMode() == RubyInstanceConfig.CompileMode.OFF) { newMethod = new InterpretedIRMethod(method, Visibility.PUBLIC, rubyClass); } else { newMethod = new MixedModeIRMethod(method, Visibility.PUBLIC, rubyClass); } rubyClass.addMethod(methodName.idString(), newMethod); if (!rubyClass.isRefinement()) obj.callMethod(context, "singleton_method_added", methodName); }