本文整理了Java中org.jruby.Ruby.getDummy
方法的一些代码示例,展示了Ruby.getDummy
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getDummy
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getDummy
暂无
代码示例来源:origin: org.jruby/jruby-complete
public static Visibility performNormalMethodChecksAndDetermineVisibility(Ruby runtime, RubyModule clazz,
RubySymbol symbol, Visibility visibility) throws RaiseException {
String name = symbol.asJavaString(); // We just assume simple ascii string since that is all we are examining.
if (clazz == runtime.getDummy()) {
throw runtime.newTypeError("no class/module to add method");
}
if (clazz == runtime.getObject() && "initialize".equals(name)) {
runtime.getWarnings().warn(ID.REDEFINING_DANGEROUS, "redefining Object#initialize may cause infinite loop");
}
if ("__id__".equals(name) || "__send__".equals(name)) {
runtime.getWarnings().warn(ID.REDEFINING_DANGEROUS, str(runtime, "redefining `", ids(runtime, symbol), "' may cause serious problem"));
}
if ("initialize".equals(name) || "initialize_copy".equals(name) || name.equals("initialize_dup") || name.equals("initialize_clone") || name.equals("respond_to_missing?") || visibility == Visibility.MODULE_FUNCTION) {
visibility = Visibility.PRIVATE;
}
return visibility;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
protected RubyModule getInstanceEvalClass() {
if (isImmediate()) {
// Ruby uses Qnil here, we use "dummy" because we need a class
return getRuntime().getDummy();
} else {
return getSingletonClass();
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
protected RubyModule getInstanceEvalClass() {
if (isImmediate()) {
// Ruby uses Qnil here, we use "dummy" because we need a class
return getRuntime().getDummy();
} else {
return getSingletonClass();
}
}
代码示例来源:origin: org.jruby/jruby-complete
protected RubyModule getInstanceEvalClass() {
if (isImmediate()) {
// Ruby uses Qnil here, we use "dummy" because we need a class
return getRuntime().getDummy();
}
return getSingletonClass();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private static void performNormalMethodChecks(RubyModule containingClass, Ruby runtime, String name) throws RaiseException {
if (containingClass == runtime.getDummy()) {
throw runtime.newTypeError("no class/module to add method");
}
if (containingClass == runtime.getObject() && name.equals("initialize")) {
runtime.getWarnings().warn(ID.REDEFINING_DANGEROUS, "redefining Object#initialize may cause infinite loop");
}
if (name.equals("__id__") || name.equals("__send__")) {
runtime.getWarnings().warn(ID.REDEFINING_DANGEROUS, "redefining `" + name + "' may cause serious problem");
}
}
代码示例来源:origin: org.jruby/jruby-core
protected RubyModule getInstanceEvalClass() {
if (isImmediate()) {
// Ruby uses Qnil here, we use "dummy" because we need a class
return getRuntime().getDummy();
}
return getSingletonClass();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private static void performNormalMethodChecks(RubyModule containingClass, Ruby runtime, String name) throws RaiseException {
if (containingClass == runtime.getDummy()) {
throw runtime.newTypeError("no class/module to add method");
}
if (containingClass == runtime.getObject() && name.equals("initialize")) {
runtime.getWarnings().warn(ID.REDEFINING_DANGEROUS, "redefining Object#initialize may cause infinite loop");
}
if (name.equals("__id__") || name.equals("__send__")) {
runtime.getWarnings().warn(ID.REDEFINING_DANGEROUS, "redefining `" + name + "' may cause serious problem");
}
}
代码示例来源:origin: org.jruby/jruby-core
public static Visibility performNormalMethodChecksAndDetermineVisibility(Ruby runtime, RubyModule clazz,
RubySymbol symbol, Visibility visibility) throws RaiseException {
String name = symbol.asJavaString(); // We just assume simple ascii string since that is all we are examining.
if (clazz == runtime.getDummy()) {
throw runtime.newTypeError("no class/module to add method");
}
if (clazz == runtime.getObject() && "initialize".equals(name)) {
runtime.getWarnings().warn(ID.REDEFINING_DANGEROUS, "redefining Object#initialize may cause infinite loop");
}
if ("__id__".equals(name) || "__send__".equals(name)) {
runtime.getWarnings().warn(ID.REDEFINING_DANGEROUS, str(runtime, "redefining `", ids(runtime, symbol), "' may cause serious problem"));
}
if ("initialize".equals(name) || "initialize_copy".equals(name) || name.equals("initialize_dup") || name.equals("initialize_clone") || name.equals("respond_to_missing?") || visibility == Visibility.MODULE_FUNCTION) {
visibility = Visibility.PRIVATE;
}
return visibility;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "instance_exec", optional = 3, rest = true, compat = RUBY1_9)
public IRubyObject instance_exec19(ThreadContext context, IRubyObject[] args, Block block) {
if (!block.isGiven()) {
throw context.runtime.newLocalJumpErrorNoBlock();
}
RubyModule klazz;
if (isImmediate()) {
// Ruby uses Qnil here, we use "dummy" because we need a class
klazz = context.runtime.getDummy();
} else {
klazz = getSingletonClass();
}
return yieldUnder(context, klazz, args, block);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "instance_exec", optional = 3, rest = true, compat = RUBY1_9)
public IRubyObject instance_exec19(ThreadContext context, IRubyObject[] args, Block block) {
if (!block.isGiven()) {
throw context.runtime.newLocalJumpErrorNoBlock();
}
RubyModule klazz;
if (isImmediate()) {
// Ruby uses Qnil here, we use "dummy" because we need a class
klazz = context.runtime.getDummy();
} else {
klazz = getSingletonClass();
}
return yieldUnder(context, klazz, args, block);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
if (isImmediate()) {
klazz = context.runtime.getDummy();
} else {
klazz = getSingletonClass();
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static RubyModule getClassVariableBase(Ruby runtime, StaticScope scope) {
RubyModule rubyClass = scope.getModule();
while (rubyClass.isSingleton() || rubyClass == runtime.getDummy()) {
// We ran out of scopes to check
if (scope == null) return null;
scope = scope.getPreviousCRefScope();
rubyClass = scope.getModule();
if (scope.getPreviousCRefScope() == null) {
runtime.getWarnings().warn(ID.CVAR_FROM_TOPLEVEL_SINGLETON_METHOD, "class variable access from toplevel singleton method");
}
}
return rubyClass;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static RubyModule getClassVariableBase(Ruby runtime, StaticScope scope) {
RubyModule rubyClass = scope.getModule();
while (rubyClass.isSingleton() || rubyClass == runtime.getDummy()) {
// We ran out of scopes to check
if (scope == null) return null;
scope = scope.getPreviousCRefScope();
rubyClass = scope.getModule();
if (scope.getPreviousCRefScope() == null) {
runtime.getWarnings().warn(ID.CVAR_FROM_TOPLEVEL_SINGLETON_METHOD, "class variable access from toplevel singleton method");
}
}
return rubyClass;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
if (isImmediate()) {
klazz = context.runtime.getDummy();
} else {
klazz = getSingletonClass();
代码示例来源:origin: org.jruby/jruby-complete
public static RubyModule getModuleFromScope(ThreadContext context, StaticScope scope, IRubyObject arg) {
Ruby runtime = context.runtime;
RubyModule rubyClass = scope.getModule();
// SSS FIXME: Copied from ASTInterpreter.getClassVariableBase and adapted
while (scope != null && (rubyClass.isSingleton() || rubyClass == runtime.getDummy())) {
scope = scope.getPreviousCRefScope();
rubyClass = scope.getModule();
if (scope.getPreviousCRefScope() == null) {
runtime.getWarnings().warn(IRubyWarnings.ID.CVAR_FROM_TOPLEVEL_SINGLETON_METHOD, "class variable access from toplevel singleton method");
}
}
if ((scope == null) && (arg != null)) {
// We ran out of scopes to check -- look in arg's metaclass
rubyClass = arg.getMetaClass();
}
if (rubyClass == null) {
throw context.runtime.newTypeError("no class/module to define class variable");
}
return rubyClass;
}
代码示例来源:origin: org.jruby/jruby-core
public static RubyModule getModuleFromScope(ThreadContext context, StaticScope scope, IRubyObject arg) {
Ruby runtime = context.runtime;
RubyModule rubyClass = scope.getModule();
// SSS FIXME: Copied from ASTInterpreter.getClassVariableBase and adapted
while (scope != null && (rubyClass.isSingleton() || rubyClass == runtime.getDummy())) {
scope = scope.getPreviousCRefScope();
rubyClass = scope.getModule();
if (scope.getPreviousCRefScope() == null) {
runtime.getWarnings().warn(IRubyWarnings.ID.CVAR_FROM_TOPLEVEL_SINGLETON_METHOD, "class variable access from toplevel singleton method");
}
}
if ((scope == null) && (arg != null)) {
// We ran out of scopes to check -- look in arg's metaclass
rubyClass = arg.getMetaClass();
}
if (rubyClass == null) {
throw context.runtime.newTypeError("no class/module to define class variable");
}
return rubyClass;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
if (clazz == runtime.getDummy()) {
throw runtime.newTypeError("no class/module to add method");
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@Override
public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) {
Ruby runtime = context.runtime;
StaticScope scope = (StaticScope) startingScope.retrieve(context, self, currDynScope, temp);
RubyModule rubyClass = scope.getModule();
// SSS FIXME: Copied from ASTInterpreter.getClassVariableBase and adapted
while (scope != null && (rubyClass.isSingleton() || rubyClass == runtime.getDummy())) {
scope = scope.getPreviousCRefScope();
rubyClass = scope.getModule();
if (scope.getPreviousCRefScope() == null) {
runtime.getWarnings().warn(ID.CVAR_FROM_TOPLEVEL_SINGLETON_METHOD, "class variable access from toplevel singleton method");
}
}
if ((scope == null) && (object != null)) {
// We ran out of scopes to check -- look in arg's metaclass
IRubyObject arg = (IRubyObject) object.retrieve(context, self, currDynScope, temp);
rubyClass = arg.getMetaClass();
}
if (rubyClass == null) {
throw context.runtime.newTypeError("no class/module to define class variable");
}
return rubyClass;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@Override
public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) {
Ruby runtime = context.runtime;
StaticScope scope = (StaticScope) startingScope.retrieve(context, self, currDynScope, temp);
RubyModule rubyClass = scope.getModule();
// SSS FIXME: Copied from ASTInterpreter.getClassVariableBase and adapted
while (scope != null && (rubyClass.isSingleton() || rubyClass == runtime.getDummy())) {
scope = scope.getPreviousCRefScope();
rubyClass = scope.getModule();
if (scope.getPreviousCRefScope() == null) {
runtime.getWarnings().warn(ID.CVAR_FROM_TOPLEVEL_SINGLETON_METHOD, "class variable access from toplevel singleton method");
}
}
if ((scope == null) && (object != null)) {
// We ran out of scopes to check -- look in arg's metaclass
IRubyObject arg = (IRubyObject) object.retrieve(context, self, currDynScope, temp);
rubyClass = arg.getMetaClass();
}
if (rubyClass == null) {
throw context.runtime.newTypeError("no class/module to define class variable");
}
return rubyClass;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
RubyModule containingClass = context.getRubyClass();
if (containingClass == runtime.getDummy()) {
throw runtime.newTypeError("no class/module to add method");
内容来源于网络,如有侵权,请联系作者删除!