Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

syncing to head of tfs. Changes IronRuby to version 0.3

  • Loading branch information...
commit cd988456fb3d102da84056e8e150d5376284cc8e 1 parent be5ccb7
Jim Deville jredville authored

Showing 43 changed files with 859 additions and 142 deletions. Show diff stats Hide diff stats

  1. +1 1  Merlin/External/Languages/IronRuby/mspec/rubyspec/core/file/expand_path_spec.rb
  2. +1 1  Merlin/Main/Config/Signed/App.config
  3. +1 1  Merlin/Main/Config/Unsigned/App.config
  4. +1 1  Merlin/Main/Languages/IronPython/IronPython/Compiler/PythonGlobalVariableExpression.cs
  5. +9 2 Merlin/Main/Languages/IronPython/IronPython/Runtime/Operations/ScopeOps.cs
  6. +11 11 Merlin/Main/Languages/IronPython/IronPython/Runtime/Operations/StringOps.cs
  7. +27 7 Merlin/Main/Languages/Ruby/IronRuby.Tests/Driver.cs
  8. +1 1  Merlin/Main/Languages/Ruby/IronRuby.Tests/Helpers.cs
  9. +2 2 Merlin/Main/Languages/Ruby/IronRuby.Tests/Parser/ParserTests.cs
  10. +4 3 Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/BacktraceTests.cs
  11. +4 4 Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/LoaderTests.cs
  12. +1 1  Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs
  13. +3 3 Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Protocols.cs
  14. +1 1  Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyClass.cs
  15. +8 0 Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs
  16. +4 3 Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/BlockDefinition.cs
  17. +1 2  Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Declarations/MethodDeclaration.cs
  18. BIN  Merlin/Main/Languages/Ruby/Ruby/Ruby.Build.csproj
  19. +4 0 Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj
  20. +10 8 Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/BlockDispatcher.cs
  21. +0 8 Merlin/Main/Languages/Ruby/Ruby/Runtime/Loader.cs
  22. +13 7 Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyContext.cs
  23. +15 1 Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyExceptionData.cs
  24. +65 0 Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyMethodDebugInfo.cs
  25. +94 0 Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyScriptCode.cs
  26. +1 1  Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs
  27. +2 2 Merlin/Main/Languages/Ruby/Utils/IronRuby.Libraries.Scanner/Program.cs
  28. +22 4 Merlin/Main/Runtime/Microsoft.Scripting/Generation/CompilerHelpers.cs
  29. +1 1  Merlin/Main/Runtime/Microsoft.Scripting/Runtime/LanguageContext.cs
  30. +39 11 ndp/fx/src/Core/Microsoft/Scripting/Ast/LambdaExpression.cs
  31. +2 10 ndp/fx/src/Core/Microsoft/Scripting/Compiler/AnalyzedTree.cs
  32. +4 4 ndp/fx/src/Core/Microsoft/Scripting/Compiler/CompilerScope.Storage.cs
  33. +56 0 ndp/fx/src/Core/Microsoft/Scripting/Compiler/DebugInfoGenerator.cs
  34. +2 0  ndp/fx/src/Core/Microsoft/Scripting/Compiler/ILGen.cs
  35. +2 0  ndp/fx/src/Core/Microsoft/Scripting/Compiler/LabelInfo.cs
  36. +3 17 ndp/fx/src/Core/Microsoft/Scripting/Compiler/LambdaCompiler.Expressions.cs
  37. +1 1  ndp/fx/src/Core/Microsoft/Scripting/Compiler/LambdaCompiler.Lambda.cs
  38. +1 1  ndp/fx/src/Core/Microsoft/Scripting/Compiler/LambdaCompiler.Statements.cs
  39. +21 13 ndp/fx/src/Core/Microsoft/Scripting/Compiler/LambdaCompiler.cs
  40. +357 0 ndp/fx/src/Core/Microsoft/Scripting/Compiler/OffsetTrackingILGenerator.cs
  41. +61 0 ndp/fx/src/Core/Microsoft/Scripting/Compiler/SymbolDocumentGenerator.cs
  42. +3 0  ndp/fx/src/Core/Microsoft/Scripting/Microsoft.Scripting.Core.csproj
  43. +0 9 ndp/fx/src/Core/Microsoft/Scripting/Utils/ExceptionFactory.Generated.cs
2  Merlin/External/Languages/IronRuby/mspec/rubyspec/core/file/expand_path_spec.rb
@@ -40,7 +40,7 @@
40 40 end
41 41
42 42 # FIXME: do not use conditionals like this around #it blocks
43   - unless not home = ENV['HOME']
  43 + unless not home = ENV['HOME'].tr('\\', '/')
44 44 it "converts a pathname to an absolute pathname, using ~ (home) as base" do
45 45 File.expand_path('~').should == home
46 46 File.expand_path('~', '/tmp/gumby/ddd').should == home
2  Merlin/Main/Config/Signed/App.config
@@ -7,7 +7,7 @@
7 7 <microsoft.scripting>
8 8 <languages>
9 9 <language names="IronPython;Python;py" extensions=".py" displayName="IronPython 2.6 Alpha" type="IronPython.Runtime.PythonContext, IronPython, Version=2.6.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
10   - <language names="IronRuby;Ruby;rb" extensions=".rb" displayName="IronRuby 1.0 Alpha" type="IronRuby.Runtime.RubyContext, IronRuby, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  10 + <language names="IronRuby;Ruby;rb" extensions=".rb" displayName="IronRuby 0.3" type="IronRuby.Runtime.RubyContext, IronRuby, Version=0.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
11 11 <language names="ToyScript;ts" extensions=".ts" type="ToyScript.ToyLanguageContext, ToyScript, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
12 12 </languages>
13 13
2  Merlin/Main/Config/Unsigned/App.config
@@ -7,7 +7,7 @@
7 7 <microsoft.scripting>
8 8 <languages>
9 9 <language names="IronPython;Python;py" extensions=".py" displayName="IronPython 2.6 Alpha" type="IronPython.Runtime.PythonContext, IronPython, Version=2.6.0.1, Culture=neutral, PublicKeyToken=null" />
10   - <language names="IronRuby;Ruby;rb" extensions=".rb" displayName="IronRuby 1.0 Alpha" type="IronRuby.Runtime.RubyContext, IronRuby, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
  10 + <language names="IronRuby;Ruby;rb" extensions=".rb" displayName="IronRuby 0.3" type="IronRuby.Runtime.RubyContext, IronRuby, Version=0.3.0.0, Culture=neutral, PublicKeyToken=null" />
