Exemplo n.º 1
0
 // implements Class#new
 public static object CreateAnonymousClass(RubyScope/*!*/ scope, BlockParam body, RubyClass/*!*/ self, [DefaultParameterValue(null)]RubyClass superClass) {
     RubyContext context = scope.RubyContext;
     RubyModule owner = scope.GetInnerMostModuleForConstantLookup();
     
     // MRI is inconsistent here, it triggers "inherited" event after the body of the method is evaluated.
     // In all other cases the order is event first, body next.
     RubyClass newClass = context.DefineClass(owner, null, superClass ?? context.ObjectClass, null);
     return (body != null) ? RubyUtils.EvaluateInModule(newClass, body, new[] { newClass }, newClass) : newClass;
 }
Exemplo n.º 2
0
 public static MutableString GetAutoloadedConstantPath(RubyScope/*!*/ scope, object self, [DefaultProtocol, NotNull]string/*!*/ constantName) {
     return ModuleOps.GetAutoloadedConstantPath(scope.GetInnerMostModuleForConstantLookup(), constantName);
 }
Exemplo n.º 3
0
 public static void SetAutoloadedConstant(RubyScope/*!*/ scope, object self,
     [DefaultProtocol, NotNull]string/*!*/ constantName, [DefaultProtocol, NotNull]MutableString/*!*/ path) {
     ModuleOps.SetAutoloadedConstant(scope.GetInnerMostModuleForConstantLookup(), constantName, path);
 }
Exemplo n.º 4
0
 [Emitted] // ConstantVariable:
 public static object SetUnqualifiedConstant(object value, RubyScope/*!*/ scope, string/*!*/ name) {
     RubyUtils.SetConstant(scope.GetInnerMostModuleForConstantLookup(), name, value);
     return value;
 }
Exemplo n.º 5
0
 public static RubyModule/*!*/ DefineNestedClass(RubyScope/*!*/ scope, string/*!*/ name, object superClassObject) {
     return RubyUtils.DefineClass(scope.GlobalScope, scope.GetInnerMostModuleForConstantLookup(), name, superClassObject);
 }
Exemplo n.º 6
0
 public static RubyModule/*!*/ DefineNestedModule(RubyScope/*!*/ scope, string/*!*/ name) {
     return RubyUtils.DefineModule(scope.GlobalScope, scope.GetInnerMostModuleForConstantLookup(), name);
 }