@Override public DynamicMethod dup() { return new InterpretedIRMethod(method, visibility, implementationClass); }
@Override public DynamicMethod dup() { return new InterpretedIRMethod(method, visibility, implementationClass); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { Ruby runtime = context.runtime; IRubyObject obj = (IRubyObject)object.retrieve(context, self, currDynScope, temp); RubyClass singletonClass = Helpers.getSingletonClass(runtime, obj); metaClassBody.getStaticScope().setModule(singletonClass); return new InterpretedIRMethod(metaClassBody, Visibility.PUBLIC, singletonClass); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { Ruby runtime = context.runtime; IRubyObject obj = (IRubyObject)object.retrieve(context, self, currDynScope, temp); RubyClass singletonClass = Helpers.getSingletonClass(runtime, obj); metaClassBody.getStaticScope().setModule(singletonClass); return new InterpretedIRMethod(metaClassBody, Visibility.PUBLIC, singletonClass); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { Object rubyContainer = container.retrieve(context, self, currDynScope, temp); if (!(rubyContainer instanceof RubyModule)) { throw context.runtime.newTypeError("no outer class/module"); } RubyModule newRubyClass = newClass(context, self, (RubyModule) rubyContainer, currDynScope, temp); newIRClassBody.getStaticScope().setModule(newRubyClass); return new InterpretedIRMethod(newIRClassBody, Visibility.PUBLIC, newRubyClass); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { Object rubyContainer = container.retrieve(context, self, currDynScope, temp); if (!(rubyContainer instanceof RubyModule)) { throw context.runtime.newTypeError("no outer class/module"); } RubyModule newRubyClass = newClass(context, self, (RubyModule) rubyContainer, currDynScope, temp); newIRClassBody.getStaticScope().setModule(newRubyClass); return new InterpretedIRMethod(newIRClassBody, Visibility.PUBLIC, newRubyClass); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { Object rubyContainer = container.retrieve(context, self, currDynScope, temp); if (!(rubyContainer instanceof RubyModule)) { throw context.runtime.newTypeError("no outer class/module"); } RubyModule newRubyModule = ((RubyModule) rubyContainer).defineOrGetModuleUnder(newIRModuleBody.getName()); newIRModuleBody.getStaticScope().setModule(newRubyModule); return new InterpretedIRMethod(newIRModuleBody, Visibility.PUBLIC, newRubyModule); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { Object rubyContainer = container.retrieve(context, self, currDynScope, temp); if (!(rubyContainer instanceof RubyModule)) { throw context.runtime.newTypeError("no outer class/module"); } RubyModule newRubyModule = ((RubyModule) rubyContainer).defineOrGetModuleUnder(newIRModuleBody.getName()); newIRModuleBody.getStaticScope().setModule(newRubyModule); return new InterpretedIRMethod(newIRModuleBody, Visibility.PUBLIC, newRubyModule); }
@Interp public static void defInterpretedInstanceMethod(ThreadContext context, IRScope method, DynamicScope currDynScope, IRubyObject self) { Ruby runtime = context.runtime; RubySymbol methodName = method.getName(); RubyModule rubyClass = findInstanceMethodContainer(context, currDynScope, self); Visibility currVisibility = context.getCurrentVisibility(); Visibility newVisibility = Helpers.performNormalMethodChecksAndDetermineVisibility(runtime, rubyClass, methodName, currVisibility); DynamicMethod newMethod; if (runtime.getInstanceConfig().getCompileMode() == RubyInstanceConfig.CompileMode.OFF) { newMethod = new InterpretedIRMethod(method, newVisibility, rubyClass); } else { newMethod = new MixedModeIRMethod(method, newVisibility, rubyClass); } Helpers.addInstanceMethod(rubyClass, methodName, newMethod, currVisibility, context, runtime); }
@Interp public static void defInterpretedInstanceMethod(ThreadContext context, IRScope method, DynamicScope currDynScope, IRubyObject self) { Ruby runtime = context.runtime; RubySymbol methodName = method.getName(); RubyModule rubyClass = findInstanceMethodContainer(context, currDynScope, self); Visibility currVisibility = context.getCurrentVisibility(); Visibility newVisibility = Helpers.performNormalMethodChecksAndDetermineVisibility(runtime, rubyClass, methodName, currVisibility); DynamicMethod newMethod; if (runtime.getInstanceConfig().getCompileMode() == RubyInstanceConfig.CompileMode.OFF) { newMethod = new InterpretedIRMethod(method, newVisibility, rubyClass); } else { newMethod = new MixedModeIRMethod(method, newVisibility, rubyClass); } Helpers.addInstanceMethod(rubyClass, methodName, newMethod, currVisibility, context, runtime); }
@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); }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { String name = method.getName(); Ruby runtime = context.runtime; RubyObject obj = (RubyObject) container.retrieve(context, self, currDynScope, temp); if (obj instanceof RubyFixnum || obj instanceof RubySymbol) { throw runtime.newTypeError("can't define singleton method \"" + name + "\" for " + obj.getMetaClass().getBaseName()); } if (obj.isFrozen()) throw runtime.newFrozenError("object"); RubyClass rubyClass = obj.getSingletonClass(); rubyClass.addMethod(name, new InterpretedIRMethod(method, Visibility.PUBLIC, rubyClass)); obj.callMethod(context, "singleton_method_added", runtime.fastNewSymbol(name)); return null; }
@Override public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { String name = method.getName(); Ruby runtime = context.runtime; RubyObject obj = (RubyObject) container.retrieve(context, self, currDynScope, temp); if (obj instanceof RubyFixnum || obj instanceof RubySymbol) { throw runtime.newTypeError("can't define singleton method \"" + name + "\" for " + obj.getMetaClass().getBaseName()); } if (obj.isFrozen()) throw runtime.newFrozenError("object"); RubyClass rubyClass = obj.getSingletonClass(); rubyClass.addMethod(name, new InterpretedIRMethod(method, Visibility.PUBLIC, rubyClass)); obj.callMethod(context, "singleton_method_added", runtime.fastNewSymbol(name)); return null; }
DynamicMethod newMethod = new InterpretedIRMethod(method, visibility, clazz); clazz.addMethod(name, newMethod);
DynamicMethod newMethod = new InterpretedIRMethod(method, visibility, clazz); clazz.addMethod(name, newMethod);
public static IRubyObject interpret(Ruby runtime, Node rootNode, IRubyObject self) { if (runtime.is1_9()) IRBuilder.setRubyVersion("1.9"); IRScriptBody root = (IRScriptBody) IRBuilder.createIRBuilder(runtime, runtime.getIRManager()).buildRoot((RootNode) rootNode); // We get the live object ball rolling here. This give a valid value for the top // of this lexical tree. All new scope can then retrieve and set based on lexical parent. if (root.getStaticScope().getModule() == null) { // If an eval this may already be setup. root.getStaticScope().setModule(runtime.getObject()); } RubyModule currModule = root.getStaticScope().getModule(); // Scope state for root? IRStaticScopeFactory.newIRLocalScope(null).setModule(currModule); ThreadContext context = runtime.getCurrentContext(); try { runBeginEndBlocks(root.getBeginBlocks(), context, self, null); // FIXME: No temp vars yet...not needed? InterpretedIRMethod method = new InterpretedIRMethod(root, currModule); IRubyObject rv = method.call(context, self, currModule, "(root)", IRubyObject.NULL_ARRAY); runBeginEndBlocks(root.getEndBlocks(), context, self, null); // FIXME: No temp vars yet...not needed? if ((IRRuntimeHelpers.isDebug() || IRRuntimeHelpers.inProfileMode()) && interpInstrsCount > 10000) { LOG.info("-- Interpreted instructions: {}", interpInstrsCount); /* for (Operation o: opStats.keySet()) { System.out.println(o + " = " + opStats.get(o).count); } */ } return rv; } catch (IRBreakJump bj) { throw IRException.BREAK_LocalJumpError.getException(context.runtime); } }
public static IRubyObject interpret(Ruby runtime, Node rootNode, IRubyObject self) { if (runtime.is1_9()) IRBuilder.setRubyVersion("1.9"); IRScriptBody root = (IRScriptBody) IRBuilder.createIRBuilder(runtime, runtime.getIRManager()).buildRoot((RootNode) rootNode); // We get the live object ball rolling here. This give a valid value for the top // of this lexical tree. All new scope can then retrieve and set based on lexical parent. if (root.getStaticScope().getModule() == null) { // If an eval this may already be setup. root.getStaticScope().setModule(runtime.getObject()); } RubyModule currModule = root.getStaticScope().getModule(); // Scope state for root? IRStaticScopeFactory.newIRLocalScope(null).setModule(currModule); ThreadContext context = runtime.getCurrentContext(); try { runBeginEndBlocks(root.getBeginBlocks(), context, self, null); // FIXME: No temp vars yet...not needed? InterpretedIRMethod method = new InterpretedIRMethod(root, currModule); IRubyObject rv = method.call(context, self, currModule, "(root)", IRubyObject.NULL_ARRAY); runBeginEndBlocks(root.getEndBlocks(), context, self, null); // FIXME: No temp vars yet...not needed? if ((IRRuntimeHelpers.isDebug() || IRRuntimeHelpers.inProfileMode()) && interpInstrsCount > 10000) { LOG.info("-- Interpreted instructions: {}", interpInstrsCount); /* for (Operation o: opStats.keySet()) { System.out.println(o + " = " + opStats.get(o).count); } */ } return rv; } catch (IRBreakJump bj) { throw IRException.BREAK_LocalJumpError.getException(context.runtime); } }