11 11 <language names="ToyScript;ts" extensions=".ts" type="ToyScript.ToyLanguageContext, ToyScript, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
12 12 </languages>
13 13
2  Merlin/Main/Languages/IronPython/IronPython/Compiler/PythonGlobalVariableExpression.cs
@@ -267,7 +267,7 @@ class LookupGlobalInstruction : Instruction {
267 267 _name = SymbolTable.StringToId(name);
268 268 _isLocal = isLocal;
269 269 }
270   -
  270 + public override int ConsumedStack { get { return 1; } }
271 271 public override int ProducedStack { get { return 1; } }
272 272 public override int Run(StackFrame frame) {
273 273 if (_isLocal) {
11 Merlin/Main/Languages/IronPython/IronPython/Runtime/Operations/ScopeOps.cs
@@ -59,14 +59,21 @@ public static class ScopeOps {
59 59 }
60 60 }
61 61
62   - public static object __getattribute__(Scope/*!*/ self, string name) {
  62 + public static object __getattribute__(CodeContext/*!*/ context, Scope/*!*/ self, string name) {
  63 + switch (name) {
  64 + // never look in the dict for these...
  65 + case "__dict__": return Get__dict__(self);
  66 + case "__class__": return DynamicHelpers.GetPythonType(self);
  67 + }
  68 +
63 69 SymbolId si = SymbolTable.StringToId(name);
64 70 object res;
65 71 if (self.TryGetName(si, out res)) {
66 72 return res;
67 73 }
68 74
69   - throw PythonOps.AttributeErrorForMissingAttribute("module", si);
  75 + // fall back to object to provide all of our other attributes (e.g. __setattr__, etc...)
  76 + return ObjectOps.__getattribute__(context, self, name);
70 77 }
71 78
72 79 public static void __setattr__(Scope/*!*/ self, string name, object value) {
22 Merlin/Main/Languages/IronPython/IronPython/Runtime/Operations/StringOps.cs
@@ -179,7 +179,7 @@ public static class StringOps {
179 179 if (cls == TypeCache.String) {
180 180 return FastNew(context, @object);
181 181 } else {
182   - return cls.CreateInstance(context, @object);
  182 + return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
183 183 }
184 184 }
185 185
@@ -197,7 +197,7 @@ public static class StringOps {
197 197 if (cls == TypeCache.String) {
198 198 return FastNew(context, @object);
199 199 } else {
200   - return cls.CreateInstance(context, @object);
  200 + return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
201 201 }
202 202 }
203 203
@@ -206,7 +206,7 @@ public static class StringOps {
206 206 if (cls == TypeCache.String) {
207 207 return CheckAsciiString(context, ScriptingRuntimeHelpers.CharToString(@object));
208 208 } else {
209   - return cls.CreateInstance(context, @object);
  209 + return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
210 210 }
211 211 }
212 212
@@ -215,7 +215,7 @@ public static class StringOps {
215 215 if (cls == TypeCache.String) {
216 216 return @object.ToString();
217 217 } else {
218   - return cls.CreateInstance(context, @object);
  218 + return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
219 219 }
220 220 }
221 221
@@ -224,7 +224,7 @@ public static class StringOps {
224 224 if (cls == TypeCache.String) {
225 225 return FastNew(context, @object);
226 226 } else {
227   - return cls.CreateInstance(context, @object);
  227 + return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
228 228 }
229 229 }
230 230
@@ -233,7 +233,7 @@ public static class StringOps {
233 233 if (cls == TypeCache.String) {
234 234 return @object.ToString();
235 235 } else {
236   - return cls.CreateInstance(context, @object);
  236 + return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
237 237 }
238 238 }
239 239
@@ -242,7 +242,7 @@ public static class StringOps {
242 242 if (cls == TypeCache.String) {
243 243 return @object.ToString();
244 244 } else {
245   - return cls.CreateInstance(context, @object);
  245 + return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
246 246 }
247 247 }
248 248
@@ -251,7 +251,7 @@ public static class StringOps {
251 251 if (cls == TypeCache.String) {
252 252 return DoubleOps.__str__(context, @object);
253 253 } else {
254   - return cls.CreateInstance(context, @object);
  254 + return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
255 255 }
256 256 }
257 257
@@ -260,7 +260,7 @@ public static class StringOps {
260 260 if (cls == TypeCache.String) {
261 261 return FastNew(context, @object);
262 262 } else {
263   - return cls.CreateInstance(context, @object);
  263 + return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
264 264 }
265 265 }
266 266
@@ -269,7 +269,7 @@ public static class StringOps {
269 269 if (cls == TypeCache.String) {
270 270 return SingleOps.__str__(context, @object);
271 271 } else {
272   - return cls.CreateInstance(context, @object);
  272 + return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
273 273 }
274 274 }
275 275
@@ -285,7 +285,7 @@ public static class StringOps {
285 285 if (cls == TypeCache.String) {
286 286 return decode(context, str, encoding ?? PythonContext.GetContext(context).GetDefaultEncodingName(), errors);
287 287 } else {
288   - return cls.CreateInstance(context, str, encoding, errors);
  288 + return cls.CreateInstance(context, __new__(context, TypeCache.String, str, encoding, errors));
289 289 }
290 290 }
291 291
34 Merlin/Main/Languages/Ruby/IronRuby.Tests/Driver.cs
@@ -59,7 +59,7 @@ public class TestRuntime {
59 59 _driver = driver;
60 60 _testName = testCase.Name;
61 61
62   - if (_driver.IsDebug) {
  62 + if (_driver.SaveToAssemblies) {
63 63 Environment.SetEnvironmentVariable("DLR_AssembliesFileName", _testName);
64 64 }
65 65
@@ -72,8 +72,7 @@ public class TestRuntime {
72 72 }
73 73 }
74 74
75   - // TODO: dynamic modules with symbols are not available in partial trust
76   - runtimeSetup.DebugMode = !driver.PartialTrust;
  75 + runtimeSetup.DebugMode = _driver.IsDebug;
77 76 languageSetup.Options["InterpretedMode"] = _driver.Interpret;
78 77 languageSetup.Options["Verbosity"] = 2;
79 78 languageSetup.Options["Compatibility"] = testCase.Compatibility;
@@ -94,6 +93,7 @@ public class Driver {
94 93 private TestRuntime _testRuntime;
95 94 private static bool _excludeSelectedCases;
96 95 private static bool _isDebug;
  96 + private static bool _saveToAssemblies;
97 97 private static bool _runTokenizerDriver;
98 98 private static bool _displayList;
99 99 private static bool _partialTrust;
@@ -116,6 +116,10 @@ public class Driver {
116 116 get { return _isDebug; }
117 117 }
118 118
  119 + public bool SaveToAssemblies {
  120 + get { return _saveToAssemblies; }
  121 + }
  122 +
119 123 public bool PartialTrust {
120 124 get { return _partialTrust; }
121 125 }
@@ -132,8 +136,10 @@ public class Driver {
132 136 if (args.Contains("/help") || args.Contains("-?") || args.Contains("/?") || args.Contains("-help")) {
133 137 Console.WriteLine("Partial trust : /partial");
134 138 Console.WriteLine("Interpret : /interpret");
  139 + Console.WriteLine("Save to assemblies : /save");
  140 + Console.WriteLine("Debug Mode : /debug");
135 141 Console.WriteLine("Disable Python interop tests : /py-");
136   - Console.WriteLine("Run Specific Tests : [/debug] [/exclude] [test_to_run ...]");
  142 + Console.WriteLine("Run Specific Tests : [/exclude] [test_to_run ...]");
137 143 Console.WriteLine("List Tests : /list");
138 144 Console.WriteLine("Tokenizer baseline : /tokenizer <target-dir> <sources-file>");
139 145 Console.WriteLine("Productions dump : /tokenizer /prod <target-dir> <sources-file>");
@@ -150,6 +156,11 @@ public class Driver {
150 156 _isDebug = true;
151 157 }
152 158
  159 + if (args.Contains("/save")) {
  160 + args.Remove("/save");
  161 + _saveToAssemblies = true;
  162 + }
  163 +
153 164 if (args.Contains("/partial")) {
154 165 args.Remove("/partial");
155 166 _partialTrust = true;
@@ -278,7 +289,7 @@ public sealed class Loader : MarshalByRefObject {
278 289 }
279 290
280 291 private static void InitializeDomain() {
281   - if (_isDebug) {
  292 + if (_saveToAssemblies) {
282 293 string _dumpDir = Path.Combine(Path.GetTempPath(), "RubyTests");
283 294
284 295 if (Directory.Exists(_dumpDir)) {
@@ -374,7 +385,11 @@ public sealed class Loader : MarshalByRefObject {
374 385 failedCases.Add(test);
375 386
376 387 Console.Error.WriteLine();
377   - WriteError("{0}) {1} {2} : {3}", failedCases.Count, test, frame.GetFileName(), frame.GetFileLineNumber());
  388 + if (_partialTrust) {
  389 + WriteError("{0}) {1}", failedCases.Count, test);
  390 + } else {
  391 + WriteError("{0}) {1} {2} : {3}", failedCases.Count, test, frame.GetFileName(), frame.GetFileLineNumber());
  392 + }
378 393 Console.Error.WriteLine(message);
379 394 }
380 395 }
@@ -397,7 +412,12 @@ public sealed class Loader : MarshalByRefObject {
397 412 Console.ForegroundColor = ConsoleColor.Gray;
398 413 } else {
399 414 Console.WriteLine();
400   - Console.Write("Repro: {0}", Environment.CommandLine);
  415 + // TODO:
  416 + if (!_partialTrust) {
  417 + Console.Write("Repro: {0}", Environment.CommandLine);
  418 + } else {
  419 + Console.Write("Repro: IronRuby.Tests.exe /partial");
  420 + }
401 421 if (largs.Count == 0) {
402 422 Console.Write(" {0}", String.Join(" ", failedCases.ToArray()));
403 423 }
2  Merlin/Main/Languages/Ruby/IronRuby.Tests/Helpers.cs
@@ -113,7 +113,7 @@ public partial class Tests {
113 113
114 114 string name = _driver.TestRuntime.TestName;
115 115
116   - if (_driver.IsDebug) {
  116 + if (_driver.SaveToAssemblies) {
117 117 string path = Path.Combine(Snippets.Shared.SnippetsDirectory, name + ".rb");
118 118 Directory.CreateDirectory(Snippets.Shared.SnippetsDirectory);
119 119 File.WriteAllText(path, code);
4 Merlin/Main/Languages/Ruby/IronRuby.Tests/Parser/ParserTests.cs
@@ -890,8 +890,8 @@ p __ENCODING__
890 890
891 891 const int Id = 0x12345678;
892 892
893   - var lambda = CallSiteTracer.Transform<DlrMainCallTarget>(ast, sourceUnit, options, Id);
894   - var code = new LegacyScriptCode(lambda, sourceUnit);
  893 + var lambda = CallSiteTracer.Transform<Func<Scope, LanguageContext, object>>(ast, sourceUnit, options, Id);
  894 + var code = new RubyScriptCode(lambda, sourceUnit);
895 895
896 896 var locations = new List<int>();
897 897 CallSiteTracer.Register((context, args, result, id, location) => {
7 Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/BacktraceTests.cs
@@ -15,10 +15,11 @@
15 15
16 16 using Microsoft.Scripting;
17 17 using System;
  18 +
18 19 namespace IronRuby.Tests {
19 20 public partial class Tests {
20 21 private bool PreciseTraces {
21   - get { return !_driver.PartialTrust || _driver.Interpret; }
  22 + get { return Runtime.Setup.DebugMode || _driver.Interpret; }
22 23 }
23 24
24 25 public void Backtrace1() {
@@ -171,13 +172,13 @@ def foo
171 172 }, PreciseTraces ? @"
172 173 Backtrace4.rb:7:in `baz'
173 174 Backtrace4.rb:11:in `foo'
174   -*.cs:*:in `Bar'
  175 +*:*:in `Bar'
175 176 Backtrace4.rb:11:in `foo'
176 177 Backtrace4.rb:14
177 178 " : @"
178 179 Backtrace4.rb:6:in `baz'
179 180 Backtrace4.rb:11:in `foo'
180   -:0:in `Bar'
  181 +*:*:in `Bar'
181 182 Backtrace4.rb:10:in `foo'
182 183 Backtrace4.rb:0
183 184 ", OutputFlags.Match);
8 Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/LoaderTests.cs
@@ -41,14 +41,14 @@ public partial class Tests {
41 41 b = Loader.TryParseAssemblyName(str, out type, out assembly);
42 42 Assert(b == false);
43 43
44   - str = "IronRuby.Runtime.RubyContext, IronRuby, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
  44 + str = "IronRuby.Runtime.RubyContext, IronRuby, Version=0.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
45 45 b = Loader.TryParseAssemblyName(str, out type, out assembly);
46 46 Assert(b == true &&
47   - assembly == "IronRuby, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" &&
  47 + assembly == "IronRuby, Version=0.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" &&
48 48 type == "IronRuby.Runtime.RubyContext"
49 49 );
50 50
51   - str = "IronRuby, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
  51 + str = "IronRuby, Version=0.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
52 52 b = Loader.TryParseAssemblyName(str, out type, out assembly);
53 53 Assert(b == true && assembly == str && type == null);
54 54
@@ -56,7 +56,7 @@ public partial class Tests {
56 56 b = Loader.TryParseAssemblyName(str, out type, out assembly);
57 57 Assert(b == true && assembly == str && type == null);
58 58
59   - str = "IronRuby, Version=1.0.0.0";
  59 + str = "IronRuby, Version=0.3.0.0";
60 60 b = Loader.TryParseAssemblyName(str, out type, out assembly);
61 61 Assert(b == true && assembly == str && type == null);
62 62 }
2  Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ModuleOps.cs
@@ -324,7 +324,7 @@ public static class ModuleOps {
324 324 );
325 325 }
326 326
327   - self.SetDefinedMethodNoEventNoLock(self.Context, methodName, info, attributesScope.Visibility);
  327 + self.SetDefinedMethodNoEventNoLock(self.Context, methodName, info, visibility);
328 328 }
329 329
330 330 self.Context.MethodAdded(self, methodName);
6 Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Protocols.cs
@@ -395,9 +395,9 @@ public static class Protocols {
395 395 return tt.Type;
396 396 }
397 397
398   - RubyClass rc = value as RubyClass;
399   - if (rc != null) {
400   - return rc.GetUnderlyingSystemType();
  398 + RubyModule module = value as RubyModule;
  399 + if (module != null) {
  400 + return module.GetUnderlyingSystemType();
401 401 }
402 402
403 403 throw RubyExceptions.InvalidValueForType(context, value, "Class");
2  Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyClass.cs
@@ -166,7 +166,7 @@ public sealed partial class RubyClass : RubyModule, IDuplicable {
166 166 }
167 167 #endif
168 168
169   - public Type/*!*/ GetUnderlyingSystemType() {
  169 + public override Type/*!*/ GetUnderlyingSystemType() {
170 170 if (_isSingletonClass) {
171 171 throw new InvalidOperationException("Singleton class doesn't have underlying system type.");
172 172 }
8 Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs
@@ -108,6 +108,14 @@ private enum MemberTableState {
108 108 get { return _tracker != null && _tracker.Type.IsInterface; }
109 109 }
110 110
  111 + public virtual Type/*!*/ GetUnderlyingSystemType() {
  112 + if (IsInterface) {
  113 + return _tracker.Type;
  114 + } else {
  115 + throw new InvalidOperationException();
  116 + }
  117 + }
  118 +
111 119 public RubyClass/*!*/ SingletonClass {
112 120 get {
113 121 Debug.Assert(_singletonClass != null);
7 Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/BlockDefinition.cs
@@ -173,11 +173,12 @@ public BlockDefinition(LexicalScope definedScope, CompoundLeftValue/*!*/ paramet
173 173 gen.CurrentScopeVariable,
174 174 gen.CurrentRfcVariable,
175 175 gen.CurrentSelfVariable,
176   - Ast.Lambda(
177   - BlockDispatcher.GetDelegateType(parameterCount, attributes),
  176 + BlockDispatcher.CreateLambda(
178 177 body,
179 178 RubyExceptionData.EncodeMethodName(gen.SourceUnit, gen.CurrentMethod.MethodName, Location),
180   - new ReadOnlyCollection<MSA.ParameterExpression>(parameters)
  179 + new ReadOnlyCollection<MSA.ParameterExpression>(parameters),
  180 + parameterCount,
  181 + attributes
181 182 ),
182 183 AstUtils.Constant(parameterCount),
183 184 AstUtils.Constant(attributes)
3  Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Declarations/MethodDeclaration.cs
@@ -156,8 +156,7 @@ public partial class MethodDeclaration : DeclarationExpression {
156 156 }
157 157 bodyWithParamInit[parameters.Length] = body;
158 158
159   - return Ast.Lambda(
160   - RubyMethodInfo.ParamsArrayDelegateType,
  159 + return Ast.Lambda<Func<object, Proc, object[], object>>(
161 160 Ast.Block(
162 161 new ReadOnlyCollection<MSA.ParameterExpression>(parameters),
163 162 new ReadOnlyCollection<MSA.Expression>(bodyWithParamInit)
BIN  Merlin/Main/Languages/Ruby/Ruby/Ruby.Build.csproj
Binary file not shown
4 Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj
@@ -61,6 +61,7 @@
61 61 <NoStdLib>true</NoStdLib>
62 62 <SilverlightBuild>true</SilverlightBuild>
63 63 <SilverlightSdkPath>..\..\..\Utilities\Silverlight\x86ret\</SilverlightSdkPath>
  64 + <NoWarn>414,219</NoWarn>
64 65 </PropertyGroup>
65 66 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Silverlight Release|AnyCPU' ">
66 67 <OutputPath>..\..\..\Bin\Silverlight Release\</OutputPath>
@@ -71,6 +72,7 @@
71 72 <ErrorReport>prompt</ErrorReport>
72 73 <SilverlightBuild>true</SilverlightBuild>
73 74 <SilverlightSdkPath>..\..\..\Utilities\Silverlight\x86ret\</SilverlightSdkPath>
  75 + <NoWarn>414,219</NoWarn>
74 76 </PropertyGroup>
75 77 <ItemGroup>
76 78 <Reference Include="System" Condition=" '$(SilverlightBuild)' != 'true' " />
@@ -309,11 +311,13 @@
309 311 <Compile Include="Builtins\RubyModule.cs" />
310 312 <Compile Include="Builtins\RubyInputProvider.cs" />
311 313 <Compile Include="Runtime\RubyGlobalScope.cs" />
  314 + <Compile Include="Runtime\RubyMethodDebugInfo.cs" />
312 315 <Compile Include="Runtime\RubyOps.cs" />
313 316 <Compile Include="Runtime\Calls\RubyMethodInfo.cs" />
314 317 <Compile Include="Runtime\RubyContext.cs" />
315 318 <Compile Include="Runtime\RubyOptions.cs" />
316 319 <Compile Include="Runtime\RubyScope.cs" />
  320 + <Compile Include="Runtime\RubyScriptCode.cs" />
317 321 <Compile Include="Runtime\RubyUtils.cs" />
318 322 <Compile Include="Runtime\RuntimeFlowControl.cs" />
319 323 <Compile Include="Runtime\RuntimeErrorSink.cs" />
18 Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/BlockDispatcher.cs
@@ -22,6 +22,7 @@
22 22 using System.Linq.Expressions;
23 23 using System.Reflection;
24 24 using IronRuby.Builtins;
  25 +using System.Collections.ObjectModel;
25 26
26 27 namespace IronRuby.Runtime.Calls {
27 28 using Ast = System.Linq.Expressions.Expression;
@@ -108,18 +109,19 @@ public abstract class BlockDispatcher {
108 109 return new BlockDispatcherUnsplatN((BlockCallTargetUnsplatN)method, parameterCount, attributes);
109 110 }
110 111
111   - internal static Type/*!*/ GetDelegateType(int parameterCount, BlockSignatureAttributes attributes) {
  112 + internal static LambdaExpression/*!*/ CreateLambda(Expression body, string name, ReadOnlyCollection<ParameterExpression> parameters,
  113 + int parameterCount, BlockSignatureAttributes attributes) {
112 114 if ((attributes & BlockSignatureAttributes.HasUnsplatParameter) == 0) {
113 115 switch (parameterCount) {
114   - case 0: return typeof(BlockCallTarget0);
115   - case 1: return typeof(BlockCallTarget1);
116   - case 2: return typeof(BlockCallTarget2);
117   - case 3: return typeof(BlockCallTarget3);
118   - case 4: return typeof(BlockCallTarget4);
119   - default: return typeof(BlockCallTargetN);
  116 + case 0: return Ast.Lambda<BlockCallTarget0>(body, name, parameters);
  117 + case 1: return Ast.Lambda<BlockCallTarget1>(body, name, parameters);
  118 + case 2: return Ast.Lambda<BlockCallTarget2>(body, name, parameters);
  119 + case 3: return Ast.Lambda<BlockCallTarget3>(body, name, parameters);
  120 + case 4: return Ast.Lambda<BlockCallTarget4>(body, name, parameters);
  121 + default: return Ast.Lambda<BlockCallTargetN>(body, name, parameters);
120 122 }
121 123 }
122   - return typeof(BlockCallTargetUnsplatN);
  124 + return Ast.Lambda<BlockCallTargetUnsplatN>(body, name, parameters);
123 125 }
124 126
125 127 private static void CopyArgumentsFromSplattee(object[]/*!*/ args, int initializedArgCount, int parameterCount,
8 Merlin/Main/Languages/Ruby/Ruby/Runtime/Loader.cs
@@ -81,7 +81,6 @@ private struct CompiledFile {
81 81 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
82 82 private int _compiledFileCount;
83 83
84   - internal static long _ILGenerationTimeTicks;
85 84 internal static long _ScriptCodeGenerationTimeTicks;
86 85
87 86 /// <summary>
@@ -477,13 +476,6 @@ private class ResolvedFile {
477 476 }
478 477
479 478 internal object CompileAndRun(Scope globalScope, ScriptCode/*!*/ code, bool tryEvaluate) {
480   - long ts1 = Stopwatch.GetTimestamp();
481   - if (code is LegacyScriptCode) {
482   - ((LegacyScriptCode)code).EnsureCompiled();
483   - }
484   - long ts2 = Stopwatch.GetTimestamp();
485   - Interlocked.Add(ref _ILGenerationTimeTicks, ts2 - ts1);
486   -
487 479 return globalScope != null ? code.Run(globalScope) : code.Run();
488 480 }
489 481
20 Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyContext.cs
@@ -48,9 +48,9 @@ public sealed class RubyContext : LanguageContext {
48 48 public static readonly string/*!*/ MriReleaseDate = "2008-05-28";
49 49
50 50 // IronRuby:
51   - public const string/*!*/ IronRubyVersionString = "1.0.0.0";
52   - public static readonly Version IronRubyVersion = new Version(1, 0, 0, 0);
53   - internal const string/*!*/ IronRubyDisplayName = "IronRuby 1.0 Alpha";
  51 + public const string/*!*/ IronRubyVersionString = "0.3.0.0";
  52 + public static readonly Version IronRubyVersion = new Version(0, 3, 0, 0);
  53 + internal const string/*!*/ IronRubyDisplayName = "IronRuby 0.3";
54 54 internal const string/*!*/ IronRubyNames = "IronRuby;Ruby;rb";
55 55 internal const string/*!*/ IronRubyFileExtensions = ".rb";
56 56
@@ -1568,7 +1568,7 @@ public RubyContext(ScriptDomainManager/*!*/ manager, IDictionary<string, object>
1568 1568 }
1569 1569 #endif
1570 1570
1571   - Expression<DlrMainCallTarget> lambda = ParseSourceCode<DlrMainCallTarget>(sourceUnit, (RubyCompilerOptions)options, errorSink);
  1571 + var lambda = ParseSourceCode<Func<Scope, LanguageContext, object>>(sourceUnit, (RubyCompilerOptions)options, errorSink);
1572 1572 if (lambda == null) {
1573 1573 return null;
1574 1574 }
@@ -1576,7 +1576,7 @@ public RubyContext(ScriptDomainManager/*!*/ manager, IDictionary<string, object>
1576 1576 if (Options.InterpretedMode) {
1577 1577 return new InterpretedScriptCode(lambda, sourceUnit);
1578 1578 } else {
1579   - return new LegacyScriptCode(lambda, sourceUnit);
  1579 + return new RubyScriptCode(lambda, sourceUnit);
1580 1580 }
1581 1581 }
1582 1582
@@ -1662,6 +1662,12 @@ public RubyContext(ScriptDomainManager/*!*/ manager, IDictionary<string, object>
1662 1662 return _runtimeErrorSink;
1663 1663 }
1664 1664
  1665 + protected override ScriptCode/*!*/ LoadCompiledCode(Delegate/*!*/ method, string path) {
  1666 + // TODO:
  1667 + SourceUnit su = new SourceUnit(this, NullTextContentProvider.Null, path, SourceCodeKind.File);
  1668 + return new RubyScriptCode((Func<Scope, LanguageContext, object>)method, su);
  1669 + }
  1670 +
1665 1671 public void CheckConstantName(string name) {
1666 1672 if (!Tokenizer.IsConstantName(name, _options.Compatibility >= RubyCompatibility.Ruby19 || KCode != null)) {
1667 1673 throw RubyExceptions.CreateNameError(String.Format("`{0}' is not allowed as a constant name", name));
@@ -1818,14 +1824,14 @@ public RubyContext(ScriptDomainManager/*!*/ manager, IDictionary<string, object>
1818 1824 parse: {1}
1819 1825 ast transform: {2}
1820 1826 script code: {3}
1821   - il: {4}
  1827 + il: {4} (TODO)
1822 1828 binding: {5} ({6} calls)
1823 1829 ",
1824 1830 _upTime.Elapsed,
1825 1831 new TimeSpan(_ParseTimeTicks),
1826 1832 new TimeSpan(_AstGenerationTimeTicks),
1827 1833 new TimeSpan(Loader._ScriptCodeGenerationTimeTicks),
1828   - new TimeSpan(Loader._ILGenerationTimeTicks),
  1834 + new TimeSpan(), // TODO: new TimeSpan(Loader._ILGenerationTimeTicks),
1829 1835 #if MEASURE
1830 1836 new TimeSpan(MetaAction.BindingTimeTicks),
1831 1837 MetaAction.BindCallCount
16 Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyExceptionData.cs
@@ -227,13 +227,27 @@ public class RubyExceptionData {
227 227 methodName = method.Name;
228 228
229 229 fileName = (hasFileAccessPermission) ? frame.GetFileName() : null;
230   - line = frame.GetFileLineNumber();
  230 + var sourceLine = line = frame.GetFileLineNumber();
231 231
232 232 if (TryParseRubyMethodName(ref methodName, ref fileName, ref line)) {
233 233 // Ruby method:
234 234 if (methodName == TopLevelMethodName) {
235 235 methodName = null;
236 236 }
  237 +
  238 + if (sourceLine == 0) {
  239 + RubyMethodDebugInfo debugInfo;
  240 + if (RubyMethodDebugInfo.TryGet(method, out debugInfo)) {
  241 + var ilOffset = frame.GetILOffset();
  242 + if (ilOffset >= 0) {
  243 + var mappedLine = debugInfo.Map(ilOffset);
  244 + if (mappedLine != 0) {
  245 + line = mappedLine;
  246 + }
  247 + }
  248 + }
  249 + }
  250 +
237 251 return true;
238 252 } else if (method.IsDefined(typeof(RubyStackTraceHiddenAttribute), false)) {
239 253 return false;
65 Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyMethodDebugInfo.cs
... ... @@ -0,0 +1,65 @@
  1 +/* ****************************************************************************
  2 + *
  3 + * Copyright (c) Microsoft Corporation.
  4 + *
  5 + * This source code is subject to terms and conditions of the Microsoft Public License. A
  6 + * copy of the license can be found in the License.html file at the root of this distribution. If
  7 + * you cannot locate the Microsoft Public License, please send an email to
  8 + * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9 + * by the terms of the Microsoft Public License.
  10 + *
  11 + * You must not remove this notice, or any other, from this software.
  12 + *
  13 + *
  14 + * ***************************************************************************/
  15 +
  16 +using System;
  17 +using System.Collections.Generic;
  18 +using System.Text;
  19 +using System.Reflection;
  20 +
  21 +namespace IronRuby.Runtime {
  22 + internal sealed class RubyMethodDebugInfo {
  23 + private static readonly Dictionary<string, RubyMethodDebugInfo> _Infos = new Dictionary<string, RubyMethodDebugInfo>();
  24 +
  25 + private readonly List<int>/*!*/ _offsets = new List<int>();
  26 + private readonly List<int>/*!*/ _lines = new List<int>();
  27 +
  28 + public static bool TryGet(MethodBase/*!*/ method, out RubyMethodDebugInfo info) {
  29 + lock (_Infos) {
  30 + return _Infos.TryGetValue(method.Name, out info);
  31 + }
  32 + }
  33 +
  34 + public static RubyMethodDebugInfo GetOrCreate(string/*!*/ methodName) {
  35 + lock (_Infos) {
  36 + RubyMethodDebugInfo info;
  37 + if (!_Infos.TryGetValue(methodName, out info)) {
  38 + info = new RubyMethodDebugInfo();
  39 + _Infos.Add(methodName, info);
  40 + }
  41 + return info;
  42 + }
  43 + }
  44 +
  45 + public void AddMapping(int ilOffset, int line) {
  46 + _offsets.Add(ilOffset);
  47 + _lines.Add(line);
  48 + }
  49 +
  50 + public int Map(int ilOffset) {
  51 + int index =_offsets.BinarySearch(ilOffset);
  52 + if (index >= 0) {
  53 + return _lines[index];
  54 + }
  55 + index = ~index;
  56 + if (index > 0) {
  57 + return _lines[index - 1];
  58 + }
  59 + if (_lines.Count > 0) {
  60 + return _lines[0];
  61 + }
  62 + return 0;
  63 + }
  64 + }
  65 +}
94 Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyScriptCode.cs
... ... @@ -0,0 +1,94 @@
  1 +/* ****************************************************************************
  2 + *
  3 + * Copyright (c) Microsoft Corporation.
  4 + *
  5 + * This source code is subject to terms and conditions of the Microsoft Public License. A
  6 + * copy of the license can be found in the License.html file at the root of this distribution. If
  7 + * you cannot locate the Microsoft Public License, please send an email to
  8 + * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9 + * by the terms of the Microsoft Public License.
  10 + *
  11 + * You must not remove this notice, or any other, from this software.
  12 + *
  13 + *
  14 + * ***************************************************************************/
  15 +
  16 +using ScriptCodeFunc = System.Func<Microsoft.Scripting.Runtime.Scope, Microsoft.Scripting.Runtime.LanguageContext, object>;
  17 +
  18 +using System;
  19 +using System.Collections.Generic;
  20 +using System.Text;
  21 +using Microsoft.Scripting;
  22 +using System.Linq.Expressions;
  23 +using Microsoft.Scripting.Runtime;
  24 +using Microsoft.Scripting.Generation;
  25 +using System.Threading;
  26 +using System.Linq.Expressions.Compiler;
  27 +using System.Reflection;
  28 +using Microsoft.Scripting.Utils;
  29 +using System.Runtime.CompilerServices;
  30 +using System.Security;
  31 +
  32 +namespace IronRuby.Runtime {
  33 + internal sealed class RubyScriptCode : ScriptCode {
  34 + private sealed class CustomGenerator : DebugInfoGenerator {
  35 + public override void MarkSequencePoint(LambdaExpression method, int ilOffset, DebugInfoExpression node) {
  36 + RubyMethodDebugInfo.GetOrCreate(method.Name).AddMapping(ilOffset, node.StartLine);
  37 + }
  38 + }
  39 +
  40 + private readonly Expression<ScriptCodeFunc> _code;
  41 + private ScriptCodeFunc _target;
  42 +
  43 + public RubyScriptCode(Expression<ScriptCodeFunc>/*!*/ code, SourceUnit/*!*/ sourceUnit)
  44 + : base(sourceUnit) {
  45 + Assert.NotNull(code);
  46 + _code = code;
  47 + }
  48 +
  49 + internal RubyScriptCode(ScriptCodeFunc/*!*/ target, SourceUnit/*!*/ sourceUnit)
  50 + : base(sourceUnit) {
  51 + Assert.NotNull(target);
  52 + _target = target;
  53 + }
  54 +
  55 + private ScriptCodeFunc/*!*/ Target {
  56 + get {
  57 + if (_target == null) {
  58 + var compiledMethod = CompileLambda<ScriptCodeFunc>(_code, SourceUnit.LanguageContext.DomainManager.Configuration.DebugMode);
  59 + Interlocked.CompareExchange(ref _target, compiledMethod, null);
  60 + }
  61 + return _target;
  62 + }
  63 + }
  64 +
  65 + public override object Run() {
  66 + return Target(CreateScope(), SourceUnit.LanguageContext);
  67 + }
  68 +
  69 + public override object Run(Scope/*!*/ scope) {
  70 + return Target(scope, SourceUnit.LanguageContext);
  71 + }
  72 +
  73 + private static bool _HasPdbPermissions = true;
  74 +
  75 + internal static T/*!*/ CompileLambda<T>(Expression<T>/*!*/ lambda, bool debugMode) {
  76 + if (debugMode) {
  77 +#if !SILVERLIGHT
  78 + // try to use PDBs and fallback to CustomGenerator if not allowed to:
  79 + if (_HasPdbPermissions) {
  80 + try {
  81 + return CompilerHelpers.CompileToMethod(lambda, DebugInfoGenerator.CreatePdbGenerator(), true);
  82 + } catch (SecurityException) {
  83 + // do not attempt next time in this app-domain:
  84 + _HasPdbPermissions = false;
  85 + }
  86 + }
  87 +#endif
  88 + return CompilerHelpers.CompileToMethod(lambda, new CustomGenerator(), false);
  89 + } else {
  90 + return lambda.Compile();
  91 + }
  92 + }
  93 + }
  94 +}
2  Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs
@@ -710,7 +710,7 @@ private class RecursionHandle : IDisposable {
710 710 targetScope.RuntimeFlowControl
711 711 );
712 712 } else {
713   - return lambda.Compile(source.EmitDebugSymbols)(
  713 + return RubyScriptCode.CompileLambda(lambda, context.DomainManager.Configuration.DebugMode)(
714 714 targetScope,
715 715 self,
716 716 module,
4 Merlin/Main/Languages/Ruby/Utils/IronRuby.Libraries.Scanner/Program.cs
@@ -167,9 +167,9 @@ where t.IsDefined(typeof(RubyModuleAttribute), false)
167 167 }
168 168
169 169 #if SIGNED
170   - const string RubyAssembly = @"IronRuby.Libraries, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
  170 + const string RubyAssembly = @"IronRuby.Libraries, Version=0.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
171 171 #else
172   - const string RubyAssembly = @"IronRuby.Libraries, Version=1.0.0.0, Culture=neutral";
  172 + const string RubyAssembly = @"IronRuby.Libraries, Version=0.3.0.0, Culture=neutral";
173 173 #endif
174 174 internal static Dictionary<Type, Type> ExtensionModules;
175 175
26 Merlin/Main/Runtime/Microsoft.Scripting/Generation/CompilerHelpers.cs
@@ -25,6 +25,7 @@
25 25 using Microsoft.Scripting.Runtime;
26 26 using Microsoft.Scripting.Utils;
27 27 using Microsoft.Scripting.Interpreter;
  28 +using System.Linq.Expressions.Compiler;
28 29 using AstUtils = Microsoft.Scripting.Ast.Utils;
29 30
30 31 namespace Microsoft.Scripting.Generation {
@@ -693,6 +694,22 @@ public static class CompilerHelpers {
693 694 }
694 695
695 696 /// <summary>
  697 + /// Compiles the lambda into a method definition.
  698 + /// </summary>
  699 + /// <param name="lambda">the lambda to compile</param>
  700 + /// <param name="method">A <see cref="MethodBuilder"/> which will be used to hold the lambda's IL.</param>
  701 + /// <param name="emitDebugSymbols">A parameter that indicates if debugging information should be emitted to a PDB symbol store.</param>
  702 + public static void CompileToMethod(this LambdaExpression lambda, MethodBuilder method, bool emitDebugSymbols) {
  703 + if (emitDebugSymbols) {
  704 + var module = method.Module as ModuleBuilder;
  705 + ContractUtils.Requires(module != null, "method", "MethodBuilder does not have a valid ModuleBuilder");
  706 + lambda.CompileToMethod(method, DebugInfoGenerator.CreatePdbGenerator());
  707 + } else {
  708 + lambda.CompileToMethod(method);
  709 + }
  710 + }
  711 +
  712 + /// <summary>
696 713 /// Compiles the LambdaExpression.
697 714 ///
698 715 /// If the lambda is compiled with emitDebugSymbols, it will be
@@ -706,7 +723,7 @@ public static class CompilerHelpers {
706 723 /// <param name="emitDebugSymbols">true to generate a debuggable method, false otherwise</param>
707 724 /// <returns>the compiled delegate</returns>
708 725 public static T Compile<T>(this Expression<T> lambda, bool emitDebugSymbols) {
709   - return emitDebugSymbols ? CompileToMethod(lambda, true) : lambda.Compile();
  726 + return emitDebugSymbols ? CompileToMethod(lambda, DebugInfoGenerator.CreatePdbGenerator(), true) : lambda.Compile();
710 727 }
711 728
712 729 /// <summary>
@@ -717,10 +734,11 @@ public static class CompilerHelpers {
717 734 /// have debugging information.
718 735 /// </summary>
719 736 /// <param name="lambda">the lambda to compile</param>
720   - /// <param name="emitDebugSymbols">true to generate a debuggable method, false otherwise</param>
  737 + /// <param name="debugInfoGenerator">Debugging information generator used by the compiler to mark sequence points and annotate local variables.</param>
  738 + /// <param name="emitDebugSymbols">True if debug symbols (PDBs) are emitted by the <paramref name="debugInfoGenerator"/>.</param>
721 739 /// <returns>the compiled delegate</returns>
722 740 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
723   - public static T CompileToMethod<T>(Expression<T> lambda, bool emitDebugSymbols) {
  741 + public static T CompileToMethod<T>(Expression<T> lambda, DebugInfoGenerator debugInfoGenerator, bool emitDebugSymbols) {
724 742 var type = Snippets.Shared.DefineType(lambda.Name, typeof(object), false, emitDebugSymbols).TypeBuilder;
725 743 var rewriter = new BoundConstantsRewriter(type);
726 744 lambda = (Expression<T>)rewriter.Visit(lambda);
@@ -728,7 +746,7 @@ public static class CompilerHelpers {
728 746 //Create a unique method name when the lambda doesn't have a name or the name is empty.
729 747 string methodName = String.IsNullOrEmpty(lambda.Name) ? GetUniqueMethodName() : lambda.Name;
730 748 var method = type.DefineMethod(methodName, CompilerHelpers.PublicStatic);
731   - lambda.CompileToMethod(method, emitDebugSymbols);
  749 + lambda.CompileToMethod(method, debugInfoGenerator);
732 750
733 751 var finished = type.CreateType();
734 752
2  Merlin/Main/Runtime/Microsoft.Scripting/Runtime/LanguageContext.cs
@@ -147,7 +147,7 @@ public abstract class LanguageContext {
147 147 internal protected abstract ScriptCode CompileSourceCode(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink);
148 148
149 149 internal protected virtual ScriptCode LoadCompiledCode(Delegate method, string path) {
150   - return LegacyScriptCode.Load((DlrMainCallTarget)method, this, path);
  150 + throw new NotSupportedException();
151 151 }
152 152
153 153 #endregion
50 ndp/fx/src/Core/Microsoft/Scripting/Ast/LambdaExpression.cs
@@ -21,6 +21,7 @@
21 21 using System.Reflection;
22 22 using System.Reflection.Emit;
23 23 using System.Threading;
  24 +using System.Runtime.CompilerServices;
24 25
25 26 namespace System.Linq.Expressions {
26 27 /// <summary>
@@ -115,27 +116,44 @@ ReadOnlyCollection<ParameterExpression> parameters
115 116 /// </summary>
116 117 /// <returns>A delegate containing the compiled version of the lambda.</returns>
117 118 public Delegate Compile() {
118   - return LambdaCompiler.Compile(this);
  119 + return LambdaCompiler.Compile(this, null);
  120 + }
  121 +
  122 + /// <summary>
  123 + /// Produces a delegate that represents the lambda expression.
  124 + /// </summary>
  125 + /// <param name="debugInfoGenerator">Debugging information generator used by the compiler to mark sequence points and annotate local variables.</param>
  126 + /// <returns>A delegate containing the compiled version of the lambda.</returns>
  127 + public Delegate Compile(DebugInfoGenerator debugInfoGenerator) {
  128 + ContractUtils.RequiresNotNull(debugInfoGenerator, "debugInfoGenerator");
  129 + return LambdaCompiler.Compile(this, debugInfoGenerator);
119 130 }
120 131
121 132 /// <summary>
122 133 /// Compiles the lambda into a method definition.
123 134 /// </summary>
124 135 /// <param name="method">A <see cref="MethodBuilder"/> which will be used to hold the lambda's IL.</param>
125   - /// <param name="emitDebugSymbols">A parameter that indicates if debugging information should be emitted.</param>
126   - public void CompileToMethod(MethodBuilder method, bool emitDebugSymbols) {
  136 + public void CompileToMethod(MethodBuilder method) {
  137 + CompileToMethodInternal(method, null);
  138 + }
  139 +
  140 + /// <summary>
  141 + /// Compiles the lambda into a method definition and custom debug information.
  142 + /// </summary>
  143 + /// <param name="method">A <see cref="MethodBuilder"/> which will be used to hold the lambda's IL.</param>
  144 + /// <param name="debugInfoGenerator">Debugging information generator used by the compiler to mark sequence points and annotate local variables.</param>
  145 + public void CompileToMethod(MethodBuilder method, DebugInfoGenerator debugInfoGenerator) {
  146 + ContractUtils.RequiresNotNull(debugInfoGenerator, "debugInfoGenerator");
  147 + CompileToMethodInternal(method, debugInfoGenerator);
  148 + }
  149 +
  150 + private void CompileToMethodInternal(MethodBuilder method, DebugInfoGenerator debugInfoGenerator) {
127 151 ContractUtils.RequiresNotNull(method, "method");
128 152 ContractUtils.Requires(method.IsStatic, "method");
129   -
130 153 var type = method.DeclaringType as TypeBuilder;
131 154 ContractUtils.Requires(type != null, "method", Strings.MethodBuilderDoesNotHaveTypeBuilder);
132   -
133   - if (emitDebugSymbols) {
134   - var module = method.Module as ModuleBuilder;
135   - ContractUtils.Requires(module != null, "method", Strings.MethodBuilderDoesNotHaveModuleBuilder);
136   - }
137 155
138   - LambdaCompiler.Compile(this, method, emitDebugSymbols);
  156 + LambdaCompiler.Compile(this, method, debugInfoGenerator);
139 157 }
140 158
141 159 internal abstract LambdaExpression Accept(StackSpiller spiller);
@@ -159,7 +177,17 @@ internal Expression(Expression body, string name, bool tailCall, ReadOnlyCollect
159 177 /// </summary>
160 178 /// <returns>A delegate containing the compiled version of the lambda.</returns>
161 179 public new TDelegate Compile() {
162   - return (TDelegate)(object)LambdaCompiler.Compile(this);
  180 + return (TDelegate)(object)LambdaCompiler.Compile(this, null);
  181 + }
  182 +
  183 + /// <summary>
  184 + /// Produces a delegate that represents the lambda expression.
  185 + /// </summary>
  186 + /// <param name="debugInfoGenerator">Debugging information generator used by the compiler to mark sequence points and annotate local variables.</param>
  187 + /// <returns>A delegate containing the compiled version of the lambda.</returns>
  188 + public new TDelegate Compile(DebugInfoGenerator debugInfoGenerator) {
  189 + ContractUtils.RequiresNotNull(debugInfoGenerator, "debugInfoGenerator");
  190 + return (TDelegate)(object)LambdaCompiler.Compile(this, debugInfoGenerator);
163 191 }
164 192
165 193 internal override Expression Accept(ExpressionVisitor visitor) {
12 ndp/fx/src/Core/Microsoft/Scripting/Compiler/AnalyzedTree.cs
@@ -17,22 +17,14 @@
17 17 using System.Collections.Generic;
18 18 using System.Diagnostics.SymbolStore;
19 19 using System.Dynamic.Utils;
  20 +using System.Runtime.CompilerServices;
20 21
21 22 namespace System.Linq.Expressions.Compiler {
22 23 internal sealed class AnalyzedTree {
23 24 internal readonly Dictionary<object, CompilerScope> Scopes = new Dictionary<object, CompilerScope>();
24 25 internal readonly Dictionary<LambdaExpression, BoundConstants> Constants = new Dictionary<LambdaExpression, BoundConstants>();
25 26
26   - // Lazy initialized because many trees will not need it
27   - private Dictionary<SymbolDocumentInfo, ISymbolDocumentWriter> _symbolWriters;
28   - internal Dictionary<SymbolDocumentInfo, ISymbolDocumentWriter> SymbolWriters {
29   - get {
30   - if (_symbolWriters == null) {
31   - _symbolWriters = new Dictionary<SymbolDocumentInfo, ISymbolDocumentWriter>();
32   - }
33   - return _symbolWriters;
34   - }
35   - }
  27 + internal DebugInfoGenerator DebugInfoGenerator { get; set; }
36 28
37 29 // Created by VariableBinder
38 30 internal AnalyzedTree() {
8 ndp/fx/src/Core/Microsoft/Scripting/Compiler/CompilerScope.Storage.cs
@@ -46,13 +46,13 @@ private abstract class Storage {
46 46 private sealed class LocalStorage : Storage {
47 47 private readonly LocalBuilder _local;
48 48
49   - internal LocalStorage(LambdaCompiler compiler, ParameterExpression v)
50   - : base(compiler, v) {
  49 + internal LocalStorage(LambdaCompiler compiler, ParameterExpression variable)
  50 + : base(compiler, variable) {
51 51 // ByRef variables are supported. This is used internally by
52 52 // the compiler when emitting an inlined lambda invoke, to