public static RubyTopLevelScope/*!*/ CreateMainTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language, out object self, out RuntimeFlowControl/*!*/ rfc, string dataPath, int dataOffset) { Assert.NotNull(locals, globalScope, language); RubyContext context = (RubyContext)language; RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, false); RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, locals); scope.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject); scope.SetDebugName("top-main"); var objectClass = context.ObjectClass; objectClass.SetConstant("TOPLEVEL_BINDING", new Binding(scope)); if (dataOffset >= 0) { RubyFile dataFile; if (context.DomainManager.Platform.FileExists(dataPath)) { dataFile = new RubyFile(context, dataPath, RubyFileMode.RDONLY); dataFile.Seek(dataOffset, SeekOrigin.Begin); } else { dataFile = null; } objectClass.SetConstant("DATA", dataFile); } self = scope.SelfObject; rfc = scope.RuntimeFlowControl; return scope; }
public static RubyTopLevelScope/*!*/ CreateMainTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language, out object self, out RuntimeFlowControl/*!*/ rfc, string dataPath, int dataOffset) { Assert.NotNull(locals, globalScope, language); GlobalScopeExtension rubyGlobalScope = (GlobalScopeExtension)language.EnsureScopeExtension(globalScope); RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, locals); scope.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject); scope.SetDebugName(rubyGlobalScope.IsHosted ? "top-primary-hosted" : "top-primary"); // define TOPLEVEL_BINDING constant: if (!rubyGlobalScope.IsHosted) { var objectClass = rubyGlobalScope.Context.ObjectClass; objectClass.SetConstant("TOPLEVEL_BINDING", new Binding(scope)); if (dataOffset >= 0) { RubyFile dataFile; if (File.Exists(dataPath)) { dataFile = new RubyFile(rubyGlobalScope.Context, dataPath, RubyFileMode.RDONLY); dataFile.Seek(dataOffset, SeekOrigin.Begin); } else { dataFile = null; } objectClass.SetConstant("DATA", dataFile); } } self = scope.SelfObject; rfc = scope.RuntimeFlowControl; return scope; }
internal static RubyTopLevelScope/*!*/ CreateWrappedTopLevelScope(Scope/*!*/ globalScope, RubyContext/*!*/ context) { RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, false, false); RubyModule module = context.CreateModule(null, null, null, null, null, null, null, ModuleRestrictions.None); RubyObject mainObject = new RubyObject(context.ObjectClass); context.CreateMainSingleton(mainObject, new[] { module }); RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, module, null, mainObject); scope.SetDebugName("top-level-wrapped"); return scope; }
internal static RubyTopLevelScope/*!*/ CreateHostedTopLevelScope(Scope/*!*/ globalScope, RubyContext/*!*/ context, bool bindGlobals) { RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, true, bindGlobals); // Reuse existing top-level scope if available: RubyTopLevelScope scope = rubyGlobalScope.TopLocalScope; if (scope == null) { scope = new RubyTopLevelScope( rubyGlobalScope, null, bindGlobals ? rubyGlobalScope.MainSingleton : null, rubyGlobalScope.MainObject ); scope.SetDebugName(bindGlobals ? "top-level-bound" : "top-level"); rubyGlobalScope.SetTopLocalScope(scope); } else { // If we reuse a local scope from previous execution all local variables are accessed dynamically. // Therefore we shouldn't have any new static local variables. } return scope; }
internal static RubyTopLevelScope/*!*/ CreateTopLevelScope(Scope/*!*/ globalScope, RubyContext/*!*/ context, bool isMain) { RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, false, false); RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, null, rubyGlobalScope.MainObject); if (isMain) { scope.SetDebugName("top-main"); context.ObjectClass.SetConstant("TOPLEVEL_BINDING", new Binding(scope)); if (context.RubyOptions.RequirePaths != null) { foreach (var path in context.RubyOptions.RequirePaths) { context.Loader.LoadFile(globalScope, rubyGlobalScope.MainObject, MutableString.Create(path, RubyEncoding.UTF8), LoadFlags.Require); } } } else { scope.SetDebugName("top-required"); } return scope; }
internal static RubyTopLevelScope/*!*/ CreateWrappedTopLevelScope(Scope/*!*/ globalScope, RubyContext/*!*/ context) { RubyModule module = context.CreateModule(null, null, null, null, null, null, null); object mainObject = new Object(); RubyClass mainSingleton = context.CreateMainSingleton(mainObject, new[] { module }); RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, false); RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, module, new RuntimeFlowControl(), mainObject); scope.SetDebugName("top-level-wrapped"); return scope; }
internal static RubyTopLevelScope/*!*/ CreateTopLevelScope(Scope/*!*/ globalScope, RubyContext/*!*/ context) { RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, false); RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, new RuntimeFlowControl(), rubyGlobalScope.MainObject); scope.SetDebugName("top-level"); return scope; }
internal static RubyTopLevelScope/*!*/ CreateTopLevelHostedScope(Scope/*!*/ globalScope, RubyContext/*!*/ context) { RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, true); // Reuse existing top-level scope if available: RubyTopLevelScope scope = rubyGlobalScope.TopLocalScope; if (scope == null) { scope = new RubyTopLevelScope(rubyGlobalScope, null, new RuntimeFlowControl(), rubyGlobalScope.MainObject); scope.SetDebugName("top-level-hosted"); rubyGlobalScope.TopLocalScope = scope; } else { // If we reuse a local scope from previous execution all local variables are accessed dynamically. // Therefore we shouldn't have any new static local variables. } return scope; }
internal static RubyTopLevelScope/*!*/ CreateMainTopLevelScope(Scope/*!*/ globalScope, RubyContext/*!*/ context) { RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, false); RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, new RuntimeFlowControl(), rubyGlobalScope.MainObject); scope.SetDebugName("top-main"); context.ObjectClass.SetConstant("TOPLEVEL_BINDING", new Binding(scope)); return scope; }
public static RubyTopLevelScope/*!*/ CreateTopLevelHostedScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language, out object self, out RuntimeFlowControl/*!*/ rfc) { RubyContext context = (RubyContext)language; RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, true); // reuse existing top-level scope if available: RubyTopLevelScope scope = rubyGlobalScope.TopLocalScope; if (scope == null) { scope = new RubyTopLevelScope(rubyGlobalScope, null, locals); scope.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject); scope.SetDebugName("top-level-hosted"); rubyGlobalScope.TopLocalScope = scope; } self = scope.SelfObject; rfc = scope.RuntimeFlowControl; return scope; }
public static RubyTopLevelScope/*!*/ CreateWrappedTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language, out object self, out RuntimeFlowControl/*!*/ rfc) { RubyContext context = (RubyContext)language; RubyModule module = context.CreateModule(null, null, null, null, null, null, null); object mainObject = new Object(); RubyClass mainSingleton = context.CreateMainSingleton(mainObject, new[] { module }); RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, false); RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, locals); scope.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject); scope.SetDebugName("top-level-wrapped"); scope.SelfObject = mainObject; scope.SetModule(module); self = scope.SelfObject; rfc = scope.RuntimeFlowControl; return scope; }
public static RubyTopLevelScope/*!*/ CreateTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language, out object self, out RuntimeFlowControl/*!*/ rfc) { RubyContext context = (RubyContext)language; RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, false); RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, locals); scope.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject); scope.SetDebugName("top-level"); self = scope.SelfObject; rfc = scope.RuntimeFlowControl; return scope; }
private static RubyTopLevelScope/*!*/ CreateTopLevelScopeInternal(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language) { GlobalScopeExtension rubyGlobalScope = (GlobalScopeExtension)language.EnsureScopeExtension(globalScope); RubyTopLevelScope result = new RubyTopLevelScope(rubyGlobalScope, null, locals); result.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject); result.SetDebugName("top-level"); return result; }
internal static RubyTopLevelScope/*!*/ CreateTopLevelScope(Scope/*!*/ globalScope, RubyContext/*!*/ context, bool isMain) { RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, false, false); RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, null, rubyGlobalScope.MainObject); if (isMain) { scope.SetDebugName("top-main"); context.ObjectClass.SetConstant("TOPLEVEL_BINDING", new Binding(scope)); } else { scope.SetDebugName("top-required"); } return scope; }