예제 #1
0
파일: RubyClass.cs 프로젝트: kashano/main
 // 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;
 }
예제 #2
0
 public static MutableString GetAutoloadedConstantPath(RubyScope/*!*/ scope, object self, [DefaultProtocol, NotNull]string/*!*/ constantName) {
     return ModuleOps.GetAutoloadedConstantPath(scope.GetInnerMostModuleForConstantLookup(), constantName);
 }
예제 #3
0
 public static void SetAutoloadedConstant(RubyScope/*!*/ scope, object self,
     [DefaultProtocol, NotNull]string/*!*/ constantName, [DefaultProtocol, NotNull]MutableString/*!*/ path) {
     ModuleOps.SetAutoloadedConstant(scope.GetInnerMostModuleForConstantLookup(), constantName, path);
 }
예제 #4
0
 [Emitted] // ConstantVariable:
 public static object SetUnqualifiedConstant(object value, RubyScope/*!*/ scope, string/*!*/ name) {
     RubyUtils.SetConstant(scope.GetInnerMostModuleForConstantLookup(), name, value);
     return value;
 }
예제 #5
0
 public static RubyModule/*!*/ DefineNestedClass(RubyScope/*!*/ scope, string/*!*/ name, object superClassObject) {
     return RubyUtils.DefineClass(scope.GlobalScope, scope.GetInnerMostModuleForConstantLookup(), name, superClassObject);
 }
예제 #6
0
 public static RubyModule/*!*/ DefineNestedModule(RubyScope/*!*/ scope, string/*!*/ name) {
     return RubyUtils.DefineModule(scope.GlobalScope, scope.GetInnerMostModuleForConstantLookup(), name);
 }