public static void checkNameAvailability(ThreadContext context, String name) { if (context.runtime.getObject().getConstantAt(name) != null) throw context.runtime.newNameError(name + " is already defined", name); }
/** * Retrieve the module with the given name from the Object namespace. * * @param name The name of the module * @return The module or null if not found */ public RubyModule getModule(String name) { return (RubyModule) objectClass.getConstantAt(name); }
/** * Retrieve the module with the given name from the Object namespace. * * @param name The name of the module * @return The module or null if not found */ public RubyModule getModule(String name) { return (RubyModule) objectClass.getConstantAt(name); }
static RubyClass getDate(final Ruby runtime) { return (RubyClass) runtime.getObject().getConstantAt("Date"); }
static RubyClass getDate(final Ruby runtime) { return (RubyClass) runtime.getObject().getConstantAt("Date"); }
static RubyClass getDateTime(final Ruby runtime) { return (RubyClass) runtime.getObject().getConstantAt("DateTime"); }
static RubyClass getDateTime(final Ruby runtime) { return (RubyClass) runtime.getObject().getConstantAt("DateTime"); }
/** * From Object, retrieve the named module. If it doesn't exist a * new module is created. * * @param name The name of the module * @returns The existing or new module */ public RubyModule getOrCreateModule(String name) { IRubyObject module = objectClass.getConstantAt(name); if (module == null) { module = defineModule(name); } else if (!module.isModule()) { throw newTypeError(name + " is not a Module"); } return (RubyModule) module; }
/** * From Object, retrieve the named module. If it doesn't exist a * new module is created. * * @param name The name of the module * @returns The existing or new module */ public RubyModule getOrCreateModule(String name) { IRubyObject module = objectClass.getConstantAt(name); if (module == null) { module = defineModule(name); } else if (!module.isModule()) { throw newTypeError(name + " is not a Module"); } return (RubyModule) module; }
static DivideTSortHash newInstance(final ThreadContext context) { final Ruby runtime = context.runtime; RubyClass Set = runtime.getClass("Set"); RubyClass klass = (RubyClass) Set.getConstantAt(NAME, true); if (klass == null) { // initialize on-demand when Set#divide is first called synchronized (DivideTSortHash.class) { klass = (RubyClass) Set.getConstantAt(NAME, true); if (klass == null) { klass = Set.defineClassUnder(NAME, runtime.getHash(), runtime.getHash().getAllocator()); Set.setConstantVisibility(runtime, NAME, true); // private klass.includeModule(getTSort(runtime)); klass.defineAnnotatedMethods(DivideTSortHash.class); } } } return new DivideTSortHash(runtime, klass); }
private RubyArray getLines(ParserConfiguration configuration, Ruby runtime, String file) { RubyArray list = null; IRubyObject scriptLines = runtime.getObject().getConstantAt("SCRIPT_LINES__"); if (!configuration.isEvalParse() && scriptLines != null) { if (scriptLines instanceof RubyHash) { list = runtime.newArray(); ((RubyHash) scriptLines).op_aset(runtime.getCurrentContext(), runtime.newString(file), list); } } return list; }
/** * From Object, retrieve the named module. If it doesn't exist a * new module is created. * * @param id The name of the module * @returns The existing or new module */ public RubyModule getOrCreateModule(String id) { IRubyObject module = objectClass.getConstantAt(id); if (module == null) { module = defineModule(id); } else if (!module.isModule()) { throw newTypeError(str(this, ids(this, id), " is not a Module")); } return (RubyModule) module; }
/** * From Object, retrieve the named module. If it doesn't exist a * new module is created. * * @param id The name of the module * @returns The existing or new module */ public RubyModule getOrCreateModule(String id) { IRubyObject module = objectClass.getConstantAt(id); if (module == null) { module = defineModule(id); } else if (!module.isModule()) { throw newTypeError(str(this, ids(this, id), " is not a Module")); } return (RubyModule) module; }
private RubyArray getLines(ParserConfiguration configuration, Ruby runtime, String file) { RubyArray list = null; IRubyObject scriptLines = runtime.getObject().getConstantAt("SCRIPT_LINES__"); if (!configuration.isEvalParse() && scriptLines != null) { if (scriptLines instanceof RubyHash) { list = runtime.newArray(); ((RubyHash) scriptLines).op_aset(runtime.getCurrentContext(), runtime.newString(file), list); } } return list; }
static DivideTSortHash newInstance(final ThreadContext context) { final Ruby runtime = context.runtime; RubyClass Set = runtime.getClass("Set"); RubyClass klass = (RubyClass) Set.getConstantAt(NAME, true); if (klass == null) { // initialize on-demand when Set#divide is first called synchronized (DivideTSortHash.class) { klass = (RubyClass) Set.getConstantAt(NAME, true); if (klass == null) { klass = Set.defineClassUnder(NAME, runtime.getHash(), runtime.getHash().getAllocator()); Set.setConstantVisibility(runtime, NAME, true); // private klass.includeModule(getTSort(runtime)); klass.defineAnnotatedMethods(DivideTSortHash.class); } } } return new DivideTSortHash(runtime, klass); }
private RubyArray getLines(ParserConfiguration configuration, Ruby runtime, String file) { RubyArray list = null; IRubyObject scriptLines = runtime.getObject().getConstantAt("SCRIPT_LINES__"); if (!configuration.isEvalParse() && scriptLines != null) { if (scriptLines instanceof RubyHash) { RubyString filename = runtime.newString(file); ThreadContext context = runtime.getCurrentContext(); IRubyObject object = ((RubyHash) scriptLines).op_aref(context, filename); list = (RubyArray) (object instanceof RubyArray ? object : runtime.newArray()); ((RubyHash) scriptLines).op_aset(context, filename, list); } } return list; } }
private RubyArray getLines(ParserConfiguration configuration, Ruby runtime, String file) { RubyArray list = null; IRubyObject scriptLines = runtime.getObject().getConstantAt("SCRIPT_LINES__"); if (!configuration.isEvalParse() && scriptLines != null) { if (scriptLines instanceof RubyHash) { RubyString filename = runtime.newString(file); ThreadContext context = runtime.getCurrentContext(); IRubyObject object = ((RubyHash) scriptLines).op_aref(context, filename); list = (RubyArray) (object instanceof RubyArray ? object : runtime.newArray()); ((RubyHash) scriptLines).op_aset(context, filename, list); } } return list; } }
IRubyObject type = superClass.getConstantAt(name); if (type != null) { ThreadContext context = runtime.getCurrentContext();
IRubyObject type = superClass.getConstantAt(name); if (type != null) { ThreadContext context = runtime.getCurrentContext();
IRubyObject type = superClass.getConstantAt(name); if (type != null) { ThreadContext context = runtime.getCurrentContext();