edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Driver.cs;C667392 File: Driver.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Driver.cs;C667392 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Driver.cs;InitAndScopes6 @@ -93,6 +93,7 @@ private static bool _displayList; private static bool _partialTrust; private static bool _interpret; + private static bool _runPython; public TestRuntime TestRuntime { get { return _testRuntime; } @@ -114,16 +115,21 @@ get { return _interpret; } } + public bool RunPython { + get { return _runPython; } + } + private static bool ParseArguments(List/*!*/ args) { if (args.Contains("/help") || args.Contains("-?") || args.Contains("/?") || args.Contains("-help")) { - Console.WriteLine("Run All Tests : [-X:Interpret]"); - Console.WriteLine("Partial trust : /partial"); - Console.WriteLine("Interpret : /interpret"); - Console.WriteLine("Run Specific Tests : [/debug] [/exclude] [test_to_run ...]"); - Console.WriteLine("List Tests : /list"); - Console.WriteLine("Tokenizer baseline : /tokenizer "); - Console.WriteLine("Productions dump : /tokenizer /prod "); - Console.WriteLine("Benchmark : /tokenizer /bm "); + Console.WriteLine("Run All Tests : [-X:Interpret]"); + Console.WriteLine("Partial trust : /partial"); + Console.WriteLine("Interpret : /interpret"); + Console.WriteLine("Run Python interop tests : /py"); + Console.WriteLine("Run Specific Tests : [/debug] [/exclude] [test_to_run ...]"); + Console.WriteLine("List Tests : /list"); + Console.WriteLine("Tokenizer baseline : /tokenizer "); + Console.WriteLine("Productions dump : /tokenizer /prod "); + Console.WriteLine("Benchmark : /tokenizer /bm "); } if (args.Contains("/list")) { @@ -146,6 +152,11 @@ _interpret = true; } + if (args.Contains("/py")) { + args.Remove("/py"); + _runPython = true; + } + if (args.Contains("/exclude")) { _excludeSelectedCases = true; args.Remove("/exclude"); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;C674241 File: RubyTests.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;C674241 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/RubyTests.cs;InitAndScopes6 @@ -283,7 +283,9 @@ Scenario_UninitializedVars2, InstanceVariables1, InstanceVariables2, - RubyHosting1, + RubyHosting1A, + RubyHosting1B, + RubyHosting1C, RubyHosting2, RubyHosting3, RubyHosting4, @@ -296,8 +298,8 @@ Scenario_RubyConsole4, ObjectOperations1, ObjectOperations2, - // TODO (python needs to run this suite): PythonInterop1, - // TODO (python needs to run this suite): PythonInterop2, + PythonInterop1, + PythonInterop2, CustomTypeDescriptor1, CustomTypeDescriptor2, @@ -376,6 +378,12 @@ MethodLookup1, VisibilityCaching1, ModuleFunctionVisibility1, + MethodDefinitionInDefineMethod1A, + MethodDefinitionInDefineMethod1B, + MethodDefinitionInDefineMethod2A, + MethodDefinitionInDefineMethod2B, + MethodDefinitionInModuleEval1A, + MethodDefinitionInModuleEval1B, Scenario_Singletons1, Scenario_Singletons2, =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/HostingTests.cs;C669880 File: HostingTests.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/HostingTests.cs;C669880 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/HostingTests.cs;InitAndScopes6 @@ -25,12 +25,13 @@ namespace IronRuby.Tests { public partial class Tests { - public void RubyHosting1() { + public void RubyHosting1A() { ScriptScope scope = Engine.Runtime.CreateScope(); scope.SetVariable("x", 1); scope.SetVariable("y", 2); - // TODO: could we replace def self.z with z = ? - via dynamic binding + // reads x, y from scope via method_missing; + // copies z, w main-singleton methods to the scope: Engine.Execute("def self.z; x + y; end", scope); Engine.Execute("def self.w(a); a + 1; end", scope); @@ -41,6 +42,45 @@ Assert(w == 2); } + public void RubyHosting1B() { + ScriptScope scope = Engine.Runtime.CreateScope(); + scope.SetVariable("x", 1); + scope.SetVariable("y", 2); + + // "tmp" is defined in the top-level bidning, which is associated with the scope: + Engine.Execute("tmp = x + y", scope); + + // "tmp" symbol is extracted from scope's top-level binding and passed to the compiler as a compiler options + // so that the parser treats the "tmp" symbols as a local variable. + string tmpDefined = Engine.Execute("defined?(tmp)", scope).ToString(); + Assert(tmpDefined == "local-variable"); + + // result= is turned into a scope variable assignment in method_missing: + Engine.Execute("self.result = tmp", scope); + + int result = scope.GetVariable("result"); + Assert(result == 3); + + // Ruby local variables are not exposed: + Assert(scope.ContainsVariable("tmp") == false); + } + + public void RubyHosting1C() { + // Main singleton in a scope-unbound code doesn't define method_missing: + AssertExceptionThrown( + () => Engine.Execute("class << self; remove_method(:method_missing); end") + ); + + // Main singleton in a scope-bound code defines method_missing: + Engine.Execute("class << self; remove_method(:method_missing); end", Engine.CreateScope()); + + var scope = Engine.CreateScope(); + Engine.Execute("self.tmp = 1", scope); + Assert(scope.ContainsVariable("tmp")); + + AssertExceptionThrown(() => Engine.Execute("self.tmp = 1")); + } + public void RubyHosting2() { Hashtable hash = new Hashtable(); hash.Add("foo", "bar"); @@ -232,6 +272,8 @@ } public void PythonInterop1() { + if (!_driver.RunPython) return; + var py = Runtime.GetEngine("python"); Engine.Execute(@" class C @@ -248,6 +290,8 @@ } public void PythonInterop2() { + if (!_driver.RunPython) return; + var py = Runtime.GetEngine("python"); py.CreateScriptSourceFromString(@" =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/MethodTests.cs;C667392 File: MethodTests.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/MethodTests.cs;C667392 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/MethodTests.cs;InitAndScopes6 @@ -270,5 +270,78 @@ [] "); } + + private string MethodDefinitionInDefineMethodCode1 = @" +class A + $p = lambda { def foo; end } +end + +class B + define_method :f, &$p +end + +B.new.f + +puts A.send(:remove_method, :foo) rescue puts B.send(:remove_method, :foo) +"; + + [Options(Compatibility = RubyCompatibility.Ruby19)] + public void MethodDefinitionInDefineMethod1A() { + AssertOutput(() => CompilerTest(MethodDefinitionInDefineMethodCode1), "A"); + } + + [Options(Compatibility = RubyCompatibility.Ruby18)] + public void MethodDefinitionInDefineMethod1B() { + AssertOutput(() => CompilerTest(MethodDefinitionInDefineMethodCode1), "B"); + } + + private string MethodDefinitionInDefineMethodCode2 = @" +class B + define_method :m do + def foo; end + end +end + +class A < B +end + +A.new.m + +puts A.send(:remove_method, :foo) rescue puts B.send(:remove_method, :foo) +"; + [Options(Compatibility = RubyCompatibility.Ruby19)] + public void MethodDefinitionInDefineMethod2A() { + AssertOutput(() => CompilerTest(MethodDefinitionInDefineMethodCode2), "B"); + } + + /// + /// MRI 1.8 actually prints A. We consider it a bug that we won't copy. + /// + [Options(Compatibility = RubyCompatibility.Ruby18)] + public void MethodDefinitionInDefineMethod2B() { + AssertOutput(() => CompilerTest(MethodDefinitionInDefineMethodCode2), "B"); + } + + private string MethodDefinitionInModuleEvalCode = @" +class A + $p = lambda { def foo; end } +end + +class B + module_eval(&$p) +end + +puts A.send(:remove_method, :foo) rescue puts B.send(:remove_method, :foo) +"; + + [Options(Compatibility = RubyCompatibility.Ruby19)] + public void MethodDefinitionInModuleEval1A() { + AssertOutput(() => CompilerTest(MethodDefinitionInModuleEvalCode), "A"); + } + + [Options(Compatibility = RubyCompatibility.Ruby18)] + public void MethodDefinitionInModuleEval1B() { + AssertOutput(() => CompilerTest(MethodDefinitionInModuleEvalCode), "B"); + } } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/OverloadResolutionTests.cs;C669565 File: OverloadResolutionTests.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/OverloadResolutionTests.cs;C669565 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/OverloadResolutionTests.cs;InitAndScopes6 @@ -33,7 +33,7 @@ public void OverloadResolution_Block() { var t = GetType(); - var gse = new GlobalScopeExtension(Context, new Scope(), new object(), true); + var gse = new RubyGlobalScope(Context, new Scope(), new object(), true); var scope = new RubyTopLevelScope(gse, null, new SymbolDictionary()); var proc = new Proc(ProcKind.Proc, null, scope, new BlockDispatcher0((x, y) => null, BlockSignatureAttributes.None)); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs;C691193 File: Initializers.Generated.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs;C691193 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs;InitAndScopes6 @@ -131,7 +131,7 @@ new System.Func(IronRuby.Builtins.RegexpOps.Create), new System.Func(IronRuby.Builtins.RegexpOps.Create), new System.Func(IronRuby.Builtins.RegexpOps.Create), - new System.Func(IronRuby.Builtins.RegexpOps.Create), + new System.Func(IronRuby.Builtins.RegexpOps.Create), }); DefineGlobalClass("String", typeof(IronRuby.Builtins.MutableString), false, Context.ObjectClass, new System.Action(LoadString_Instance), null, new IronRuby.Builtins.RubyModule[] {def21, def30, }, new System.Delegate[] { new System.Func(IronRuby.Builtins.MutableStringOps.Create), @@ -2066,6 +2066,11 @@ new System.Func(IronRuby.Builtins.RubyIOOps.Gets), }); + module.DefineLibraryMethod("initialize", 0x52, new System.Delegate[] { + new System.Action(IronRuby.Builtins.RubyIOOps.CreateIO), + new System.Action(IronRuby.Builtins.RubyIOOps.CreateIO), + }); + module.DefineLibraryMethod("internal_encoding", 0x51, new System.Delegate[] { new System.Func(IronRuby.Builtins.RubyIOOps.GetInternalEncoding), }); @@ -2189,12 +2194,7 @@ new System.Action(IronRuby.Builtins.RubyIOOps.ForEach), }); - module.DefineLibraryMethod("open", 0x61, new System.Delegate[] { - new System.Func(IronRuby.Builtins.RubyIOOps.Open), - new System.Func(IronRuby.Builtins.RubyIOOps.Open), - new System.Func(IronRuby.Builtins.RubyIOOps.Open), - new System.Func(IronRuby.Builtins.RubyIOOps.Open), - }); + module.DefineRuleGenerator("open", 0x61, IronRuby.Builtins.RubyIOOps.Open()); #if !SILVERLIGHT module.DefineLibraryMethod("popen", 0x61, new System.Delegate[] { @@ -2445,7 +2445,7 @@ }); module.DefineLibraryMethod("load_assembly", 0x52, new System.Delegate[] { - new System.Func(IronRuby.Builtins.KernelOps.LoadAssembly), + new System.Func(IronRuby.Builtins.KernelOps.LoadAssembly), }); module.DefineLibraryMethod("local_variables", 0x52, new System.Delegate[] { @@ -2632,7 +2632,7 @@ }); module.DefineLibraryMethod("to_a", 0x51, new System.Delegate[] { - new System.Func(IronRuby.Builtins.KernelOps.ToA), + new System.Func(IronRuby.Builtins.KernelOps.ToA), }); module.DefineLibraryMethod("to_s", 0x51, new System.Delegate[] { @@ -2755,7 +2755,7 @@ }); module.DefineLibraryMethod("load_assembly", 0x61, new System.Delegate[] { - new System.Func(IronRuby.Builtins.KernelOps.LoadAssembly), + new System.Func(IronRuby.Builtins.KernelOps.LoadAssembly), }); module.DefineLibraryMethod("local_variables", 0x61, new System.Delegate[] { @@ -4176,9 +4176,9 @@ }); module.DefineLibraryMethod("gsub", 0x51, new System.Delegate[] { - new System.Func(IronRuby.Builtins.MutableStringOps.ReplaceAll), new System.Func, IronRuby.Runtime.RubyScope, IronRuby.Runtime.BlockParam, IronRuby.Builtins.MutableString, IronRuby.Builtins.RubyRegex, System.Object>(IronRuby.Builtins.MutableStringOps.BlockReplaceAll), new System.Func, IronRuby.Runtime.RubyScope, IronRuby.Runtime.BlockParam, IronRuby.Builtins.MutableString, IronRuby.Builtins.MutableString, System.Object>(IronRuby.Builtins.MutableStringOps.BlockReplaceAll), + new System.Func(IronRuby.Builtins.MutableStringOps.ReplaceAll), }); module.DefineLibraryMethod("gsub!", 0x51, new System.Delegate[] { =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/IoOps.cs;C674241 File: IoOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/IoOps.cs;C674241 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/IoOps.cs;InitAndScopes6 @@ -25,6 +25,8 @@ using IronRuby.Runtime.Calls; using System.Diagnostics; using Microsoft.Scripting.Generation; +using IronRuby.Compiler.Generation; +using Ast = System.Linq.Expressions.Expression; namespace IronRuby.Builtins { @@ -69,6 +71,21 @@ return result; } + [RubyMethod("initialize", RubyMethodAttributes.PrivateInstance)] + public static void CreateIO(RubyIO/*!*/ self) { + // TODO: + } + + [RubyMethod("initialize", RubyMethodAttributes.PrivateInstance)] + public static void CreateIO(RubyIO/*!*/ self, + [DefaultProtocol]int fileDescriptor, [DefaultProtocol, NotNull, Optional]MutableString modeString) { + + // TODO: + if (modeString != null) { + self.ResetIOMode(modeString.ConvertToString()); + } + } + //initialize_copy #endregion @@ -137,27 +154,44 @@ } [RubyMethod("open", RubyMethodAttributes.PublicSingleton)] - public static object Open(RubyContext/*!*/ context, BlockParam/*!*/ block, RubyClass/*!*/ self, int fileDescriptor) { - RubyIO io = _CreateIOSharedSite1.Target(_CreateIOSharedSite1, context, self, fileDescriptor); - return TryInvokeOpenBlock(context, block, io); - } + public static RuleGenerator/*!*/ Open() { + return new RuleGenerator((metaBuilder, args, name) => { + var targetClass = (RubyClass)args.Target; + targetClass.BuildObjectConstructionNoFlow(metaBuilder, args, name); - [RubyMethod("open", RubyMethodAttributes.PublicSingleton)] - public static object Open(RubyContext/*!*/ context, BlockParam/*!*/ block, RubyClass/*!*/ self, int fileDescriptor, [NotNull]MutableString/*!*/ mode) { - RubyIO io = _CreateIOSharedSite11.Target(_CreateIOSharedSite11, context, self, fileDescriptor, mode); - return TryInvokeOpenBlock(context, block, io); - } + // TODO: initialize yields the block? + // TODO: null block check + if (args.Signature.HasBlock) { + // ignore flow builder set up so far, we need one that creates a BlockParam for library calls: + metaBuilder.ControlFlowBuilder = null; - [RubyMethod("open", RubyMethodAttributes.PublicSingleton)] - public static object Open(RubyContext/*!*/ context, BlockParam/*!*/ block, RubyClass/*!*/ self, int fileDescriptor, object mode) { - RubyIO io = _CreateIOSharedSite11.Target(_CreateIOSharedSite11, context, self, fileDescriptor, Protocols.CastToString(context, mode)); - return TryInvokeOpenBlock(context, block, io); + if (metaBuilder.BfcVariable == null) { + metaBuilder.BfcVariable = metaBuilder.GetTemporary(typeof(BlockParam), "#bfc"); + } + + metaBuilder.Result = Ast.Call(typeof(RubyIOOps).GetMethod("InvokeOpenBlock"), + args.ContextExpression, + metaBuilder.BfcVariable, + metaBuilder.Result + ); + + RubyMethodGroupInfo.RuleControlFlowBuilder(metaBuilder, args); + } else { + metaBuilder.BuildControlFlow(args); + } + }); } - [RubyMethod("open", RubyMethodAttributes.PublicSingleton)] - public static object Open(RubyContext/*!*/ context, BlockParam/*!*/ block, RubyClass/*!*/ self, MutableString/*!*/ host, int port) { - RubyIO io = _CreateIOSharedSite6.Target(_CreateIOSharedSite6, context, self, host, port); - return TryInvokeOpenBlock(context, block, io); + [Emitted] + public static object InvokeOpenBlock(RubyContext/*!*/ context, BlockParam/*!*/ block, object obj) { + RubyIO io; + if (!RubyOps.IsRetrySingleton(obj) && block != null && (io = obj as RubyIO) != null) { + block.Yield(io, out obj); + if (!block.BlockJumped(obj)) { + io.Close(); + } + } + return obj; } private static RubyIO OpenFileForRead(RubyContext/*!*/ context, MutableString/*!*/ path) { =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/KernelOps.cs;C691193 File: KernelOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/KernelOps.cs;C691193 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/KernelOps.cs;InitAndScopes6 @@ -371,23 +371,23 @@ [RubyMethod("load", RubyMethodAttributes.PublicSingleton)] public static bool Load(RubyScope/*!*/ scope, object self, [DefaultProtocol, NotNull]MutableString/*!*/ libraryName, [Optional]bool wrap) { - return scope.RubyContext.Loader.LoadFile(scope.GlobalScope, self, libraryName, wrap ? LoadFlags.LoadIsolated : LoadFlags.None); + return scope.RubyContext.Loader.LoadFile(scope.GlobalScope.Scope, self, libraryName, wrap ? LoadFlags.LoadIsolated : LoadFlags.None); } [RubyMethod("load_assembly", RubyMethodAttributes.PrivateInstance)] [RubyMethod("load_assembly", RubyMethodAttributes.PublicSingleton)] - public static bool LoadAssembly(RubyScope/*!*/ scope, object self, + public static bool LoadAssembly(RubyContext/*!*/ context, object self, [DefaultProtocol, NotNull]MutableString/*!*/ assemblyName, [DefaultProtocol, Optional, NotNull]MutableString libraryNamespace) { string initializer = libraryNamespace != null ? LibraryInitializer.GetFullTypeName(libraryNamespace.ConvertToString()) : null; - return scope.RubyContext.Loader.LoadAssembly(assemblyName.ConvertToString(), initializer, true); + return context.Loader.LoadAssembly(assemblyName.ConvertToString(), initializer, true); } [RubyMethod("require", RubyMethodAttributes.PrivateInstance)] [RubyMethod("require", RubyMethodAttributes.PublicSingleton)] public static bool Require(RubyScope/*!*/ scope, object self, [DefaultProtocol, NotNull]MutableString/*!*/ libraryName) { - return scope.RubyContext.Loader.LoadFile(scope.GlobalScope, self, libraryName, LoadFlags.LoadOnce | LoadFlags.AppendExtensions); + return scope.RubyContext.Loader.LoadFile(scope.GlobalScope.Scope, self, libraryName, LoadFlags.LoadOnce | LoadFlags.AppendExtensions); } #endregion @@ -1408,11 +1408,11 @@ } [RubyMethod("to_a")] - public static RubyArray/*!*/ ToA(RubyScope/*!*/ scope, object self) { + public static RubyArray/*!*/ ToA(RubyContext/*!*/ context, object self) { // Return an array that contains self RubyArray result = new RubyArray(new object[] { self }); - return scope.RubyContext.TaintObjectBy(result, self); + return context.TaintObjectBy(result, self); } [RubyMethod("to_s")] =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Marshal.cs;C674241 File: Marshal.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Marshal.cs;C674241 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/Marshal.cs;InitAndScopes6 @@ -485,16 +485,19 @@ internal class MarshalReader { private readonly BinaryReader/*!*/ _reader; private readonly SiteLocalStorage/*!*/ _sites; - private readonly RubyContext/*!*/ _context; - private readonly Scope/*!*/ _globalScope; + private readonly RubyGlobalScope/*!*/ _globalScope; private readonly Proc _proc; private readonly Dictionary/*!*/ _symbols; private readonly Dictionary/*!*/ _objects; - internal MarshalReader(SiteLocalStorage/*!*/ sites, BinaryReader/*!*/ reader, RubyContext/*!*/ context, Scope/*!*/ globalScope, Proc proc) { + private RubyContext/*!*/ Context { + get { return _globalScope.Context; } + } + + internal MarshalReader(SiteLocalStorage/*!*/ sites, BinaryReader/*!*/ reader, + RubyGlobalScope/*!*/ globalScope, Proc proc) { _sites = sites; _reader = reader; - _context = context; _globalScope = globalScope; _proc = proc; _symbols = new Dictionary(); @@ -514,7 +517,7 @@ string message = String.Format( "incompatible marshal file format (can be read)\n\tformat version {0}.{1} required; {2}.{3} given", MAJOR_VERSION, MINOR_VERSION, major, minor); - _context.ReportWarning(message); + Context.ReportWarning(message); } } @@ -589,7 +592,7 @@ if (pos >= 0) { value.Remove(pos, value.Length - pos); } - return Protocols.ConvertToFloat(_context, value); + return Protocols.ConvertToFloat(Context, value); } private MutableString/*!*/ ReadString() { @@ -615,7 +618,7 @@ private Hash/*!*/ ReadHash(int typeFlag) { int count = ReadInt32(); - Hash result = new Hash(_context); + Hash result = new Hash(Context); for (int i = 0; i < count; i++) { object key = ReadAnObject(false); result[key] = ReadAnObject(false); @@ -659,7 +662,7 @@ private object/*!*/ ReadObject() { RubyClass theClass = ReadType(); int count = ReadInt32(); - Hash attributes = new Hash(_context); + Hash attributes = new Hash(Context); for (int i = 0; i < count; i++) { string name = ReadSymbol(); attributes[name] = ReadAnObject(false); @@ -669,12 +672,12 @@ private object/*!*/ ReadUsingLoad() { RubyClass theClass = ReadType(); - return _sites.Data.Load.Target(_sites.Data.Load, _context, theClass, ReadString()); + return _sites.Data.Load.Target(_sites.Data.Load, Context, theClass, ReadString()); } private object/*!*/ ReadUsingMarshalLoad() { object obj = UnmarshalNewObject(); - _sites.Data.MarshalLoad.Target(_sites.Data.MarshalLoad, _context, obj, ReadAnObject(false)); + _sites.Data.MarshalLoad.Target(_sites.Data.MarshalLoad, Context, obj, ReadAnObject(false)); return obj; } @@ -685,11 +688,11 @@ private object/*!*/ ReadClassOrModule(int typeFlag, string/*!*/ name) { RubyModule result; - if (!_context.TryGetModule(_globalScope, name, out result)) { + if (!Context.TryGetModule(_globalScope, name, out result)) { throw RubyExceptions.CreateArgumentError(String.Format("undefined class/module {0}", name)); } - bool isClass = (result is RubyClass); + bool isClass = result is RubyClass; if (isClass && typeFlag == 'm') { throw RubyExceptions.CreateArgumentError( String.Format("{0} does not refer module", name)); @@ -716,7 +719,7 @@ for (int i = 0; i < count; i++) { string name = ReadSymbol(); if (name != names[i]) { - RubyClass theClass = _context.GetClassOf(obj); + RubyClass theClass = Context.GetClassOf(obj); string message = String.Format("struct {0} not compatible ({1} for {2})", theClass.Name, name, names[i]); throw RubyExceptions.CreateTypeError(message); } @@ -731,7 +734,7 @@ int count = ReadInt32(); for (int i = 0; i < count; i++) { string name = ReadSymbol(); - _context.SetInstanceVariable(obj, name, ReadAnObject(false)); + Context.SetInstanceVariable(obj, name, ReadAnObject(false)); } return obj; } @@ -893,7 +896,7 @@ break; } if (runProc) { - _sites.Data.ProcCall.Target(_sites.Data.ProcCall, _context, _proc, obj); + _sites.Data.ProcCall.Target(_sites.Data.ProcCall, Context, _proc, obj); } return obj; } @@ -959,7 +962,7 @@ [RubyMethod("restore", RubyMethodAttributes.PublicSingleton)] public static object Load(SiteLocalStorage/*!*/ sites, RubyScope/*!*/ scope, RubyModule/*!*/ self, [NotNull]MutableString/*!*/ source, [Optional]Proc proc) { BinaryReader reader = new BinaryReader(new MemoryStream(source.ConvertToBytes())); - MarshalReader loader = new MarshalReader(sites, reader, scope.RubyContext, scope.GlobalScope, proc); + MarshalReader loader = new MarshalReader(sites, reader, scope.GlobalScope, proc); return loader.Load(); } @@ -967,7 +970,7 @@ [RubyMethod("restore", RubyMethodAttributes.PublicSingleton)] public static object Load(SiteLocalStorage/*!*/ sites, RubyScope/*!*/ scope, RubyModule/*!*/ self, [NotNull]RubyIO/*!*/ source, [Optional]Proc proc) { BinaryReader reader = source.GetBinaryReader(); - MarshalReader loader = new MarshalReader(sites, reader, scope.RubyContext, scope.GlobalScope, proc); + MarshalReader loader = new MarshalReader(sites, reader, scope.GlobalScope, proc); return loader.Load(); } @@ -984,7 +987,7 @@ throw RubyExceptions.CreateTypeError("instance of IO needed"); } BinaryReader reader = new BinaryReader(stream); - MarshalReader loader = new MarshalReader(sites, reader, scope.RubyContext, scope.GlobalScope, proc); + MarshalReader loader = new MarshalReader(sites, reader, scope.GlobalScope, proc); return loader.Load(); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;C674241 File: ModuleOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;C674241 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs;InitAndScopes6 @@ -573,7 +573,7 @@ [RubyMethod("const_get")] public static object GetConstantValue(RubyScope/*!*/ scope, RubyModule/*!*/ self, [DefaultProtocol]string/*!*/ constantName) { - return RubyUtils.GetConstant(scope, self, constantName, true); + return RubyUtils.GetConstant(scope.GlobalScope, self, constantName, true); } [RubyMethod("const_set")] =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/RubyRegexOps.cs;C674241 File: RubyRegexOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/RubyRegexOps.cs;C674241 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/RubyRegexOps.cs;InitAndScopes6 @@ -56,7 +56,7 @@ } [RubyConstructor] - public static RubyRegex/*!*/ Create(RubyScope/*!*/ scope, RubyClass/*!*/ self, + public static RubyRegex/*!*/ Create(RubyClass/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ pattern, [DefaultParameterValue(null)]object ignoreCase, [DefaultProtocol, Optional]MutableString encoding) { return new RubyRegex(pattern, MakeOptions(ignoreCase, encoding)); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.cs;C633889 File: Ruby.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.cs;C633889 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.cs;InitAndScopes6 @@ -23,6 +23,7 @@ using System; using System.Collections; using System.Collections.Generic; +using Microsoft.Scripting; #if SILVERLIGHT [assembly: DynamicLanguageProvider(typeof(RubyContext), RubyContext.IronRubyDisplayName, RubyContext.IronRubyNames, RubyContext.IronRubyFileExtensions)] @@ -101,12 +102,22 @@ ContractUtils.RequiresNotNull(engine, "engine"); ContractUtils.RequiresNotNull(path, "path"); - return HostingHelpers.CallEngine(engine, RequireFile, path); + return HostingHelpers.CallEngine, bool>(engine, RequireFile, + new KeyValuePair(path, null)); } - internal static bool RequireFile(LanguageContext/*!*/ context, string/*!*/ path) { + public static bool RequireFile(ScriptEngine/*!*/ engine, string/*!*/ path, ScriptScope/*!*/ scope) { + ContractUtils.RequiresNotNull(engine, "engine"); + ContractUtils.RequiresNotNull(path, "path"); + ContractUtils.RequiresNotNull(scope, "scope"); + + return HostingHelpers.CallEngine, bool>(engine, RequireFile, + new KeyValuePair(path, HostingHelpers.GetScope(scope))); + } + + internal static bool RequireFile(LanguageContext/*!*/ context, KeyValuePair pathAndScope) { var rc = (RubyContext)context; - return rc.Loader.LoadFile(rc.DefaultGlobalScope, null, MutableString.Create(path), + return rc.Loader.LoadFile(pathAndScope.Value, null, MutableString.Create(pathAndScope.Key), LoadFlags.LoadOnce | LoadFlags.AppendExtensions); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;C674241 File: Ruby.csproj =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;C674241 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;InitAndScopes6 @@ -3,7 +3,7 @@ Debug AnyCPU - 9.0.30729 + 9.0.30718 2.0 {7F6984B4-EE6D-4E6F-ABB1-E210D7DC4FDD} Library @@ -307,7 +307,7 @@ - + =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyClass.cs;C660056 File: RubyClass.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyClass.cs;C660056 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyClass.cs;InitAndScopes6 @@ -51,7 +51,7 @@ // null for singletons: private Type _underlyingSystemType; private readonly bool _isRubyClass; - private GlobalScopeExtension _globalScope; + private RubyGlobalScope _globalScope; // if this class is a struct represents its layout: private RubyStruct.Info _structInfo; @@ -87,11 +87,11 @@ set { _structInfo = value; } } - internal override GlobalScopeExtension GlobalScope { + internal override RubyGlobalScope GlobalScope { get { return _globalScope; } } - internal void SetGlobalScope(GlobalScopeExtension/*!*/ value) { + internal void SetGlobalScope(RubyGlobalScope/*!*/ value) { Assert.NotNull(value); _globalScope = value; } @@ -462,6 +462,11 @@ /// Implements Class#new feature. /// public void BuildObjectConstruction(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ methodName) { + BuildObjectConstructionNoFlow(metaBuilder, args, methodName); + metaBuilder.BuildControlFlow(args); + } + + public void BuildObjectConstructionNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ methodName) { Debug.Assert(!IsSingletonClass, "Cannot instantiate singletons"); Type type = GetUnderlyingSystemType(); @@ -504,7 +509,11 @@ } RubyMethodGroupInfo.BuildCallNoFlow(metaBuilder, args, methodName, constructionOverloads, includeSelf, false); - RubyMethodGroupInfo.ApplyBlockFlowHandlingInternal(metaBuilder, args); + + // we need to handle break, which unwinds to a proc-converter that could be this method's frame: + if (!metaBuilder.Error) { + metaBuilder.ControlFlowBuilder = RubyMethodGroupInfo.RuleControlFlowBuilder; + } } } @@ -520,7 +529,7 @@ args.SetTarget(instanceVariable, null); if (initializer is RubyMethodInfo) { - initializer.BuildCall(metaBuilder, args, Symbols.Initialize); + initializer.BuildCallNoFlow(metaBuilder, args, Symbols.Initialize); } else { // TODO: we need more refactoring of RubyMethodGroupInfo.BuildCall to be able to inline this: metaBuilder.Result = Ast.Dynamic( @@ -538,7 +547,9 @@ Ast.Assign(instanceVariable, instanceExpr), metaBuilder.Result ); - RubyMethodInfo.ApplyBlockFlowHandlingInternal(metaBuilder, args); + + // we need to handle break, which unwinds to a proc-converter that could be this method's frame: + metaBuilder.ControlFlowBuilder = RubyMethodInfo.RuleControlFlowBuilder; } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;C682742 File: RubyModule.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;C682742 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;InitAndScopes6 @@ -154,7 +154,7 @@ get { return ReferenceEquals(this, _context.ObjectClass); } } - internal virtual GlobalScopeExtension GlobalScope { + internal virtual RubyGlobalScope GlobalScope { get { return null; } } @@ -417,13 +417,13 @@ _path = path; } - public bool Load(RubyContext/*!*/ context, Scope/*!*/ autoloadScope) { + public bool Load(RubyGlobalScope/*!*/ autoloadScope) { if (_loaded) { return false; } _loaded = true; - return context.Loader.LoadFile(autoloadScope, null, _path, LoadFlags.LoadOnce | LoadFlags.AppendExtensions); + return autoloadScope.Context.Loader.LoadFile(autoloadScope.Scope, null, _path, LoadFlags.LoadOnce | LoadFlags.AppendExtensions); } } @@ -488,7 +488,7 @@ /// /// Get constant defined in this module. /// - public bool TryGetConstant(Scope autoloadScope, string/*!*/ name, out object value) { + public bool TryGetConstant(RubyGlobalScope autoloadScope, string/*!*/ name, out object value) { return TryLookupConstant(false, false, autoloadScope, name, out value) != ConstantLookupResult.NotFound; } @@ -502,7 +502,7 @@ /// /// Get constant defined in this module or any of its ancestors. /// - public bool TryResolveConstant(Scope autoloadScope, string/*!*/ name, out object value) { + public bool TryResolveConstant(RubyGlobalScope autoloadScope, string/*!*/ name, out object value) { return TryLookupConstant(true, true, autoloadScope, name, out value) != ConstantLookupResult.NotFound; } @@ -512,7 +512,9 @@ FoundAutoload = 2, } - private ConstantLookupResult TryLookupConstant(bool included, bool inherited, Scope autoloadScope, string/*!*/ name, out object value) { + private ConstantLookupResult TryLookupConstant(bool included, bool inherited, RubyGlobalScope autoloadScope, + string/*!*/ name, out object value) { + Debug.Assert(included || !inherited); value = null; @@ -541,7 +543,7 @@ RemoveConstant(name); // load file and try lookup again: - if (!autoloaded.Load(_context, autoloadScope)) { + if (!autoloaded.Load(autoloadScope)) { return ConstantLookupResult.NotFound; } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/ReflectionCache.Generated.cs;C674241 File: ReflectionCache.Generated.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/ReflectionCache.Generated.cs;C674241 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/ReflectionCache.Generated.cs;InitAndScopes6 @@ -19,32 +19,18 @@ namespace IronRuby.Compiler { internal static partial class Methods { - private static MethodInfo _TryGetObjectClassVariable, _TryGetClassVariable, _IsDefinedObjectClassVariable, _IsDefinedClassVariable, _SetObjectClassVariable, _SetClassVariable, _GetInstanceData, _DeserializeObject, _SerializeObject, _HookupEvent, _CreateDelegateFromProc, _CreateDelegateFromMethod, _X, _UpdateProfileTicks, _CreateRfcForMethod, _BlockRetry, _MethodRetry, _EvalRetry, _BlockBreak, - _MethodBreak, _EvalBreak, _MethodNext, _EvalNext, _MethodRedo, _EvalRedo, _BlockReturn, _EvalReturn, _BlockYield, _MethodYield, _EvalYield, _MethodProcCall, _CanRescue, _IsRetrySingleton, _PropagateRetrySingleton, _GetRetrySingleton, _GetCurrentMatchData, _GetCurrentMatchLastGroup, _GetCurrentMatchPrefix, _GetCurrentMatchSuffix, - _MatchLastInputLine, _MatchString, _CreateRegexB, _CreateRegexU, _CreateRegexE, _CreateRegexM, _CreateRegexBM, _CreateRegexUM, _CreateRegexEM, _CreateRegexMB, _CreateRegexMU, _CreateRegexME, _CreateRegexMM, _CreateRegexN, _CreateMutableStringB, _CreateMutableStringU, _CreateMutableStringE, _CreateMutableStringM, _CreateMutableStringBM, _CreateMutableStringUM, - _CreateMutableStringEM, _CreateMutableStringMB, _CreateMutableStringMU, _CreateMutableStringME, _CreateMutableStringMM, _CreateMutableStringN, _CreateSymbolB, _CreateSymbolU, _CreateSymbolE, _CreateSymbolM, _CreateSymbolBM, _CreateSymbolUM, _CreateSymbolEM, _CreateSymbolMB, _CreateSymbolMU, _CreateSymbolME, _CreateSymbolMM, _CreateSymbolN, _CreateEncoding, _IsTrue, - _IsFalse, _GetCurrentException, _SetCurrentExceptionAndStackTrace, _SetCurrentException, _CompareException, _CompareSplattedExceptions, _CompareDefaultException, _GetDefaultExceptionMessage, _MakeWrongNumberOfArgumentsError, _MakeTopLevelSuperException, _MakeMissingSuperException, _MakeInvalidArgumentTypesError, _MakeAmbiguousMatchError, _IsSuperCallTarget, _CreateInclusiveRange, _CreateExclusiveRange, _CreateInclusiveIntegerRange, _CreateExclusiveIntegerRange, _AllocateStructInstance, _CreateStructInstance, - _GetMetaObject, _ToProcValidator, _ToStringValidator, _ToSymbolValidator, _ConvertSymbolIdToSymbol, _ConvertFixnumToSymbol, _ConvertMutableStringToSymbol, _ToRegexValidator, _ToArrayValidator, _ToHashValidator, _ToFixnumValidator, _CreateTypeConversionError, _ConvertBignumToFixnum, _ToSDefaultConversion, _GetInstanceVariable, _IsDefinedInstanceVariable, _SetInstanceVariable, _GetObjectClassVariable, _GetClassVariable, _IsProcConverterTarget, - _CreateBfcForYield, _CreateBfcForMethodProcCall, _CreateBfcForProcCall, _CreateBfcForLibraryMethod, _LeaveProcConverter, _CreateMainTopLevelScope, _CreateTopLevelScope, _CreateWrappedTopLevelScope, _CreateModuleEvalScope, _CreateModuleScope, _CreateMethodScope, _CreateBlockScope, _TraceMethodCall, _TraceMethodReturn, _TraceBlockCall, _TraceBlockReturn, _PrintInteractiveResult, _GetLocalVariable, _SetLocalVariable, _GetContextFromScope, - _GetContextFromMethod, _GetContextFromBlockParam, _GetContextFromProc, _GetEmptyScope, _DefineBlock, _InitializeBlock, _Yield0, _Yield1, _Yield2, _Yield3, _Yield4, _YieldN, _YieldSplat0, _YieldSplat1, _YieldSplat2, _YieldSplat3, _YieldSplat4, _YieldSplatN, _YieldSplatNRhs, _DefineMethod, - _MethodDefined, _AliasMethod, _UndefineMethod, _IsDefinedMethod, _DefineGlobalModule, _DefineNestedModule, _DefineModule, _ConvertNamespaceToModule, _DefineSingletonClass, _DefineGlobalClass, _DefineNestedClass, _DefineClass, _GetGlobalConstant, _GetUnqualifiedConstant, _GetQualifiedConstant, _IsDefinedGlobalConstant, _IsDefinedUnqualifiedConstant, _IsDefinedQualifiedConstant, _SetGlobalConstant, _SetUnqualifiedConstant, - _SetQualifiedConstant, _MakeArray0, _MakeArray1, _MakeArray2, _MakeArray3, _MakeArray4, _MakeArray5, _MakeArrayN, _MakeHash0, _MakeHash, _SplatAppend, _Splat, _SplatPair, _Unsplat, _GetArrayItem, _GetArraySuffix, _GetGlobalVariable, _IsDefinedGlobalVariable, _SetGlobalVariable, _AliasGlobalVariable, - _GetCurrentMatchGroup; + private static MethodInfo _CreateRfcForMethod, _BlockRetry, _MethodRetry, _EvalRetry, _BlockBreak, _MethodBreak, _EvalBreak, _MethodNext, _EvalNext, _MethodRedo, _EvalRedo, _BlockReturn, _EvalReturn, _BlockYield, _MethodYield, _EvalYield, _MethodProcCall, _CanRescue, _IsRetrySingleton, + _PropagateRetrySingleton, _GetRetrySingleton, _UpdateProfileTicks, _CreateMainTopLevelScope, _CreateTopLevelHostedScope, _CreateTopLevelScope, _CreateWrappedTopLevelScope, _CreateModuleEvalScope, _CreateModuleScope, _CreateMethodScope, _CreateBlockScope, _TraceMethodCall, _TraceMethodReturn, _TraceBlockCall, _TraceBlockReturn, _PrintInteractiveResult, _GetLocalVariable, _SetLocalVariable, _GetContextFromScope, _GetContextFromMethod, + _GetContextFromBlockParam, _GetContextFromProc, _GetEmptyScope, _DefineBlock, _InitializeBlock, _Yield0, _Yield1, _Yield2, _Yield3, _Yield4, _YieldN, _YieldSplat0, _YieldSplat1, _YieldSplat2, _YieldSplat3, _YieldSplat4, _YieldSplatN, _YieldSplatNRhs, _DefineMethod, _MethodDefined, + _AliasMethod, _UndefineMethod, _IsDefinedMethod, _DefineGlobalModule, _DefineNestedModule, _DefineModule, _ConvertNamespaceToModule, _DefineSingletonClass, _DefineGlobalClass, _DefineNestedClass, _DefineClass, _GetGlobalConstant, _GetUnqualifiedConstant, _GetQualifiedConstant, _IsDefinedGlobalConstant, _IsDefinedUnqualifiedConstant, _IsDefinedQualifiedConstant, _SetGlobalConstant, _SetUnqualifiedConstant, _SetQualifiedConstant, + _MakeArray0, _MakeArray1, _MakeArray2, _MakeArray3, _MakeArray4, _MakeArray5, _MakeArrayN, _MakeHash0, _MakeHash, _SplatAppend, _Splat, _SplatPair, _Unsplat, _GetArrayItem, _GetArraySuffix, _GetGlobalVariable, _IsDefinedGlobalVariable, _SetGlobalVariable, _AliasGlobalVariable, _GetCurrentMatchGroup, + _GetCurrentMatchData, _GetCurrentMatchLastGroup, _GetCurrentMatchPrefix, _GetCurrentMatchSuffix, _MatchLastInputLine, _MatchString, _CreateRegexB, _CreateRegexU, _CreateRegexE, _CreateRegexM, _CreateRegexBM, _CreateRegexUM, _CreateRegexEM, _CreateRegexMB, _CreateRegexMU, _CreateRegexME, _CreateRegexMM, _CreateRegexN, _CreateMutableStringB, _CreateMutableStringU, + _CreateMutableStringE, _CreateMutableStringM, _CreateMutableStringBM, _CreateMutableStringUM, _CreateMutableStringEM, _CreateMutableStringMB, _CreateMutableStringMU, _CreateMutableStringME, _CreateMutableStringMM, _CreateMutableStringN, _CreateSymbolB, _CreateSymbolU, _CreateSymbolE, _CreateSymbolM, _CreateSymbolBM, _CreateSymbolUM, _CreateSymbolEM, _CreateSymbolMB, _CreateSymbolMU, _CreateSymbolME, + _CreateSymbolMM, _CreateSymbolN, _CreateEncoding, _IsTrue, _IsFalse, _GetCurrentException, _SetCurrentExceptionAndStackTrace, _SetCurrentException, _CompareException, _CompareSplattedExceptions, _CompareDefaultException, _GetDefaultExceptionMessage, _MakeWrongNumberOfArgumentsError, _MakeTopLevelSuperException, _MakeMissingSuperException, _MakeInvalidArgumentTypesError, _MakeAmbiguousMatchError, _IsSuperCallTarget, _CreateInclusiveRange, _CreateExclusiveRange, + _CreateInclusiveIntegerRange, _CreateExclusiveIntegerRange, _AllocateStructInstance, _CreateStructInstance, _GetMetaObject, _ToProcValidator, _ToStringValidator, _ToSymbolValidator, _ConvertSymbolIdToSymbol, _ConvertFixnumToSymbol, _ConvertMutableStringToSymbol, _ToRegexValidator, _ToArrayValidator, _ToHashValidator, _ToFixnumValidator, _CreateTypeConversionError, _ConvertBignumToFixnum, _ToSDefaultConversion, _GetInstanceVariable, _IsDefinedInstanceVariable, + _SetInstanceVariable, _GetObjectClassVariable, _GetClassVariable, _TryGetObjectClassVariable, _TryGetClassVariable, _IsDefinedObjectClassVariable, _IsDefinedClassVariable, _SetObjectClassVariable, _SetClassVariable, _GetInstanceData, _DeserializeObject, _SerializeObject, _HookupEvent, _CreateDelegateFromProc, _CreateDelegateFromMethod, _X, _IsProcConverterTarget, _CreateBfcForYield, _CreateBfcForMethodProcCall, _CreateBfcForProcCall, + _CreateBfcForLibraryMethod, _LeaveProcConverter; - public static MethodInfo/*!*/ TryGetObjectClassVariable { get { return _TryGetObjectClassVariable ?? (_TryGetObjectClassVariable = GetMethod(typeof(RubyOps), "TryGetObjectClassVariable")); } } - public static MethodInfo/*!*/ TryGetClassVariable { get { return _TryGetClassVariable ?? (_TryGetClassVariable = GetMethod(typeof(RubyOps), "TryGetClassVariable")); } } - public static MethodInfo/*!*/ IsDefinedObjectClassVariable { get { return _IsDefinedObjectClassVariable ?? (_IsDefinedObjectClassVariable = GetMethod(typeof(RubyOps), "IsDefinedObjectClassVariable")); } } - public static MethodInfo/*!*/ IsDefinedClassVariable { get { return _IsDefinedClassVariable ?? (_IsDefinedClassVariable = GetMethod(typeof(RubyOps), "IsDefinedClassVariable")); } } - public static MethodInfo/*!*/ SetObjectClassVariable { get { return _SetObjectClassVariable ?? (_SetObjectClassVariable = GetMethod(typeof(RubyOps), "SetObjectClassVariable")); } } - public static MethodInfo/*!*/ SetClassVariable { get { return _SetClassVariable ?? (_SetClassVariable = GetMethod(typeof(RubyOps), "SetClassVariable")); } } - public static MethodInfo/*!*/ GetInstanceData { get { return _GetInstanceData ?? (_GetInstanceData = GetMethod(typeof(RubyOps), "GetInstanceData")); } } - public static MethodInfo/*!*/ DeserializeObject { get { return _DeserializeObject ?? (_DeserializeObject = GetMethod(typeof(RubyOps), "DeserializeObject")); } } - public static MethodInfo/*!*/ SerializeObject { get { return _SerializeObject ?? (_SerializeObject = GetMethod(typeof(RubyOps), "SerializeObject")); } } - public static MethodInfo/*!*/ HookupEvent { get { return _HookupEvent ?? (_HookupEvent = GetMethod(typeof(RubyOps), "HookupEvent")); } } - public static MethodInfo/*!*/ CreateDelegateFromProc { get { return _CreateDelegateFromProc ?? (_CreateDelegateFromProc = GetMethod(typeof(RubyOps), "CreateDelegateFromProc")); } } - public static MethodInfo/*!*/ CreateDelegateFromMethod { get { return _CreateDelegateFromMethod ?? (_CreateDelegateFromMethod = GetMethod(typeof(RubyOps), "CreateDelegateFromMethod")); } } - public static MethodInfo/*!*/ X { get { return _X ?? (_X = GetMethod(typeof(RubyOps), "X")); } } - public static MethodInfo/*!*/ UpdateProfileTicks { get { return _UpdateProfileTicks ?? (_UpdateProfileTicks = GetMethod(typeof(RubyOps), "UpdateProfileTicks")); } } public static MethodInfo/*!*/ CreateRfcForMethod { get { return _CreateRfcForMethod ?? (_CreateRfcForMethod = GetMethod(typeof(RubyOps), "CreateRfcForMethod")); } } public static MethodInfo/*!*/ BlockRetry { get { return _BlockRetry ?? (_BlockRetry = GetMethod(typeof(RubyOps), "BlockRetry")); } } public static MethodInfo/*!*/ MethodRetry { get { return _MethodRetry ?? (_MethodRetry = GetMethod(typeof(RubyOps), "MethodRetry")); } } @@ -66,6 +52,84 @@ public static MethodInfo/*!*/ IsRetrySingleton { get { return _IsRetrySingleton ?? (_IsRetrySingleton = GetMethod(typeof(RubyOps), "IsRetrySingleton")); } } public static MethodInfo/*!*/ PropagateRetrySingleton { get { return _PropagateRetrySingleton ?? (_PropagateRetrySingleton = GetMethod(typeof(RubyOps), "PropagateRetrySingleton")); } } public static MethodInfo/*!*/ GetRetrySingleton { get { return _GetRetrySingleton ?? (_GetRetrySingleton = GetMethod(typeof(RubyOps), "GetRetrySingleton")); } } + public static MethodInfo/*!*/ UpdateProfileTicks { get { return _UpdateProfileTicks ?? (_UpdateProfileTicks = GetMethod(typeof(RubyOps), "UpdateProfileTicks")); } } + public static MethodInfo/*!*/ CreateMainTopLevelScope { get { return _CreateMainTopLevelScope ?? (_CreateMainTopLevelScope = GetMethod(typeof(RubyOps), "CreateMainTopLevelScope")); } } + public static MethodInfo/*!*/ CreateTopLevelHostedScope { get { return _CreateTopLevelHostedScope ?? (_CreateTopLevelHostedScope = GetMethod(typeof(RubyOps), "CreateTopLevelHostedScope")); } } + public static MethodInfo/*!*/ CreateTopLevelScope { get { return _CreateTopLevelScope ?? (_CreateTopLevelScope = GetMethod(typeof(RubyOps), "CreateTopLevelScope")); } } + public static MethodInfo/*!*/ CreateWrappedTopLevelScope { get { return _CreateWrappedTopLevelScope ?? (_CreateWrappedTopLevelScope = GetMethod(typeof(RubyOps), "CreateWrappedTopLevelScope")); } } + public static MethodInfo/*!*/ CreateModuleEvalScope { get { return _CreateModuleEvalScope ?? (_CreateModuleEvalScope = GetMethod(typeof(RubyOps), "CreateModuleEvalScope")); } } + public static MethodInfo/*!*/ CreateModuleScope { get { return _CreateModuleScope ?? (_CreateModuleScope = GetMethod(typeof(RubyOps), "CreateModuleScope")); } } + public static MethodInfo/*!*/ CreateMethodScope { get { return _CreateMethodScope ?? (_CreateMethodScope = GetMethod(typeof(RubyOps), "CreateMethodScope")); } } + public static MethodInfo/*!*/ CreateBlockScope { get { return _CreateBlockScope ?? (_CreateBlockScope = GetMethod(typeof(RubyOps), "CreateBlockScope")); } } + public static MethodInfo/*!*/ TraceMethodCall { get { return _TraceMethodCall ?? (_TraceMethodCall = GetMethod(typeof(RubyOps), "TraceMethodCall")); } } + public static MethodInfo/*!*/ TraceMethodReturn { get { return _TraceMethodReturn ?? (_TraceMethodReturn = GetMethod(typeof(RubyOps), "TraceMethodReturn")); } } + public static MethodInfo/*!*/ TraceBlockCall { get { return _TraceBlockCall ?? (_TraceBlockCall = GetMethod(typeof(RubyOps), "TraceBlockCall")); } } + public static MethodInfo/*!*/ TraceBlockReturn { get { return _TraceBlockReturn ?? (_TraceBlockReturn = GetMethod(typeof(RubyOps), "TraceBlockReturn")); } } + public static MethodInfo/*!*/ PrintInteractiveResult { get { return _PrintInteractiveResult ?? (_PrintInteractiveResult = GetMethod(typeof(RubyOps), "PrintInteractiveResult")); } } + public static MethodInfo/*!*/ GetLocalVariable { get { return _GetLocalVariable ?? (_GetLocalVariable = GetMethod(typeof(RubyOps), "GetLocalVariable")); } } + public static MethodInfo/*!*/ SetLocalVariable { get { return _SetLocalVariable ?? (_SetLocalVariable = GetMethod(typeof(RubyOps), "SetLocalVariable")); } } + public static MethodInfo/*!*/ GetContextFromScope { get { return _GetContextFromScope ?? (_GetContextFromScope = GetMethod(typeof(RubyOps), "GetContextFromScope")); } } + public static MethodInfo/*!*/ GetContextFromMethod { get { return _GetContextFromMethod ?? (_GetContextFromMethod = GetMethod(typeof(RubyOps), "GetContextFromMethod")); } } + public static MethodInfo/*!*/ GetContextFromBlockParam { get { return _GetContextFromBlockParam ?? (_GetContextFromBlockParam = GetMethod(typeof(RubyOps), "GetContextFromBlockParam")); } } + public static MethodInfo/*!*/ GetContextFromProc { get { return _GetContextFromProc ?? (_GetContextFromProc = GetMethod(typeof(RubyOps), "GetContextFromProc")); } } + public static MethodInfo/*!*/ GetEmptyScope { get { return _GetEmptyScope ?? (_GetEmptyScope = GetMethod(typeof(RubyOps), "GetEmptyScope")); } } + public static MethodInfo/*!*/ DefineBlock { get { return _DefineBlock ?? (_DefineBlock = GetMethod(typeof(RubyOps), "DefineBlock")); } } + public static MethodInfo/*!*/ InitializeBlock { get { return _InitializeBlock ?? (_InitializeBlock = GetMethod(typeof(RubyOps), "InitializeBlock")); } } + public static MethodInfo/*!*/ Yield0 { get { return _Yield0 ?? (_Yield0 = GetMethod(typeof(RubyOps), "Yield0")); } } + public static MethodInfo/*!*/ Yield1 { get { return _Yield1 ?? (_Yield1 = GetMethod(typeof(RubyOps), "Yield1")); } } + public static MethodInfo/*!*/ Yield2 { get { return _Yield2 ?? (_Yield2 = GetMethod(typeof(RubyOps), "Yield2")); } } + public static MethodInfo/*!*/ Yield3 { get { return _Yield3 ?? (_Yield3 = GetMethod(typeof(RubyOps), "Yield3")); } } + public static MethodInfo/*!*/ Yield4 { get { return _Yield4 ?? (_Yield4 = GetMethod(typeof(RubyOps), "Yield4")); } } + public static MethodInfo/*!*/ YieldN { get { return _YieldN ?? (_YieldN = GetMethod(typeof(RubyOps), "YieldN")); } } + public static MethodInfo/*!*/ YieldSplat0 { get { return _YieldSplat0 ?? (_YieldSplat0 = GetMethod(typeof(RubyOps), "YieldSplat0")); } } + public static MethodInfo/*!*/ YieldSplat1 { get { return _YieldSplat1 ?? (_YieldSplat1 = GetMethod(typeof(RubyOps), "YieldSplat1")); } } + public static MethodInfo/*!*/ YieldSplat2 { get { return _YieldSplat2 ?? (_YieldSplat2 = GetMethod(typeof(RubyOps), "YieldSplat2")); } } + public static MethodInfo/*!*/ YieldSplat3 { get { return _YieldSplat3 ?? (_YieldSplat3 = GetMethod(typeof(RubyOps), "YieldSplat3")); } } + public static MethodInfo/*!*/ YieldSplat4 { get { return _YieldSplat4 ?? (_YieldSplat4 = GetMethod(typeof(RubyOps), "YieldSplat4")); } } + public static MethodInfo/*!*/ YieldSplatN { get { return _YieldSplatN ?? (_YieldSplatN = GetMethod(typeof(RubyOps), "YieldSplatN")); } } + public static MethodInfo/*!*/ YieldSplatNRhs { get { return _YieldSplatNRhs ?? (_YieldSplatNRhs = GetMethod(typeof(RubyOps), "YieldSplatNRhs")); } } + public static MethodInfo/*!*/ DefineMethod { get { return _DefineMethod ?? (_DefineMethod = GetMethod(typeof(RubyOps), "DefineMethod")); } } + public static MethodInfo/*!*/ MethodDefined { get { return _MethodDefined ?? (_MethodDefined = GetMethod(typeof(RubyOps), "MethodDefined")); } } + public static MethodInfo/*!*/ AliasMethod { get { return _AliasMethod ?? (_AliasMethod = GetMethod(typeof(RubyOps), "AliasMethod")); } } + public static MethodInfo/*!*/ UndefineMethod { get { return _UndefineMethod ?? (_UndefineMethod = GetMethod(typeof(RubyOps), "UndefineMethod")); } } + public static MethodInfo/*!*/ IsDefinedMethod { get { return _IsDefinedMethod ?? (_IsDefinedMethod = GetMethod(typeof(RubyOps), "IsDefinedMethod")); } } + public static MethodInfo/*!*/ DefineGlobalModule { get { return _DefineGlobalModule ?? (_DefineGlobalModule = GetMethod(typeof(RubyOps), "DefineGlobalModule")); } } + public static MethodInfo/*!*/ DefineNestedModule { get { return _DefineNestedModule ?? (_DefineNestedModule = GetMethod(typeof(RubyOps), "DefineNestedModule")); } } + public static MethodInfo/*!*/ DefineModule { get { return _DefineModule ?? (_DefineModule = GetMethod(typeof(RubyOps), "DefineModule")); } } + public static MethodInfo/*!*/ ConvertNamespaceToModule { get { return _ConvertNamespaceToModule ?? (_ConvertNamespaceToModule = GetMethod(typeof(RubyOps), "ConvertNamespaceToModule")); } } + public static MethodInfo/*!*/ DefineSingletonClass { get { return _DefineSingletonClass ?? (_DefineSingletonClass = GetMethod(typeof(RubyOps), "DefineSingletonClass")); } } + public static MethodInfo/*!*/ DefineGlobalClass { get { return _DefineGlobalClass ?? (_DefineGlobalClass = GetMethod(typeof(RubyOps), "DefineGlobalClass")); } } + public static MethodInfo/*!*/ DefineNestedClass { get { return _DefineNestedClass ?? (_DefineNestedClass = GetMethod(typeof(RubyOps), "DefineNestedClass")); } } + public static MethodInfo/*!*/ DefineClass { get { return _DefineClass ?? (_DefineClass = GetMethod(typeof(RubyOps), "DefineClass")); } } + public static MethodInfo/*!*/ GetGlobalConstant { get { return _GetGlobalConstant ?? (_GetGlobalConstant = GetMethod(typeof(RubyOps), "GetGlobalConstant")); } } + public static MethodInfo/*!*/ GetUnqualifiedConstant { get { return _GetUnqualifiedConstant ?? (_GetUnqualifiedConstant = GetMethod(typeof(RubyOps), "GetUnqualifiedConstant")); } } + public static MethodInfo/*!*/ GetQualifiedConstant { get { return _GetQualifiedConstant ?? (_GetQualifiedConstant = GetMethod(typeof(RubyOps), "GetQualifiedConstant")); } } + public static MethodInfo/*!*/ IsDefinedGlobalConstant { get { return _IsDefinedGlobalConstant ?? (_IsDefinedGlobalConstant = GetMethod(typeof(RubyOps), "IsDefinedGlobalConstant")); } } + public static MethodInfo/*!*/ IsDefinedUnqualifiedConstant { get { return _IsDefinedUnqualifiedConstant ?? (_IsDefinedUnqualifiedConstant = GetMethod(typeof(RubyOps), "IsDefinedUnqualifiedConstant")); } } + public static MethodInfo/*!*/ IsDefinedQualifiedConstant { get { return _IsDefinedQualifiedConstant ?? (_IsDefinedQualifiedConstant = GetMethod(typeof(RubyOps), "IsDefinedQualifiedConstant")); } } + public static MethodInfo/*!*/ SetGlobalConstant { get { return _SetGlobalConstant ?? (_SetGlobalConstant = GetMethod(typeof(RubyOps), "SetGlobalConstant")); } } + public static MethodInfo/*!*/ SetUnqualifiedConstant { get { return _SetUnqualifiedConstant ?? (_SetUnqualifiedConstant = GetMethod(typeof(RubyOps), "SetUnqualifiedConstant")); } } + public static MethodInfo/*!*/ SetQualifiedConstant { get { return _SetQualifiedConstant ?? (_SetQualifiedConstant = GetMethod(typeof(RubyOps), "SetQualifiedConstant")); } } + public static MethodInfo/*!*/ MakeArray0 { get { return _MakeArray0 ?? (_MakeArray0 = GetMethod(typeof(RubyOps), "MakeArray0")); } } + public static MethodInfo/*!*/ MakeArray1 { get { return _MakeArray1 ?? (_MakeArray1 = GetMethod(typeof(RubyOps), "MakeArray1")); } } + public static MethodInfo/*!*/ MakeArray2 { get { return _MakeArray2 ?? (_MakeArray2 = GetMethod(typeof(RubyOps), "MakeArray2")); } } + public static MethodInfo/*!*/ MakeArray3 { get { return _MakeArray3 ?? (_MakeArray3 = GetMethod(typeof(RubyOps), "MakeArray3")); } } + public static MethodInfo/*!*/ MakeArray4 { get { return _MakeArray4 ?? (_MakeArray4 = GetMethod(typeof(RubyOps), "MakeArray4")); } } + public static MethodInfo/*!*/ MakeArray5 { get { return _MakeArray5 ?? (_MakeArray5 = GetMethod(typeof(RubyOps), "MakeArray5")); } } + public static MethodInfo/*!*/ MakeArrayN { get { return _MakeArrayN ?? (_MakeArrayN = GetMethod(typeof(RubyOps), "MakeArrayN")); } } + public static MethodInfo/*!*/ MakeHash0 { get { return _MakeHash0 ?? (_MakeHash0 = GetMethod(typeof(RubyOps), "MakeHash0")); } } + public static MethodInfo/*!*/ MakeHash { get { return _MakeHash ?? (_MakeHash = GetMethod(typeof(RubyOps), "MakeHash")); } } + public static MethodInfo/*!*/ SplatAppend { get { return _SplatAppend ?? (_SplatAppend = GetMethod(typeof(RubyOps), "SplatAppend")); } } + public static MethodInfo/*!*/ Splat { get { return _Splat ?? (_Splat = GetMethod(typeof(RubyOps), "Splat")); } } + public static MethodInfo/*!*/ SplatPair { get { return _SplatPair ?? (_SplatPair = GetMethod(typeof(RubyOps), "SplatPair")); } } + public static MethodInfo/*!*/ Unsplat { get { return _Unsplat ?? (_Unsplat = GetMethod(typeof(RubyOps), "Unsplat")); } } + public static MethodInfo/*!*/ GetArrayItem { get { return _GetArrayItem ?? (_GetArrayItem = GetMethod(typeof(RubyOps), "GetArrayItem")); } } + public static MethodInfo/*!*/ GetArraySuffix { get { return _GetArraySuffix ?? (_GetArraySuffix = GetMethod(typeof(RubyOps), "GetArraySuffix")); } } + public static MethodInfo/*!*/ GetGlobalVariable { get { return _GetGlobalVariable ?? (_GetGlobalVariable = GetMethod(typeof(RubyOps), "GetGlobalVariable")); } } + public static MethodInfo/*!*/ IsDefinedGlobalVariable { get { return _IsDefinedGlobalVariable ?? (_IsDefinedGlobalVariable = GetMethod(typeof(RubyOps), "IsDefinedGlobalVariable")); } } + public static MethodInfo/*!*/ SetGlobalVariable { get { return _SetGlobalVariable ?? (_SetGlobalVariable = GetMethod(typeof(RubyOps), "SetGlobalVariable")); } } + public static MethodInfo/*!*/ AliasGlobalVariable { get { return _AliasGlobalVariable ?? (_AliasGlobalVariable = GetMethod(typeof(RubyOps), "AliasGlobalVariable")); } } + public static MethodInfo/*!*/ GetCurrentMatchGroup { get { return _GetCurrentMatchGroup ?? (_GetCurrentMatchGroup = GetMethod(typeof(RubyOps), "GetCurrentMatchGroup")); } } public static MethodInfo/*!*/ GetCurrentMatchData { get { return _GetCurrentMatchData ?? (_GetCurrentMatchData = GetMethod(typeof(RubyOps), "GetCurrentMatchData")); } } public static MethodInfo/*!*/ GetCurrentMatchLastGroup { get { return _GetCurrentMatchLastGroup ?? (_GetCurrentMatchLastGroup = GetMethod(typeof(RubyOps), "GetCurrentMatchLastGroup")); } } public static MethodInfo/*!*/ GetCurrentMatchPrefix { get { return _GetCurrentMatchPrefix ?? (_GetCurrentMatchPrefix = GetMethod(typeof(RubyOps), "GetCurrentMatchPrefix")); } } @@ -149,88 +213,25 @@ public static MethodInfo/*!*/ SetInstanceVariable { get { return _SetInstanceVariable ?? (_SetInstanceVariable = GetMethod(typeof(RubyOps), "SetInstanceVariable")); } } public static MethodInfo/*!*/ GetObjectClassVariable { get { return _GetObjectClassVariable ?? (_GetObjectClassVariable = GetMethod(typeof(RubyOps), "GetObjectClassVariable")); } } public static MethodInfo/*!*/ GetClassVariable { get { return _GetClassVariable ?? (_GetClassVariable = GetMethod(typeof(RubyOps), "GetClassVariable")); } } + public static MethodInfo/*!*/ TryGetObjectClassVariable { get { return _TryGetObjectClassVariable ?? (_TryGetObjectClassVariable = GetMethod(typeof(RubyOps), "TryGetObjectClassVariable")); } } + public static MethodInfo/*!*/ TryGetClassVariable { get { return _TryGetClassVariable ?? (_TryGetClassVariable = GetMethod(typeof(RubyOps), "TryGetClassVariable")); } } + public static MethodInfo/*!*/ IsDefinedObjectClassVariable { get { return _IsDefinedObjectClassVariable ?? (_IsDefinedObjectClassVariable = GetMethod(typeof(RubyOps), "IsDefinedObjectClassVariable")); } } + public static MethodInfo/*!*/ IsDefinedClassVariable { get { return _IsDefinedClassVariable ?? (_IsDefinedClassVariable = GetMethod(typeof(RubyOps), "IsDefinedClassVariable")); } } + public static MethodInfo/*!*/ SetObjectClassVariable { get { return _SetObjectClassVariable ?? (_SetObjectClassVariable = GetMethod(typeof(RubyOps), "SetObjectClassVariable")); } } + public static MethodInfo/*!*/ SetClassVariable { get { return _SetClassVariable ?? (_SetClassVariable = GetMethod(typeof(RubyOps), "SetClassVariable")); } } + public static MethodInfo/*!*/ GetInstanceData { get { return _GetInstanceData ?? (_GetInstanceData = GetMethod(typeof(RubyOps), "GetInstanceData")); } } + public static MethodInfo/*!*/ DeserializeObject { get { return _DeserializeObject ?? (_DeserializeObject = GetMethod(typeof(RubyOps), "DeserializeObject")); } } + public static MethodInfo/*!*/ SerializeObject { get { return _SerializeObject ?? (_SerializeObject = GetMethod(typeof(RubyOps), "SerializeObject")); } } + public static MethodInfo/*!*/ HookupEvent { get { return _HookupEvent ?? (_HookupEvent = GetMethod(typeof(RubyOps), "HookupEvent")); } } + public static MethodInfo/*!*/ CreateDelegateFromProc { get { return _CreateDelegateFromProc ?? (_CreateDelegateFromProc = GetMethod(typeof(RubyOps), "CreateDelegateFromProc")); } } + public static MethodInfo/*!*/ CreateDelegateFromMethod { get { return _CreateDelegateFromMethod ?? (_CreateDelegateFromMethod = GetMethod(typeof(RubyOps), "CreateDelegateFromMethod")); } } + public static MethodInfo/*!*/ X { get { return _X ?? (_X = GetMethod(typeof(RubyOps), "X")); } } public static MethodInfo/*!*/ IsProcConverterTarget { get { return _IsProcConverterTarget ?? (_IsProcConverterTarget = GetMethod(typeof(RubyOps), "IsProcConverterTarget")); } } public static MethodInfo/*!*/ CreateBfcForYield { get { return _CreateBfcForYield ?? (_CreateBfcForYield = GetMethod(typeof(RubyOps), "CreateBfcForYield")); } } public static MethodInfo/*!*/ CreateBfcForMethodProcCall { get { return _CreateBfcForMethodProcCall ?? (_CreateBfcForMethodProcCall = GetMethod(typeof(RubyOps), "CreateBfcForMethodProcCall")); } } public static MethodInfo/*!*/ CreateBfcForProcCall { get { return _CreateBfcForProcCall ?? (_CreateBfcForProcCall = GetMethod(typeof(RubyOps), "CreateBfcForProcCall")); } } public static MethodInfo/*!*/ CreateBfcForLibraryMethod { get { return _CreateBfcForLibraryMethod ?? (_CreateBfcForLibraryMethod = GetMethod(typeof(RubyOps), "CreateBfcForLibraryMethod")); } } public static MethodInfo/*!*/ LeaveProcConverter { get { return _LeaveProcConverter ?? (_LeaveProcConverter = GetMethod(typeof(RubyOps), "LeaveProcConverter")); } } - public static MethodInfo/*!*/ CreateMainTopLevelScope { get { return _CreateMainTopLevelScope ?? (_CreateMainTopLevelScope = GetMethod(typeof(RubyOps), "CreateMainTopLevelScope")); } } - public static MethodInfo/*!*/ CreateTopLevelScope { get { return _CreateTopLevelScope ?? (_CreateTopLevelScope = GetMethod(typeof(RubyOps), "CreateTopLevelScope")); } } - public static MethodInfo/*!*/ CreateWrappedTopLevelScope { get { return _CreateWrappedTopLevelScope ?? (_CreateWrappedTopLevelScope = GetMethod(typeof(RubyOps), "CreateWrappedTopLevelScope")); } } - public static MethodInfo/*!*/ CreateModuleEvalScope { get { return _CreateModuleEvalScope ?? (_CreateModuleEvalScope = GetMethod(typeof(RubyOps), "CreateModuleEvalScope")); } } - public static MethodInfo/*!*/ CreateModuleScope { get { return _CreateModuleScope ?? (_CreateModuleScope = GetMethod(typeof(RubyOps), "CreateModuleScope")); } } - public static MethodInfo/*!*/ CreateMethodScope { get { return _CreateMethodScope ?? (_CreateMethodScope = GetMethod(typeof(RubyOps), "CreateMethodScope")); } } - public static MethodInfo/*!*/ CreateBlockScope { get { return _CreateBlockScope ?? (_CreateBlockScope = GetMethod(typeof(RubyOps), "CreateBlockScope")); } } - public static MethodInfo/*!*/ TraceMethodCall { get { return _TraceMethodCall ?? (_TraceMethodCall = GetMethod(typeof(RubyOps), "TraceMethodCall")); } } - public static MethodInfo/*!*/ TraceMethodReturn { get { return _TraceMethodReturn ?? (_TraceMethodReturn = GetMethod(typeof(RubyOps), "TraceMethodReturn")); } } - public static MethodInfo/*!*/ TraceBlockCall { get { return _TraceBlockCall ?? (_TraceBlockCall = GetMethod(typeof(RubyOps), "TraceBlockCall")); } } - public static MethodInfo/*!*/ TraceBlockReturn { get { return _TraceBlockReturn ?? (_TraceBlockReturn = GetMethod(typeof(RubyOps), "TraceBlockReturn")); } } - public static MethodInfo/*!*/ PrintInteractiveResult { get { return _PrintInteractiveResult ?? (_PrintInteractiveResult = GetMethod(typeof(RubyOps), "PrintInteractiveResult")); } } - public static MethodInfo/*!*/ GetLocalVariable { get { return _GetLocalVariable ?? (_GetLocalVariable = GetMethod(typeof(RubyOps), "GetLocalVariable")); } } - public static MethodInfo/*!*/ SetLocalVariable { get { return _SetLocalVariable ?? (_SetLocalVariable = GetMethod(typeof(RubyOps), "SetLocalVariable")); } } - public static MethodInfo/*!*/ GetContextFromScope { get { return _GetContextFromScope ?? (_GetContextFromScope = GetMethod(typeof(RubyOps), "GetContextFromScope")); } } - public static MethodInfo/*!*/ GetContextFromMethod { get { return _GetContextFromMethod ?? (_GetContextFromMethod = GetMethod(typeof(RubyOps), "GetContextFromMethod")); } } - public static MethodInfo/*!*/ GetContextFromBlockParam { get { return _GetContextFromBlockParam ?? (_GetContextFromBlockParam = GetMethod(typeof(RubyOps), "GetContextFromBlockParam")); } } - public static MethodInfo/*!*/ GetContextFromProc { get { return _GetContextFromProc ?? (_GetContextFromProc = GetMethod(typeof(RubyOps), "GetContextFromProc")); } } - public static MethodInfo/*!*/ GetEmptyScope { get { return _GetEmptyScope ?? (_GetEmptyScope = GetMethod(typeof(RubyOps), "GetEmptyScope")); } } - public static MethodInfo/*!*/ DefineBlock { get { return _DefineBlock ?? (_DefineBlock = GetMethod(typeof(RubyOps), "DefineBlock")); } } - public static MethodInfo/*!*/ InitializeBlock { get { return _InitializeBlock ?? (_InitializeBlock = GetMethod(typeof(RubyOps), "InitializeBlock")); } } - public static MethodInfo/*!*/ Yield0 { get { return _Yield0 ?? (_Yield0 = GetMethod(typeof(RubyOps), "Yield0")); } } - public static MethodInfo/*!*/ Yield1 { get { return _Yield1 ?? (_Yield1 = GetMethod(typeof(RubyOps), "Yield1")); } } - public static MethodInfo/*!*/ Yield2 { get { return _Yield2 ?? (_Yield2 = GetMethod(typeof(RubyOps), "Yield2")); } } - public static MethodInfo/*!*/ Yield3 { get { return _Yield3 ?? (_Yield3 = GetMethod(typeof(RubyOps), "Yield3")); } } - public static MethodInfo/*!*/ Yield4 { get { return _Yield4 ?? (_Yield4 = GetMethod(typeof(RubyOps), "Yield4")); } } - public static MethodInfo/*!*/ YieldN { get { return _YieldN ?? (_YieldN = GetMethod(typeof(RubyOps), "YieldN")); } } - public static MethodInfo/*!*/ YieldSplat0 { get { return _YieldSplat0 ?? (_YieldSplat0 = GetMethod(typeof(RubyOps), "YieldSplat0")); } } - public static MethodInfo/*!*/ YieldSplat1 { get { return _YieldSplat1 ?? (_YieldSplat1 = GetMethod(typeof(RubyOps), "YieldSplat1")); } } - public static MethodInfo/*!*/ YieldSplat2 { get { return _YieldSplat2 ?? (_YieldSplat2 = GetMethod(typeof(RubyOps), "YieldSplat2")); } } - public static MethodInfo/*!*/ YieldSplat3 { get { return _YieldSplat3 ?? (_YieldSplat3 = GetMethod(typeof(RubyOps), "YieldSplat3")); } } - public static MethodInfo/*!*/ YieldSplat4 { get { return _YieldSplat4 ?? (_YieldSplat4 = GetMethod(typeof(RubyOps), "YieldSplat4")); } } - public static MethodInfo/*!*/ YieldSplatN { get { return _YieldSplatN ?? (_YieldSplatN = GetMethod(typeof(RubyOps), "YieldSplatN")); } } - public static MethodInfo/*!*/ YieldSplatNRhs { get { return _YieldSplatNRhs ?? (_YieldSplatNRhs = GetMethod(typeof(RubyOps), "YieldSplatNRhs")); } } - public static MethodInfo/*!*/ DefineMethod { get { return _DefineMethod ?? (_DefineMethod = GetMethod(typeof(RubyOps), "DefineMethod")); } } - public static MethodInfo/*!*/ MethodDefined { get { return _MethodDefined ?? (_MethodDefined = GetMethod(typeof(RubyOps), "MethodDefined")); } } - public static MethodInfo/*!*/ AliasMethod { get { return _AliasMethod ?? (_AliasMethod = GetMethod(typeof(RubyOps), "AliasMethod")); } } - public static MethodInfo/*!*/ UndefineMethod { get { return _UndefineMethod ?? (_UndefineMethod = GetMethod(typeof(RubyOps), "UndefineMethod")); } } - public static MethodInfo/*!*/ IsDefinedMethod { get { return _IsDefinedMethod ?? (_IsDefinedMethod = GetMethod(typeof(RubyOps), "IsDefinedMethod")); } } - public static MethodInfo/*!*/ DefineGlobalModule { get { return _DefineGlobalModule ?? (_DefineGlobalModule = GetMethod(typeof(RubyOps), "DefineGlobalModule")); } } - public static MethodInfo/*!*/ DefineNestedModule { get { return _DefineNestedModule ?? (_DefineNestedModule = GetMethod(typeof(RubyOps), "DefineNestedModule")); } } - public static MethodInfo/*!*/ DefineModule { get { return _DefineModule ?? (_DefineModule = GetMethod(typeof(RubyOps), "DefineModule")); } } - public static MethodInfo/*!*/ ConvertNamespaceToModule { get { return _ConvertNamespaceToModule ?? (_ConvertNamespaceToModule = GetMethod(typeof(RubyOps), "ConvertNamespaceToModule")); } } - public static MethodInfo/*!*/ DefineSingletonClass { get { return _DefineSingletonClass ?? (_DefineSingletonClass = GetMethod(typeof(RubyOps), "DefineSingletonClass")); } } - public static MethodInfo/*!*/ DefineGlobalClass { get { return _DefineGlobalClass ?? (_DefineGlobalClass = GetMethod(typeof(RubyOps), "DefineGlobalClass")); } } - public static MethodInfo/*!*/ DefineNestedClass { get { return _DefineNestedClass ?? (_DefineNestedClass = GetMethod(typeof(RubyOps), "DefineNestedClass")); } } - public static MethodInfo/*!*/ DefineClass { get { return _DefineClass ?? (_DefineClass = GetMethod(typeof(RubyOps), "DefineClass")); } } - public static MethodInfo/*!*/ GetGlobalConstant { get { return _GetGlobalConstant ?? (_GetGlobalConstant = GetMethod(typeof(RubyOps), "GetGlobalConstant")); } } - public static MethodInfo/*!*/ GetUnqualifiedConstant { get { return _GetUnqualifiedConstant ?? (_GetUnqualifiedConstant = GetMethod(typeof(RubyOps), "GetUnqualifiedConstant")); } } - public static MethodInfo/*!*/ GetQualifiedConstant { get { return _GetQualifiedConstant ?? (_GetQualifiedConstant = GetMethod(typeof(RubyOps), "GetQualifiedConstant")); } } - public static MethodInfo/*!*/ IsDefinedGlobalConstant { get { return _IsDefinedGlobalConstant ?? (_IsDefinedGlobalConstant = GetMethod(typeof(RubyOps), "IsDefinedGlobalConstant")); } } - public static MethodInfo/*!*/ IsDefinedUnqualifiedConstant { get { return _IsDefinedUnqualifiedConstant ?? (_IsDefinedUnqualifiedConstant = GetMethod(typeof(RubyOps), "IsDefinedUnqualifiedConstant")); } } - public static MethodInfo/*!*/ IsDefinedQualifiedConstant { get { return _IsDefinedQualifiedConstant ?? (_IsDefinedQualifiedConstant = GetMethod(typeof(RubyOps), "IsDefinedQualifiedConstant")); } } - public static MethodInfo/*!*/ SetGlobalConstant { get { return _SetGlobalConstant ?? (_SetGlobalConstant = GetMethod(typeof(RubyOps), "SetGlobalConstant")); } } - public static MethodInfo/*!*/ SetUnqualifiedConstant { get { return _SetUnqualifiedConstant ?? (_SetUnqualifiedConstant = GetMethod(typeof(RubyOps), "SetUnqualifiedConstant")); } } - public static MethodInfo/*!*/ SetQualifiedConstant { get { return _SetQualifiedConstant ?? (_SetQualifiedConstant = GetMethod(typeof(RubyOps), "SetQualifiedConstant")); } } - public static MethodInfo/*!*/ MakeArray0 { get { return _MakeArray0 ?? (_MakeArray0 = GetMethod(typeof(RubyOps), "MakeArray0")); } } - public static MethodInfo/*!*/ MakeArray1 { get { return _MakeArray1 ?? (_MakeArray1 = GetMethod(typeof(RubyOps), "MakeArray1")); } } - public static MethodInfo/*!*/ MakeArray2 { get { return _MakeArray2 ?? (_MakeArray2 = GetMethod(typeof(RubyOps), "MakeArray2")); } } - public static MethodInfo/*!*/ MakeArray3 { get { return _MakeArray3 ?? (_MakeArray3 = GetMethod(typeof(RubyOps), "MakeArray3")); } } - public static MethodInfo/*!*/ MakeArray4 { get { return _MakeArray4 ?? (_MakeArray4 = GetMethod(typeof(RubyOps), "MakeArray4")); } } - public static MethodInfo/*!*/ MakeArray5 { get { return _MakeArray5 ?? (_MakeArray5 = GetMethod(typeof(RubyOps), "MakeArray5")); } } - public static MethodInfo/*!*/ MakeArrayN { get { return _MakeArrayN ?? (_MakeArrayN = GetMethod(typeof(RubyOps), "MakeArrayN")); } } - public static MethodInfo/*!*/ MakeHash0 { get { return _MakeHash0 ?? (_MakeHash0 = GetMethod(typeof(RubyOps), "MakeHash0")); } } - public static MethodInfo/*!*/ MakeHash { get { return _MakeHash ?? (_MakeHash = GetMethod(typeof(RubyOps), "MakeHash")); } } - public static MethodInfo/*!*/ SplatAppend { get { return _SplatAppend ?? (_SplatAppend = GetMethod(typeof(RubyOps), "SplatAppend")); } } - public static MethodInfo/*!*/ Splat { get { return _Splat ?? (_Splat = GetMethod(typeof(RubyOps), "Splat")); } } - public static MethodInfo/*!*/ SplatPair { get { return _SplatPair ?? (_SplatPair = GetMethod(typeof(RubyOps), "SplatPair")); } } - public static MethodInfo/*!*/ Unsplat { get { return _Unsplat ?? (_Unsplat = GetMethod(typeof(RubyOps), "Unsplat")); } } - public static MethodInfo/*!*/ GetArrayItem { get { return _GetArrayItem ?? (_GetArrayItem = GetMethod(typeof(RubyOps), "GetArrayItem")); } } - public static MethodInfo/*!*/ GetArraySuffix { get { return _GetArraySuffix ?? (_GetArraySuffix = GetMethod(typeof(RubyOps), "GetArraySuffix")); } } - public static MethodInfo/*!*/ GetGlobalVariable { get { return _GetGlobalVariable ?? (_GetGlobalVariable = GetMethod(typeof(RubyOps), "GetGlobalVariable")); } } - public static MethodInfo/*!*/ IsDefinedGlobalVariable { get { return _IsDefinedGlobalVariable ?? (_IsDefinedGlobalVariable = GetMethod(typeof(RubyOps), "IsDefinedGlobalVariable")); } } - public static MethodInfo/*!*/ SetGlobalVariable { get { return _SetGlobalVariable ?? (_SetGlobalVariable = GetMethod(typeof(RubyOps), "SetGlobalVariable")); } } - public static MethodInfo/*!*/ AliasGlobalVariable { get { return _AliasGlobalVariable ?? (_AliasGlobalVariable = GetMethod(typeof(RubyOps), "AliasGlobalVariable")); } } - public static MethodInfo/*!*/ GetCurrentMatchGroup { get { return _GetCurrentMatchGroup ?? (_GetCurrentMatchGroup = GetMethod(typeof(RubyOps), "GetCurrentMatchGroup")); } } public static MethodInfo/*!*/ CreateRegex(string/*!*/ suffix) { switch (suffix) { =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/RubyCompilerOptions.cs;C633889 File: RubyCompilerOptions.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/RubyCompilerOptions.cs;C633889 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/RubyCompilerOptions.cs;InitAndScopes6 @@ -20,14 +20,53 @@ using IronRuby.Runtime; namespace IronRuby.Compiler { + internal enum TopScopeFactoryKind { + /// + /// Simple scope without DLR Scope binding. + /// Used by Execute("code") w/o scope. + /// + Default, + + /// + /// Main script scope w/o DLR Scope binding. + /// The factory sets TOPLEVEL_BINDING and DATA constants. + /// Used by ExecuteProgram. + /// + Main, + + /// + /// Hosted scope, i.e. scope with DLR Scope binding. + /// Used by Execute("code", scope). + /// + GlobalScopeBound, + + /// + /// Top scope is passed by parameter to the top-level lambda, it is not scope is created. + /// Used by eval("code"), eval("code", binding). + /// + None, + + /// + /// Creates a module scope with parent scope passed into the top-level lambda. + /// Used by module_eval("code")/instance_eval("code"). + /// + Module, + + /// + /// File executed via load(true). + /// + WrappedFile, + } + [Serializable] public sealed class RubyCompilerOptions : CompilerOptions { - // TODO: replace bool's by flags/enum + /// + /// Embedded code. The code being compiled is embedded into an already compiled code. + /// internal bool IsEval { get; set; } - internal bool IsModuleEval { get; set; } - internal bool IsIncluded { get; set; } - internal bool IsWrapped { get; set; } - + + internal TopScopeFactoryKind FactoryKind { get; set; } + private SourceLocation _initialLocation = SourceLocation.MinValue; internal SourceLocation InitialLocation { =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/SourceUnitTree.cs;C691193 File: SourceUnitTree.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/SourceUnitTree.cs;C691193 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/SourceUnitTree.cs;InitAndScopes6 @@ -80,7 +80,8 @@ MSA.Expression blockParameter; MSA.Expression currentMethodVariable; - if (gen.CompilerOptions.IsEval) { + if (gen.CompilerOptions.FactoryKind == TopScopeFactoryKind.None || + gen.CompilerOptions.FactoryKind == TopScopeFactoryKind.Module) { parameters = new MSA.ParameterExpression[6]; parameters[0] = Ast.Parameter(typeof(RubyScope), "#scope"); @@ -90,7 +91,7 @@ currentMethodVariable = parameters[4] = Ast.Parameter(typeof(RubyMethodInfo), "#method"); rfcVariable = parameters[5] = Ast.Parameter(typeof(RuntimeFlowControl), "#rfc"); - if (gen.CompilerOptions.IsModuleEval) { + if (gen.CompilerOptions.FactoryKind == TopScopeFactoryKind.Module) { runtimeScopeVariable = scope.DefineHiddenVariable("#scope", typeof(RubyScope)); parentScope = parameters[0]; moduleVariable = parameters[2]; @@ -129,21 +130,44 @@ MSA.Expression scopeFactoryCall; - if (gen.CompilerOptions.IsEval) { - if (gen.CompilerOptions.IsModuleEval) { + switch (gen.CompilerOptions.FactoryKind) { + case TopScopeFactoryKind.Default: + scopeFactoryCall = Methods.CreateTopLevelScope.OpCall( + scope.VisibleVariables(), parentScope, language, selfVariable, rfcVariable + ); + break; + + case TopScopeFactoryKind.GlobalScopeBound: + scopeFactoryCall = Methods.CreateTopLevelHostedScope.OpCall( + scope.VisibleVariables(), parentScope, language, selfVariable, rfcVariable + ); + break; + + case TopScopeFactoryKind.Main: + scopeFactoryCall = Methods.CreateMainTopLevelScope.OpCall( + scope.VisibleVariables(), parentScope, language, selfVariable, rfcVariable, + Ast.Constant(gen.SourceUnit.Path, typeof(string)), Ast.Constant(_dataOffset) + ); + break; + + case TopScopeFactoryKind.None: + scopeFactoryCall = null; + break; + + case TopScopeFactoryKind.Module: scopeFactoryCall = Methods.CreateModuleEvalScope.OpCall( scope.VisibleVariables(), parentScope, selfVariable, moduleVariable ); - } else { - scopeFactoryCall = null; - } - } else if (!gen.CompilerOptions.IsIncluded) { - scopeFactoryCall = Methods.CreateMainTopLevelScope.OpCall(scope.VisibleVariables(), parentScope, language, selfVariable, rfcVariable, - Ast.Constant(gen.SourceUnit.Path, typeof(string)), Ast.Constant(_dataOffset)); - } else if (gen.CompilerOptions.IsWrapped) { - scopeFactoryCall = Methods.CreateWrappedTopLevelScope.OpCall(scope.VisibleVariables(), parentScope, language, selfVariable, rfcVariable); - } else { - scopeFactoryCall = Methods.CreateTopLevelScope.OpCall(scope.VisibleVariables(), parentScope, language, selfVariable, rfcVariable); + break; + + case TopScopeFactoryKind.WrappedFile: + scopeFactoryCall = Methods.CreateWrappedTopLevelScope.OpCall( + scope.VisibleVariables(), parentScope, language, selfVariable, rfcVariable + ); + break; + + default: + throw Assert.Unreachable; } MSA.Expression prologue, body; =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyCommandLine.cs;C691193 File: RubyCommandLine.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyCommandLine.cs;C691193 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyCommandLine.cs;InitAndScopes6 @@ -32,7 +32,7 @@ protected override string Logo { get { - return String.Format("IronRuby {1} on .NET {2}{0}Copyright (c) Microsoft Corporation. All rights reserved.{0}{0}Note that local variables do not work today in the console.{0}As a workaround, use globals instead (eg $x = 42 instead of x = 42).{0}{0}", + return String.Format("IronRuby {1} on .NET {2}{0}Copyright (c) Microsoft Corporation. All rights reserved.{0}{0}", Environment.NewLine, RubyContext.IronRubyVersion, Environment.Version); } } =================================================================== delete: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/GlobalScopeExtension.cs;C633889 File: GlobalScopeExtension.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/GlobalScopeExtension.cs;C633889 (server) 1/6/2009 10:38 AM +++ [no target file] @@ -1,46 +1,0 @@ -/* **************************************************************************** - * - * Copyright (c) Microsoft Corporation. - * - * This source code is subject to terms and conditions of the Microsoft Public License. A - * copy of the license can be found in the License.html file at the root of this distribution. If - * you cannot locate the Microsoft Public License, please send an email to - * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound - * by the terms of the Microsoft Public License. - * - * You must not remove this notice, or any other, from this software. - * - * - * ***************************************************************************/ - -using Microsoft.Scripting.Runtime; -using Microsoft.Scripting.Utils; - -namespace IronRuby.Runtime { - public class GlobalScopeExtension : ScopeExtension { - private RubyContext/*!*/ _context; - private object/*!*/ _mainObject; - private bool _isHosted; - - public RubyContext/*!*/ Context { - get { return _context; } - set { _context = value; } - } - - public object/*!*/ MainObject { - get { return _mainObject; } - } - - public bool IsHosted { - get { return _isHosted; } - } - - public GlobalScopeExtension(RubyContext/*!*/ context, Scope/*!*/ globalScope, object/*!*/ mainObject, bool isHosted) - : base(globalScope) { - Assert.NotNull(context, globalScope, mainObject); - _context = context; - _mainObject = mainObject; - _isHosted = isHosted; - } - } -} =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Loader.cs;C674241 File: Loader.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Loader.cs;C674241 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Loader.cs;InitAndScopes6 @@ -229,8 +229,8 @@ /// /// Returns true if a Ruby file is successfully loaded, false if it is already loaded. /// - public bool LoadFile(Scope/*!*/ globalScope, object self, MutableString/*!*/ path, LoadFlags flags) { - Assert.NotNull(globalScope, path); + public bool LoadFile(Scope globalScope, object self, MutableString/*!*/ path, LoadFlags flags) { + Assert.NotNull(path); string assemblyName, typeName; @@ -335,10 +335,10 @@ } } - private bool LoadFromPath(Scope/*!*/ globalScope, object self, string/*!*/ path, LoadFlags flags) { - Assert.NotNull(globalScope, path); + private bool LoadFromPath(Scope globalScope, object self, string/*!*/ path, LoadFlags flags) { + Assert.NotNull(path); - ResolvedFile file = FindFile(globalScope, path, (flags & LoadFlags.AppendExtensions) != 0); + ResolvedFile file = FindFile(path, (flags & LoadFlags.AppendExtensions) != 0); if (file == null) { throw new LoadError(String.Format("no such file to load -- {0}", path)); } @@ -382,21 +382,24 @@ return true; } - private void ExecuteRubySourceUnit(SourceUnit/*!*/ sourceUnit, Scope/*!*/ globalScope, LoadFlags flags) { - Assert.NotNull(sourceUnit, globalScope); + private void ExecuteRubySourceUnit(SourceUnit/*!*/ sourceUnit, Scope globalScope, LoadFlags flags) { + Assert.NotNull(sourceUnit); // TODO: check file timestamp string fullPath = Platform.GetFullPath(sourceUnit.Path); CompiledFile compiledFile; if (TryGetCompiledFile(fullPath, out compiledFile)) { Utils.Log(String.Format("{0}: {1}", ++_cacheHitCount, sourceUnit.Path), "LOAD_CACHED"); - compiledFile.CompiledCode.Run(globalScope); + if (globalScope != null) { + compiledFile.CompiledCode.Run(globalScope); + } else { + compiledFile.CompiledCode.Run(); + } } else { Utils.Log(String.Format("{0}: {1}", ++_compiledFileCount, sourceUnit.Path), "LOAD_COMPILED"); RubyCompilerOptions options = new RubyCompilerOptions(_context.RubyOptions) { - IsIncluded = true, - IsWrapped = (flags & LoadFlags.LoadIsolated) != 0, + FactoryKind = (flags & LoadFlags.LoadIsolated) != 0 ? TopScopeFactoryKind.WrappedFile : TopScopeFactoryKind.Default }; long ts1 = Stopwatch.GetTimestamp(); @@ -410,16 +413,16 @@ } } - internal object CompileAndRun(Scope/*!*/ globalScope, ScriptCode/*!*/ code, bool tryEvaluate) { + internal object CompileAndRun(Scope globalScope, ScriptCode/*!*/ code, bool tryEvaluate) { long ts1 = Stopwatch.GetTimestamp(); code.EnsureCompiled(); long ts2 = Stopwatch.GetTimestamp(); Interlocked.Add(ref _ILGenerationTimeTicks, ts2 - ts1); - return code.Run(globalScope); + return globalScope != null ? code.Run(globalScope) : code.Run(); } - private ResolvedFile FindFile(Scope/*!*/ globalScope, string/*!*/ path, bool appendExtensions) { + private ResolvedFile FindFile(string/*!*/ path, bool appendExtensions) { Assert.NotNull(path); bool isAbsolutePath; string extension; =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyContext.cs;C691193 File: RubyContext.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyContext.cs;C691193 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyContext.cs;InitAndScopes6 @@ -246,11 +246,6 @@ get { return _emptyScope; } } - // TODO: - internal Scope/*!*/ DefaultGlobalScope { - get { return DomainManager.Globals; } - } - public Exception CurrentException { get { return _currentException; } set { _currentException = RubyOps.GetVisibleException(value); } @@ -1060,7 +1055,7 @@ return GetImmediateClassOf(target).ResolveSuperMethod(name, declaringModule); } - public bool TryGetModule(Scope autoloadScope, string/*!*/ moduleName, out RubyModule result) { + public bool TryGetModule(RubyGlobalScope autoloadScope, string/*!*/ moduleName, out RubyModule result) { result = _objectClass; int pos = 0; while (true) { @@ -1077,7 +1072,7 @@ result = null; return false; } - result = (tmp as RubyModule); + result = tmp as RubyModule; if (result == null) { return false; } else if (pos2 < 0) { @@ -1696,9 +1691,24 @@ } public override CompilerOptions/*!*/ GetCompilerOptions() { - return new RubyCompilerOptions(_options); + return new RubyCompilerOptions(_options) { + FactoryKind = TopScopeFactoryKind.Default + }; } + public override CompilerOptions/*!*/ GetCompilerOptions(Scope/*!*/ scope) { + var result = new RubyCompilerOptions(_options) { + FactoryKind = TopScopeFactoryKind.GlobalScopeBound + }; + + var rubyGlobalScope = (RubyGlobalScope)scope.GetExtension(ContextId); + if (rubyGlobalScope != null && rubyGlobalScope.TopLocalScope != null) { + result.LocalNames = rubyGlobalScope.TopLocalScope.GetVisibleLocalNames(); + } + + return result; + } + public override ErrorSink GetCompilerErrorSink() { return _runtimeErrorSink; } @@ -1708,59 +1718,41 @@ #region Global Scope /// - /// Creates a scope extension for DLR scopes that haven't been created by Ruby. - /// These scopes adds method_missing and const_missing methods to handle lookups to the DLR scope. + /// Creates a scope extension for a DLR scope unless it already exists for the given scope. /// - internal GlobalScopeExtension/*!*/ InitializeGlobalScope(Scope/*!*/ globalScope) { + internal RubyGlobalScope/*!*/ InitializeGlobalScope(Scope/*!*/ globalScope, bool createHosted) { Assert.NotNull(globalScope); var scopeExtension = globalScope.GetExtension(ContextId); if (scopeExtension != null) { - return (GlobalScopeExtension)scopeExtension; + return (RubyGlobalScope)scopeExtension; } object mainObject = new Object(); RubyClass singletonClass = CreateMainSingleton(mainObject); - // method_missing: - singletonClass.SetMethodNoEvent(this, Symbols.MethodMissing, new RubyMethodGroupInfo(new Delegate[] { - new Func(RubyTopLevelScope.TopMethodMissing) - }, RubyMemberFlags.Private, singletonClass)); + RubyGlobalScope result = new RubyGlobalScope(this, globalScope, mainObject, createHosted); + globalScope.SetExtension(ContextId, result); + + if (createHosted) { + // method_missing: + singletonClass.SetMethodNoEvent(this, Symbols.MethodMissing, new RubyMethodGroupInfo(new Delegate[] { + new Func(RubyTopLevelScope.TopMethodMissing) + }, RubyMemberFlags.Private, singletonClass)); + + singletonClass.SetGlobalScope(result); + } - // TODO: - // TOPLEVEL_BINDING: - //singletonClass.SetMethod(Symbols.MethodMissing, new RubyMethodGroupInfo(new Delegate[] { - // new Func(RubyScope.GetTopLevelBinding) - //}, RubyMethodVisibility.Private, singletonClass, false)); - - GlobalScopeExtension result = new GlobalScopeExtension(this, globalScope, mainObject, true); - singletonClass.SetGlobalScope(result); - - globalScope.SetExtension(ContextId, result); return result; } - // - // Create a scope extension for Ruby program/file. - // - internal GlobalScopeExtension/*!*/ CreateScopeExtensionForProgram(Scope/*!*/ globalScope) { - Assert.NotNull(globalScope); - - object mainObject = new Object(); - CreateMainSingleton(mainObject); - - return new GlobalScopeExtension(this, globalScope, mainObject, false); - } - public override int ExecuteProgram(SourceUnit/*!*/ program) { try { - RubyCompilerOptions options = new RubyCompilerOptions(_options); - ScriptCode compiledCode = CompileSourceCode(program, options, _runtimeErrorSink); + RubyCompilerOptions options = new RubyCompilerOptions(_options) { + FactoryKind = TopScopeFactoryKind.Main + }; - Scope scope = new Scope(); - scope.SetExtension(ContextId, CreateScopeExtensionForProgram(scope)); - - compiledCode.Run(scope); + CompileSourceCode(program, options, _runtimeErrorSink).Run(); } catch (SystemExit e) { return e.Status; } =================================================================== branch, edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyGlobalScope.cs File: RubyGlobalScope.cs =================================================================== --- GlobalScopeExtension.cs (server) 1/6/2009 10:25 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyGlobalScope.cs;InitAndScopes6 @@ -17,9 +17,10 @@ using Microsoft.Scripting.Utils; namespace IronRuby.Runtime { - public class GlobalScopeExtension : ScopeExtension { + public class RubyGlobalScope : ScopeExtension { private RubyContext/*!*/ _context; private object/*!*/ _mainObject; + private RubyTopLevelScope _topLocalScope; private bool _isHosted; public RubyContext/*!*/ Context { @@ -35,9 +36,14 @@ get { return _isHosted; } } - public GlobalScopeExtension(RubyContext/*!*/ context, Scope/*!*/ globalScope, object/*!*/ mainObject, bool isHosted) - : base(globalScope) { - Assert.NotNull(context, globalScope, mainObject); + internal RubyTopLevelScope TopLocalScope { + get { return _topLocalScope; } + set { _topLocalScope = value; } + } + + public RubyGlobalScope(RubyContext/*!*/ context, Scope/*!*/ scope, object/*!*/ mainObject, bool isHosted) + : base(scope) { + Assert.NotNull(context, scope, mainObject); _context = context; _mainObject = mainObject; _isHosted = isHosted; =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyOps.cs;C691193 File: RubyOps.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyOps.cs;C691193 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyOps.cs;InitAndScopes6 @@ -53,28 +53,25 @@ out object self, out RuntimeFlowControl/*!*/ rfc, string dataPath, int dataOffset) { Assert.NotNull(locals, globalScope, language); - GlobalScopeExtension rubyGlobalScope = ((RubyContext)language).InitializeGlobalScope(globalScope); + 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(rubyGlobalScope.IsHosted ? "top-primary-hosted" : "top-primary"); + scope.SetDebugName("top-main"); - // 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; - } + var objectClass = context.ObjectClass; + objectClass.SetConstant("TOPLEVEL_BINDING", new Binding(scope)); + if (dataOffset >= 0) { + RubyFile dataFile; + if (File.Exists(dataPath)) { + dataFile = new RubyFile(context, dataPath, RubyFileMode.RDONLY); + dataFile.Seek(dataOffset, SeekOrigin.Begin); + } else { + dataFile = null; + } - objectClass.SetConstant("DATA", dataFile); - } + objectClass.SetConstant("DATA", dataFile); } self = scope.SelfObject; @@ -84,10 +81,37 @@ } [Emitted] + 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; + } + + [Emitted] public static RubyTopLevelScope/*!*/ CreateTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language, out object self, out RuntimeFlowControl/*!*/ rfc) { - RubyTopLevelScope scope = CreateTopLevelScopeInternal(locals, globalScope, (RubyContext)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-level"); + self = scope.SelfObject; rfc = scope.RuntimeFlowControl; return scope; @@ -97,14 +121,18 @@ public static RubyTopLevelScope/*!*/ CreateWrappedTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language, out object self, out RuntimeFlowControl/*!*/ rfc) { - RubyTopLevelScope scope = CreateTopLevelScopeInternal(locals, globalScope, (RubyContext)language); + RubyContext context = (RubyContext)language; - RubyModule module = scope.RubyGlobalScope.Context.CreateModule(null, null, null, null, null); - object mainObject = new Object(); - RubyClass mainSingleton = scope.RubyContext.CreateMainSingleton(mainObject); + RubyClass mainSingleton = context.CreateMainSingleton(mainObject); + + RubyModule module = context.CreateModule(null, null, null, null, null); mainSingleton.SetMixins(new RubyModule[] { 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); @@ -113,19 +141,9 @@ return scope; } - private static RubyTopLevelScope/*!*/ CreateTopLevelScopeInternal(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, RubyContext/*!*/ context) { - GlobalScopeExtension rubyGlobalScope = context.InitializeGlobalScope(globalScope); - RubyTopLevelScope result = new RubyTopLevelScope(rubyGlobalScope, null, locals); - result.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject); - result.SetDebugName("top-level"); - - return result; - } - [Emitted] public static RubyModuleScope/*!*/ CreateModuleEvalScope(LocalsDictionary/*!*/ locals, RubyScope/*!*/ parent, object self, RubyModule module) { RubyModuleScope scope = new RubyModuleScope(parent, locals, module, true); - // TODO: used to inherit parent.MethodAttributes scope.Initialize(parent.RuntimeFlowControl, RubyMethodAttributes.PublicInstance, self); scope.SetDebugName("top-module/instance-eval"); return scope; @@ -475,7 +493,7 @@ [Emitted] // MethodDeclaration: public static RubyMethodInfo/*!*/ DefineMethod(object targetOrSelf, object/*!*/ ast, RubyScope/*!*/ scope, - bool hasTarget, string/*!*/ name, Delegate/*!*/ clrMethod, int mandatory, int optional, bool hasUnsplatParameter) { + bool hasTarget, string/*!*/ name, Delegate/*!*/ clrMethod, int mandatory, int optional, bool hasUnsplatParameter) { Assert.NotNull(ast, scope, clrMethod, name); @@ -661,7 +679,7 @@ [Emitted] // ConstantVariable: public static object GetGlobalConstant(RubyScope/*!*/ scope, string/*!*/ name) { - return RubyUtils.GetConstant(scope, scope.RubyContext.ObjectClass, name, false); + return RubyUtils.GetConstant(scope.GlobalScope, scope.RubyContext.ObjectClass, name, false); } [Emitted] // ConstantVariable: @@ -671,7 +689,7 @@ [Emitted] // ConstantVariable: public static object GetQualifiedConstant(object target, RubyScope/*!*/ scope, string/*!*/ name) { - return RubyUtils.GetConstant(scope, RubyUtils.GetModuleFromObject(scope.RubyContext, target), name, false); + return RubyUtils.GetConstant(scope.GlobalScope, RubyUtils.GetModuleFromObject(scope.RubyContext, target), name, false); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyScope.cs;C669880 File: RubyScope.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyScope.cs;C669880 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyScope.cs;InitAndScopes6 @@ -78,8 +78,8 @@ get { return _runtimeFlowControl; } } - public Scope GlobalScope { - get { return _top.RubyGlobalScope.Scope; } + public RubyGlobalScope/*!*/ GlobalScope { + get { return _top.RubyGlobalScope; } } public RubyTopLevelScope/*!*/ Top { @@ -261,8 +261,13 @@ } internal RubyModule/*!*/ GetMethodDefinitionOwner() { + // MRI 1.9: skips all module_eval and define_method blocks. + // MRI 1.8: skips module_eval and define_method blocks above method scope. + if (RubyContext.RubyOptions.Compatibility == RubyCompatibility.Ruby19) { + return GetInnerMostModule(); + } + RubyScope scope = this; - bool skipBlocks = false; while (true) { Debug.Assert(scope != null); @@ -275,17 +280,12 @@ return scope.Module; case ScopeKind.Method: - // MRI 1.8: skips module_evals above - // MRI 1.9: just continue search for a module or module_eval - skipBlocks = RubyContext.RubyOptions.Compatibility == RubyCompatibility.Ruby18; - break; + return scope.GetInnerMostModule(); case ScopeKind.Block: - if (!skipBlocks) { - BlockParam blockParam = ((RubyBlockScope)scope).BlockParameter; - if (blockParam.ModuleDeclaration != null) { - return blockParam.ModuleDeclaration; - } + BlockParam blockParam = ((RubyBlockScope)scope).BlockParameter; + if (blockParam.ModuleDeclaration != null) { + return blockParam.ModuleDeclaration; } break; } @@ -307,7 +307,7 @@ } public bool TryResolveConstant(bool autoload, string/*!*/ name, out object result) { - Scope autoloadScope = autoload ? GlobalScope : null; + RubyGlobalScope autoloadScope = autoload ? GlobalScope : null; RubyScope scope = this; // lexical lookup first: @@ -568,11 +568,11 @@ public override ScopeKind Kind { get { return ScopeKind.TopLevel; } } public override bool InheritsLocalVariables { get { return false; } } - private readonly GlobalScopeExtension/*!*/ _globalScope; + private readonly RubyGlobalScope/*!*/ _globalScope; private readonly RubyContext/*!*/ _context; private RubyModule _definitionsModule; - public GlobalScopeExtension/*!*/ RubyGlobalScope { + public RubyGlobalScope/*!*/ RubyGlobalScope { get { if (_globalScope == null) { throw new InvalidOperationException("Empty scope has no global scope."); @@ -603,41 +603,39 @@ _context = context; } - internal RubyTopLevelScope(GlobalScopeExtension/*!*/ globalScope, RubyModule definitionsModule, IAttributesCollection/*!*/ frame) + internal RubyTopLevelScope(RubyGlobalScope/*!*/ globalScope, RubyModule definitionsModule, IAttributesCollection/*!*/ frame) : base(frame) { Assert.NotNull(globalScope); _globalScope = globalScope; _context = globalScope.Context; _definitionsModule = definitionsModule; } - - // TODO: might be called by MI.Invoke -> needs to be public in partial trust - // method_missing on top-level DLR created scope: + + // method_missing on main singleton in DLR Scope bound code. + // Might be called via a site -> needs to be public in partial trust. public static object TopMethodMissing(RubyScope/*!*/ scope, BlockParam block, object/*!*/ self, SymbolId name, [NotNull]params object[]/*!*/ args) { Assert.NotNull(scope, self); Debug.Assert(!scope.IsEmpty); - Scope globalScope = scope.GlobalScope; + Scope globalScope = scope.GlobalScope.Scope; Debug.Assert(globalScope != null); // TODO: error when arguments non-empty, block != null, ... + // TODO: name-mangling - object value; - if (globalScope.TryGetName(name, out value)) { - return value; + if (args.Length == 0) { + object value; + if (globalScope.TryGetName(name, out value)) { + return value; + } + } else if (args.Length == 1) { + string str = SymbolTable.IdToString(name); + if (str.Length > 0 && str[str.Length - 1] == '=') { + SymbolId plainName = SymbolTable.StringToId(str.Substring(0, str.Length - 1)); + globalScope.SetName(plainName, args[0]); + return args[0]; + } } - // TODO: assignment - //if (args.Length == 1) { - // string str = SymbolTable.IdToString(name); - // if (str.Length > 0 && str[str.Length - 1] == '=') { - // SymbolId plainName = SymbolTable.StringToId(str.Substring(0, str.Length - 1)); - // if (globalScope.ContainsName(plainName)) { - // globalScope.SetName(plainName, args[0]); - // } - // return value; - // } - //} - // TODO: call super throw RubyExceptions.CreateMethodMissing(scope.RubyContext, self, SymbolTable.IdToString(name)); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs;C674241 File: RubyUtils.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs;C674241 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs;InitAndScopes6 @@ -418,21 +418,21 @@ #region Constants, Methods - public static object GetConstant(RubyScope/*!*/ scope, RubyModule/*!*/ owner, string/*!*/ name, bool lookupObject) { - Assert.NotNull(scope, owner, name); + public static object GetConstant(RubyGlobalScope/*!*/ globalScope, RubyModule/*!*/ owner, string/*!*/ name, bool lookupObject) { + Assert.NotNull(globalScope, owner, name); object result; - if (owner.TryResolveConstant(scope.GlobalScope, name, out result)) { + if (owner.TryResolveConstant(globalScope, name, out result)) { return result; } RubyClass objectClass = owner.Context.ObjectClass; - if (owner != objectClass && lookupObject && objectClass.TryResolveConstant(scope.GlobalScope, name, out result)) { + if (owner != objectClass && lookupObject && objectClass.TryResolveConstant(globalScope, name, out result)) { return result; } CheckConstantName(name); - return RubySites.ModuleConstMissing(scope.RubyContext, owner, name); + return RubySites.ModuleConstMissing(globalScope.Context, owner, name); } public static void SetConstant(RubyModule/*!*/ owner, string/*!*/ name, object value) { @@ -464,7 +464,7 @@ #region Modules, Classes - internal static RubyModule/*!*/ DefineModule(Scope/*!*/ autoloadScope, RubyModule/*!*/ owner, string/*!*/ name) { + internal static RubyModule/*!*/ DefineModule(RubyGlobalScope/*!*/ autoloadScope, RubyModule/*!*/ owner, string/*!*/ name) { Assert.NotNull(autoloadScope, owner); object existing; @@ -480,7 +480,7 @@ } } - internal static RubyClass/*!*/ DefineClass(Scope/*!*/ autoloadScope, RubyModule/*!*/ owner, string/*!*/ name, object superClassObject) { + internal static RubyClass/*!*/ DefineClass(RubyGlobalScope/*!*/ autoloadScope, RubyModule/*!*/ owner, string/*!*/ name, object superClassObject) { Assert.NotNull(owner); RubyClass superClass = ToSuperClass(owner.Context, superClassObject); @@ -659,7 +659,7 @@ return new RubyCompilerOptions(targetScope.RubyContext.RubyOptions) { IsEval = true, - IsModuleEval = isModuleEval, + FactoryKind = isModuleEval ? TopScopeFactoryKind.Module : TopScopeFactoryKind.None, LocalNames = targetScope.GetVisibleLocalNames(), TopLevelMethodName = (methodScope != null) ? methodScope.Method.DefinitionName : null, InitialLocation = new SourceLocation(0, line <= 0 ? 1 : line, 1), =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/MetaObjectBuilder.cs;C669880 File: MetaObjectBuilder.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/MetaObjectBuilder.cs;C669880 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/MetaObjectBuilder.cs;InitAndScopes6 @@ -52,6 +52,12 @@ public ParameterExpression BfcVariable { get; set; } + /// + /// A rule builder sets this up if the resulting rule is required to be wrapped in a non-local control flow handler. + /// This delegate must be called exactly once ( method). + /// + public Action ControlFlowBuilder { get; set; } + public bool TreatRestrictionsAsConditions { get { return _treatRestrictionsAsConditions; } set { _treatRestrictionsAsConditions = value; } @@ -62,6 +68,8 @@ } internal DynamicMetaObject/*!*/ CreateMetaObject(DynamicMetaObjectBinder/*!*/ action, DynamicMetaObject/*!*/[]/*!*/ siteArgs) { + Debug.Assert(ControlFlowBuilder == null, "Control flow required but not built"); + var expr = _error ? Ast.Throw(_result) : _result; BindingRestrictions restrictions; @@ -252,5 +260,12 @@ _temps.Add(variable); return variable; } + + public void BuildControlFlow(CallArguments/*!*/ args) { + if (ControlFlowBuilder != null) { + ControlFlowBuilder(this, args); + ControlFlowBuilder = null; + } + } } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyCustomMethodInfo.cs;C651054 File: RubyCustomMethodInfo.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyCustomMethodInfo.cs;C651054 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyCustomMethodInfo.cs;InitAndScopes6 @@ -33,10 +33,6 @@ _ruleGenerator(metaBuilder, args, name); } - internal override void ApplyBlockFlowHandling(MetaObjectBuilder metaBuilder, CallArguments args) { - // nop - } - protected internal override RubyMemberInfo/*!*/ Copy(RubyMemberFlags flags, RubyModule/*!*/ module) { return new RubyCustomMethodInfo(_ruleGenerator, flags, module); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMemberInfo.cs;C651054 File: RubyMemberInfo.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMemberInfo.cs;C651054 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMemberInfo.cs;InitAndScopes6 @@ -106,22 +106,18 @@ throw Assert.Unreachable; } - internal virtual void ApplyBlockFlowHandling(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args) { - // nop - } - internal void BuildCall(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name) { BuildCallNoFlow(metaBuilder, args, name); - ApplyBlockFlowHandling(metaBuilder, args); + metaBuilder.BuildControlFlow(args); } internal virtual void BuildSuperCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name, RubyModule/*!*/ declaringModule) { BuildCallNoFlow(metaBuilder, args, name); } - internal virtual void BuildSuperCall(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name, RubyModule/*!*/ declaringModule) { + internal void BuildSuperCall(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name, RubyModule/*!*/ declaringModule) { BuildSuperCallNoFlow(metaBuilder, args, name, declaringModule); - ApplyBlockFlowHandling(metaBuilder, args); + metaBuilder.BuildControlFlow(args); } } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMethodGroupInfo.cs;C672727 File: RubyMethodGroupInfo.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMethodGroupInfo.cs;C672727 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMethodGroupInfo.cs;InitAndScopes6 @@ -258,9 +258,12 @@ // Allocates a variable holding BlockParam. At runtime the BlockParam is created with a new RFC instance that // identifies the library method frame as a proc-converter target of a method unwinder triggered by break from a block. // - // NOTE: We check for null block here -> test fore that fact is added in MakeActualArgs - if (metaBuilder.BfcVariable == null && args.Signature.HasBlock && args.GetBlock() != null && calleeHasBlockParam) { - metaBuilder.BfcVariable = metaBuilder.GetTemporary(typeof(BlockParam), "#bfc"); + // NOTE: We check for null block here -> test for that fact is added in MakeActualArgs + if (args.Signature.HasBlock && args.GetBlock() != null && calleeHasBlockParam) { + if (metaBuilder.BfcVariable == null) { + metaBuilder.BfcVariable = metaBuilder.GetTemporary(typeof(BlockParam), "#bfc"); + } + metaBuilder.ControlFlowBuilder = RuleControlFlowBuilder; } var actualArgs = MakeActualArgs(metaBuilder, args, includeSelf, selfIsInstance, calleeHasBlockParam, true); @@ -279,15 +282,11 @@ } } - internal override void ApplyBlockFlowHandling(MetaObjectBuilder metaBuilder, CallArguments args) { - ApplyBlockFlowHandlingInternal(metaBuilder, args); - } - /// /// Takes current result and wraps it into try-filter(MethodUnwinder)-finally block that ensures correct "break" behavior for /// library method calls with block given in bfcVariable (BlockParam). /// - internal static void ApplyBlockFlowHandlingInternal(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args) { + public static void RuleControlFlowBuilder(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args) { if (metaBuilder.Error) { return; } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMethodInfo.cs;C656583 File: RubyMethodInfo.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMethodInfo.cs;C656583 (server) 1/6/2009 10:01 AM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/RubyMethodInfo.cs;InitAndScopes6 @@ -105,6 +105,9 @@ internal override void BuildCallNoFlow(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args, string/*!*/ name) { Assert.NotNull(metaBuilder, args, name); + // any user method can yield to a block (regardless of whether block parameter is present or not): + metaBuilder.ControlFlowBuilder = RuleControlFlowBuilder; + // 2 implicit args: self, block var argsBuilder = new ArgsBuilder(2, _mandatoryParamCount, _optionalParamCount, _hasUnsplatParameter); argsBuilder.SetImplicit(0, AstFactory.Box(args.TargetExpression)); @@ -133,17 +136,13 @@ } } - internal override void ApplyBlockFlowHandling(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args) { - ApplyBlockFlowHandlingInternal(metaBuilder, args); - } - /// /// Takes current result and wraps it into try-filter(MethodUnwinder)-finally block that ensures correct "break" behavior for /// Ruby method calls with a block given in arguments. /// /// Sets up a RFC frame similarly to MethodDeclaration. /// - internal static void ApplyBlockFlowHandlingInternal(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args) { + public static void RuleControlFlowBuilder(MetaObjectBuilder/*!*/ metaBuilder, CallArguments/*!*/ args) { // TODO (improvement): // We don't special case null block here, although we could (we would need a test for that then). // We could also statically know (via call-site flag) that the current method is not a proc-converter (passed by ref), ===================================================================