private TryGetConstant ( |
||
autoloadScope | ||
name | string | |
value | IronRuby.Runtime.ConstantStorage | |
return | bool |
public static bool IsConstantDefined(RubyModule /*!*/ self, [DefaultProtocol, NotNull] string /*!*/ constantName) { RubyUtils.CheckConstantName(constantName); object constant; // MRI checks declared constans only and don't trigger autoload: return(self.TryGetConstant(null, constantName, out constant)); }
public static Object Scan(ConversionStorage<MutableString>/*!*/ toMutableStringStorage, RespondToStorage/*!*/ respondsTo, BinaryOpStorage/*!*/ readIOStorage, BlockParam block, RubyModule/*!*/ self, Object/*!*/ source, Hash/*!*/ options) { Object elementContent; if (!self.TryGetConstant(null, "ElementContent", out elementContent) && !(elementContent is Hash)) { throw new Exception("Hpricot::ElementContent is missing or it is not an Hash"); } var scanner = new HpricotScanner(toMutableStringStorage, readIOStorage, block); return scanner.Scan(source, options, elementContent as Hash); }
public static bool IsConstantDefined(RubyModule/*!*/ self, [DefaultProtocol, NotNull]string/*!*/ constantName) { self.Context.CheckConstantName(constantName); object constant; // MRI checks declared constans only and don't trigger autoload: return self.TryGetConstant(null, constantName, out constant); }
internal static RubyClass/*!*/ DefineClass(Scope/*!*/ autoloadScope, RubyModule/*!*/ owner, string/*!*/ name, object superClassObject) { Assert.NotNull(owner); RubyClass superClass = ToSuperClass(owner.Context, superClassObject); object existing; if (ReferenceEquals(owner, owner.Context.ObjectClass) ? owner.TryResolveConstant(autoloadScope, name, out existing) : owner.TryGetConstant(autoloadScope, name, out existing)) { RubyClass cls = existing as RubyClass; if (cls == null || !cls.IsClass) { throw RubyExceptions.CreateTypeError(String.Format("{0} is not a class", name)); } if (superClassObject != null && !ReferenceEquals(cls.SuperClass, superClass)) { throw RubyExceptions.CreateTypeError(String.Format("superclass mismatch for class {0}", name)); } return cls; } else { return owner.Context.DefineClass(owner, name, superClass); } }
internal static RubyModule/*!*/ DefineModule(Scope/*!*/ autoloadScope, RubyModule/*!*/ owner, string/*!*/ name) { Assert.NotNull(autoloadScope, owner); object existing; if (owner.TryGetConstant(autoloadScope, name, out existing)) { RubyModule module = existing as RubyModule; if (module == null || module.IsClass) { throw RubyExceptions.CreateTypeError(String.Format("{0} is not a module", name)); } return module; } else { // create class/module object: return owner.Context.DefineModule(owner, name); } }