internal MarshalReader(ReaderSites /*!*/ sites, BinaryReader /*!*/ reader, RubyGlobalScope /*!*/ globalScope, Proc proc) { _sites = sites; _reader = reader; _globalScope = globalScope; _proc = proc; _symbols = new Dictionary <int, Symbol>(); _objects = new Dictionary <int, object>(); }
public RubyConstructor(RubyGlobalScope /*!*/ scope, NodeProvider /*!*/ nodeProvider) : base(nodeProvider, scope) { _encoding = RubyEncoding.GetRubyEncoding(nodeProvider.Encoding); _newSite = CallSite <Func <CallSite, RubyModule, object, object, object, object> > .Create( RubyCallAction.Make(scope.Context, "new", RubyCallSignature.WithImplicitSelf(3)) ); _yamlInitializeSite = CallSite <Func <CallSite, object, object, Hash, object> > .Create( RubyCallAction.Make(scope.Context, "yaml_initialize", RubyCallSignature.WithImplicitSelf(3)) ); }
private static object ConstructPrivateObject(RubyConstructor /*!*/ ctor, string className, Node node) { MappingNode mapping = node as MappingNode; if (mapping == null) { throw new ConstructorException("can only construct private type from mapping node"); } RubyModule module; RubyGlobalScope globalScope = ctor.GlobalScope; if (globalScope.Context.TryGetModule(globalScope, className, out module)) { if (!module.IsClass) { throw new ConstructorException("Cannot construct module"); } Hash values = ctor.ConstructMapping(mapping); // TODO: call allocate here: object result = null; RubyMethodInfo method = module.GetMethod("yaml_initialize") as RubyMethodInfo; if (method != null) { result = RubyMarshal.Utils.CreateObjectAndSetIvars((RubyClass)module); ctor._yamlInitializeSite.Target(ctor._yamlInitializeSite, result, className, values); } else { var dict = new Dictionary <string, object>(values.Count); foreach (var kvp in EnumerateAttributes(globalScope.Context, values)) { dict.Add(kvp.Key, kvp.Value); } result = RubyMarshal.Utils.CreateObjectAndSetIvars((RubyClass)module, dict); } return(result); } else { //TODO: YAML::Object throw new NotImplementedError("YAML::Object is not implemented yet"); } }
internal RubyTopLevelScope(RubyGlobalScope/*!*/ globalScope, RubyModule scopeModule, RubyModule methodLookupModule, RubyObject/*!*/ selfObject) { Assert.NotNull(globalScope, selfObject); // RubyScope: _top = this; _selfObject = selfObject; _methodAttributes = RubyMethodAttributes.PrivateInstance; // RubyTopLevelScope: _globalScope = globalScope; _context = globalScope.Context; _wrappingModule = scopeModule; _methodLookupModule = methodLookupModule; }
public BaseConstructor(NodeProvider /*!*/ nodeProvider, RubyGlobalScope /*!*/ globalScope) { Assert.NotNull(nodeProvider, globalScope); _nodeProvider = nodeProvider; _globalScope = globalScope; }
internal RubyTopLevelScope(RubyGlobalScope/*!*/ globalScope, RubyModule definitionsModule, IAttributesCollection/*!*/ frame) : base(frame) { Assert.NotNull(globalScope); _globalScope = globalScope; _context = globalScope.Context; _definitionsModule = definitionsModule; }
internal RubyTopLevelScope(RubyGlobalScope/*!*/ globalScope, RubyModule definitionsModule, RuntimeFlowControl/*!*/ runtimeFlowControl, object selfObject) : base(runtimeFlowControl, selfObject) { Assert.NotNull(globalScope); _globalScope = globalScope; _context = globalScope.Context; _definitionsModule = definitionsModule; }
internal RubyTopLevelScope(RubyGlobalScope/*!*/ globalScope, RubyModule scopeModule, RubyModule methodLookupModule, RuntimeFlowControl/*!*/ runtimeFlowControl, object selfObject) : base(runtimeFlowControl, selfObject) { Assert.NotNull(globalScope); _globalScope = globalScope; _context = globalScope.Context; _wrappingModule = scopeModule; _methodLookupModule = methodLookupModule; }
private static RubyConstructor /*!*/ MakeConstructor(RubyGlobalScope /*!*/ scope, Stream /*!*/ stream) { return(new RubyConstructor(scope, MakeComposer(scope.Context, stream))); }