Skip to content

Commit

Permalink
syncing to head of tfs. Changes IronRuby to version 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jredville committed Mar 19, 2009
1 parent be5ccb7 commit cd98845
Show file tree
Hide file tree
Showing 43 changed files with 859 additions and 142 deletions.
Expand Up @@ -40,7 +40,7 @@
end end


# FIXME: do not use conditionals like this around #it blocks # FIXME: do not use conditionals like this around #it blocks
unless not home = ENV['HOME'] unless not home = ENV['HOME'].tr('\\', '/')
it "converts a pathname to an absolute pathname, using ~ (home) as base" do it "converts a pathname to an absolute pathname, using ~ (home) as base" do
File.expand_path('~').should == home File.expand_path('~').should == home
File.expand_path('~', '/tmp/gumby/ddd').should == home File.expand_path('~', '/tmp/gumby/ddd').should == home
Expand Down
2 changes: 1 addition & 1 deletion Merlin/Main/Config/Signed/App.config
Expand Up @@ -7,7 +7,7 @@
<microsoft.scripting> <microsoft.scripting>
<languages> <languages>
<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" /> <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" />
<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" /> <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" />
<language names="ToyScript;ts" extensions=".ts" type="ToyScript.ToyLanguageContext, ToyScript, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <language names="ToyScript;ts" extensions=".ts" type="ToyScript.ToyLanguageContext, ToyScript, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</languages> </languages>


Expand Down
2 changes: 1 addition & 1 deletion Merlin/Main/Config/Unsigned/App.config
Expand Up @@ -7,7 +7,7 @@
<microsoft.scripting> <microsoft.scripting>
<languages> <languages>
<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" /> <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" />
<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" /> <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" />
<language names="ToyScript;ts" extensions=".ts" type="ToyScript.ToyLanguageContext, ToyScript, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> <language names="ToyScript;ts" extensions=".ts" type="ToyScript.ToyLanguageContext, ToyScript, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</languages> </languages>


Expand Down
Expand Up @@ -267,7 +267,7 @@ class LookupGlobalInstruction : Instruction {
_name = SymbolTable.StringToId(name); _name = SymbolTable.StringToId(name);
_isLocal = isLocal; _isLocal = isLocal;
} }

public override int ConsumedStack { get { return 1; } }
public override int ProducedStack { get { return 1; } } public override int ProducedStack { get { return 1; } }
public override int Run(StackFrame frame) { public override int Run(StackFrame frame) {
if (_isLocal) { if (_isLocal) {
Expand Down
Expand Up @@ -59,14 +59,21 @@ public static class ScopeOps {
} }
} }


public static object __getattribute__(Scope/*!*/ self, string name) { public static object __getattribute__(CodeContext/*!*/ context, Scope/*!*/ self, string name) {
switch (name) {
// never look in the dict for these...
case "__dict__": return Get__dict__(self);
case "__class__": return DynamicHelpers.GetPythonType(self);
}

SymbolId si = SymbolTable.StringToId(name); SymbolId si = SymbolTable.StringToId(name);
object res; object res;
if (self.TryGetName(si, out res)) { if (self.TryGetName(si, out res)) {
return res; return res;
} }


throw PythonOps.AttributeErrorForMissingAttribute("module", si); // fall back to object to provide all of our other attributes (e.g. __setattr__, etc...)
return ObjectOps.__getattribute__(context, self, name);
} }


public static void __setattr__(Scope/*!*/ self, string name, object value) { public static void __setattr__(Scope/*!*/ self, string name, object value) {
Expand Down
Expand Up @@ -179,7 +179,7 @@ public static class StringOps {
if (cls == TypeCache.String) { if (cls == TypeCache.String) {
return FastNew(context, @object); return FastNew(context, @object);
} else { } else {
return cls.CreateInstance(context, @object); return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
} }
} }


Expand All @@ -197,7 +197,7 @@ public static class StringOps {
if (cls == TypeCache.String) { if (cls == TypeCache.String) {
return FastNew(context, @object); return FastNew(context, @object);
} else { } else {
return cls.CreateInstance(context, @object); return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
} }
} }


Expand All @@ -206,7 +206,7 @@ public static class StringOps {
if (cls == TypeCache.String) { if (cls == TypeCache.String) {
return CheckAsciiString(context, ScriptingRuntimeHelpers.CharToString(@object)); return CheckAsciiString(context, ScriptingRuntimeHelpers.CharToString(@object));
} else { } else {
return cls.CreateInstance(context, @object); return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
} }
} }


Expand All @@ -215,7 +215,7 @@ public static class StringOps {
if (cls == TypeCache.String) { if (cls == TypeCache.String) {
return @object.ToString(); return @object.ToString();
} else { } else {
return cls.CreateInstance(context, @object); return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
} }
} }


Expand All @@ -224,7 +224,7 @@ public static class StringOps {
if (cls == TypeCache.String) { if (cls == TypeCache.String) {
return FastNew(context, @object); return FastNew(context, @object);
} else { } else {
return cls.CreateInstance(context, @object); return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
} }
} }


Expand All @@ -233,7 +233,7 @@ public static class StringOps {
if (cls == TypeCache.String) { if (cls == TypeCache.String) {
return @object.ToString(); return @object.ToString();
} else { } else {
return cls.CreateInstance(context, @object); return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
} }
} }


Expand All @@ -242,7 +242,7 @@ public static class StringOps {
if (cls == TypeCache.String) { if (cls == TypeCache.String) {
return @object.ToString(); return @object.ToString();
} else { } else {
return cls.CreateInstance(context, @object); return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
} }
} }


Expand All @@ -251,7 +251,7 @@ public static class StringOps {
if (cls == TypeCache.String) { if (cls == TypeCache.String) {
return DoubleOps.__str__(context, @object); return DoubleOps.__str__(context, @object);
} else { } else {
return cls.CreateInstance(context, @object); return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
} }
} }


Expand All @@ -260,7 +260,7 @@ public static class StringOps {
if (cls == TypeCache.String) { if (cls == TypeCache.String) {
return FastNew(context, @object); return FastNew(context, @object);
} else { } else {
return cls.CreateInstance(context, @object); return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
} }
} }


Expand All @@ -269,7 +269,7 @@ public static class StringOps {
if (cls == TypeCache.String) { if (cls == TypeCache.String) {
return SingleOps.__str__(context, @object); return SingleOps.__str__(context, @object);
} else { } else {
return cls.CreateInstance(context, @object); return cls.CreateInstance(context, __new__(context, TypeCache.String, @object));
} }
} }


Expand All @@ -285,7 +285,7 @@ public static class StringOps {
if (cls == TypeCache.String) { if (cls == TypeCache.String) {
return decode(context, str, encoding ?? PythonContext.GetContext(context).GetDefaultEncodingName(), errors); return decode(context, str, encoding ?? PythonContext.GetContext(context).GetDefaultEncodingName(), errors);
} else { } else {
return cls.CreateInstance(context, str, encoding, errors); return cls.CreateInstance(context, __new__(context, TypeCache.String, str, encoding, errors));
} }
} }


Expand Down
34 changes: 27 additions & 7 deletions Merlin/Main/Languages/Ruby/IronRuby.Tests/Driver.cs
Expand Up @@ -59,7 +59,7 @@ public class TestRuntime {
_driver = driver; _driver = driver;
_testName = testCase.Name; _testName = testCase.Name;


if (_driver.IsDebug) { if (_driver.SaveToAssemblies) {
Environment.SetEnvironmentVariable("DLR_AssembliesFileName", _testName); Environment.SetEnvironmentVariable("DLR_AssembliesFileName", _testName);
} }


Expand All @@ -72,8 +72,7 @@ public class TestRuntime {
} }
} }


// TODO: dynamic modules with symbols are not available in partial trust runtimeSetup.DebugMode = _driver.IsDebug;
runtimeSetup.DebugMode = !driver.PartialTrust;
languageSetup.Options["InterpretedMode"] = _driver.Interpret; languageSetup.Options["InterpretedMode"] = _driver.Interpret;
languageSetup.Options["Verbosity"] = 2; languageSetup.Options["Verbosity"] = 2;
languageSetup.Options["Compatibility"] = testCase.Compatibility; languageSetup.Options["Compatibility"] = testCase.Compatibility;
Expand All @@ -94,6 +93,7 @@ public class Driver {
private TestRuntime _testRuntime; private TestRuntime _testRuntime;
private static bool _excludeSelectedCases; private static bool _excludeSelectedCases;
private static bool _isDebug; private static bool _isDebug;
private static bool _saveToAssemblies;
private static bool _runTokenizerDriver; private static bool _runTokenizerDriver;
private static bool _displayList; private static bool _displayList;
private static bool _partialTrust; private static bool _partialTrust;
Expand All @@ -116,6 +116,10 @@ public class Driver {
get { return _isDebug; } get { return _isDebug; }
} }


public bool SaveToAssemblies {
get { return _saveToAssemblies; }
}

public bool PartialTrust { public bool PartialTrust {
get { return _partialTrust; } get { return _partialTrust; }
} }
Expand All @@ -132,8 +136,10 @@ public class Driver {
if (args.Contains("/help") || args.Contains("-?") || args.Contains("/?") || args.Contains("-help")) { if (args.Contains("/help") || args.Contains("-?") || args.Contains("/?") || args.Contains("-help")) {
Console.WriteLine("Partial trust : /partial"); Console.WriteLine("Partial trust : /partial");
Console.WriteLine("Interpret : /interpret"); Console.WriteLine("Interpret : /interpret");
Console.WriteLine("Save to assemblies : /save");
Console.WriteLine("Debug Mode : /debug");
Console.WriteLine("Disable Python interop tests : /py-"); Console.WriteLine("Disable Python interop tests : /py-");
Console.WriteLine("Run Specific Tests : [/debug] [/exclude] [test_to_run ...]"); Console.WriteLine("Run Specific Tests : [/exclude] [test_to_run ...]");
Console.WriteLine("List Tests : /list"); Console.WriteLine("List Tests : /list");
Console.WriteLine("Tokenizer baseline : /tokenizer <target-dir> <sources-file>"); Console.WriteLine("Tokenizer baseline : /tokenizer <target-dir> <sources-file>");
Console.WriteLine("Productions dump : /tokenizer /prod <target-dir> <sources-file>"); Console.WriteLine("Productions dump : /tokenizer /prod <target-dir> <sources-file>");
Expand All @@ -150,6 +156,11 @@ public class Driver {
_isDebug = true; _isDebug = true;
} }


if (args.Contains("/save")) {
args.Remove("/save");
_saveToAssemblies = true;
}

if (args.Contains("/partial")) { if (args.Contains("/partial")) {
args.Remove("/partial"); args.Remove("/partial");
_partialTrust = true; _partialTrust = true;
Expand Down Expand Up @@ -278,7 +289,7 @@ public sealed class Loader : MarshalByRefObject {
} }


private static void InitializeDomain() { private static void InitializeDomain() {
if (_isDebug) { if (_saveToAssemblies) {
string _dumpDir = Path.Combine(Path.GetTempPath(), "RubyTests"); string _dumpDir = Path.Combine(Path.GetTempPath(), "RubyTests");


if (Directory.Exists(_dumpDir)) { if (Directory.Exists(_dumpDir)) {
Expand Down Expand Up @@ -374,7 +385,11 @@ public sealed class Loader : MarshalByRefObject {
failedCases.Add(test); failedCases.Add(test);


Console.Error.WriteLine(); Console.Error.WriteLine();
WriteError("{0}) {1} {2} : {3}", failedCases.Count, test, frame.GetFileName(), frame.GetFileLineNumber()); if (_partialTrust) {
WriteError("{0}) {1}", failedCases.Count, test);
} else {
WriteError("{0}) {1} {2} : {3}", failedCases.Count, test, frame.GetFileName(), frame.GetFileLineNumber());
}
Console.Error.WriteLine(message); Console.Error.WriteLine(message);
} }
} }
Expand All @@ -397,7 +412,12 @@ public sealed class Loader : MarshalByRefObject {
Console.ForegroundColor = ConsoleColor.Gray; Console.ForegroundColor = ConsoleColor.Gray;
} else { } else {
Console.WriteLine(); Console.WriteLine();
Console.Write("Repro: {0}", Environment.CommandLine); // TODO:
if (!_partialTrust) {
Console.Write("Repro: {0}", Environment.CommandLine);
} else {
Console.Write("Repro: IronRuby.Tests.exe /partial");
}
if (largs.Count == 0) { if (largs.Count == 0) {
Console.Write(" {0}", String.Join(" ", failedCases.ToArray())); Console.Write(" {0}", String.Join(" ", failedCases.ToArray()));
} }
Expand Down
2 changes: 1 addition & 1 deletion Merlin/Main/Languages/Ruby/IronRuby.Tests/Helpers.cs
Expand Up @@ -113,7 +113,7 @@ public partial class Tests {


string name = _driver.TestRuntime.TestName; string name = _driver.TestRuntime.TestName;


if (_driver.IsDebug) { if (_driver.SaveToAssemblies) {
string path = Path.Combine(Snippets.Shared.SnippetsDirectory, name + ".rb"); string path = Path.Combine(Snippets.Shared.SnippetsDirectory, name + ".rb");
Directory.CreateDirectory(Snippets.Shared.SnippetsDirectory); Directory.CreateDirectory(Snippets.Shared.SnippetsDirectory);
File.WriteAllText(path, code); File.WriteAllText(path, code);
Expand Down
Expand Up @@ -890,8 +890,8 @@ p __ENCODING__


const int Id = 0x12345678; const int Id = 0x12345678;


var lambda = CallSiteTracer.Transform<DlrMainCallTarget>(ast, sourceUnit, options, Id); var lambda = CallSiteTracer.Transform<Func<Scope, LanguageContext, object>>(ast, sourceUnit, options, Id);
var code = new LegacyScriptCode(lambda, sourceUnit); var code = new RubyScriptCode(lambda, sourceUnit);


var locations = new List<int>(); var locations = new List<int>();
CallSiteTracer.Register((context, args, result, id, location) => { CallSiteTracer.Register((context, args, result, id, location) => {
Expand Down
Expand Up @@ -15,10 +15,11 @@


using Microsoft.Scripting; using Microsoft.Scripting;
using System; using System;

namespace IronRuby.Tests { namespace IronRuby.Tests {
public partial class Tests { public partial class Tests {
private bool PreciseTraces { private bool PreciseTraces {
get { return !_driver.PartialTrust || _driver.Interpret; } get { return Runtime.Setup.DebugMode || _driver.Interpret; }
} }


public void Backtrace1() { public void Backtrace1() {
Expand Down Expand Up @@ -171,13 +172,13 @@ def foo
}, PreciseTraces ? @" }, PreciseTraces ? @"
Backtrace4.rb:7:in `baz' Backtrace4.rb:7:in `baz'
Backtrace4.rb:11:in `foo' Backtrace4.rb:11:in `foo'
*.cs:*:in `Bar' *:*:in `Bar'
Backtrace4.rb:11:in `foo' Backtrace4.rb:11:in `foo'
Backtrace4.rb:14 Backtrace4.rb:14
" : @" " : @"
Backtrace4.rb:6:in `baz' Backtrace4.rb:6:in `baz'
Backtrace4.rb:11:in `foo' Backtrace4.rb:11:in `foo'
:0:in `Bar' *:*:in `Bar'
Backtrace4.rb:10:in `foo' Backtrace4.rb:10:in `foo'
Backtrace4.rb:0 Backtrace4.rb:0
", OutputFlags.Match); ", OutputFlags.Match);
Expand Down
Expand Up @@ -41,22 +41,22 @@ public partial class Tests {
b = Loader.TryParseAssemblyName(str, out type, out assembly); b = Loader.TryParseAssemblyName(str, out type, out assembly);
Assert(b == false); Assert(b == false);


str = "IronRuby.Runtime.RubyContext, IronRuby, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; str = "IronRuby.Runtime.RubyContext, IronRuby, Version=0.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
b = Loader.TryParseAssemblyName(str, out type, out assembly); b = Loader.TryParseAssemblyName(str, out type, out assembly);
Assert(b == true && Assert(b == true &&
assembly == "IronRuby, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" && assembly == "IronRuby, Version=0.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" &&
type == "IronRuby.Runtime.RubyContext" type == "IronRuby.Runtime.RubyContext"
); );


str = "IronRuby, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; str = "IronRuby, Version=0.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
b = Loader.TryParseAssemblyName(str, out type, out assembly); b = Loader.TryParseAssemblyName(str, out type, out assembly);
Assert(b == true && assembly == str && type == null); Assert(b == true && assembly == str && type == null);


str = "IronRuby, Culture=neutral, PublicKeyToken=31bf3856ad364e35"; str = "IronRuby, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
b = Loader.TryParseAssemblyName(str, out type, out assembly); b = Loader.TryParseAssemblyName(str, out type, out assembly);
Assert(b == true && assembly == str && type == null); Assert(b == true && assembly == str && type == null);


str = "IronRuby, Version=1.0.0.0"; str = "IronRuby, Version=0.3.0.0";
b = Loader.TryParseAssemblyName(str, out type, out assembly); b = Loader.TryParseAssemblyName(str, out type, out assembly);
Assert(b == true && assembly == str && type == null); Assert(b == true && assembly == str && type == null);
} }
Expand Down
Expand Up @@ -324,7 +324,7 @@ public static class ModuleOps {
); );
} }


self.SetDefinedMethodNoEventNoLock(self.Context, methodName, info, attributesScope.Visibility); self.SetDefinedMethodNoEventNoLock(self.Context, methodName, info, visibility);
} }


self.Context.MethodAdded(self, methodName); self.Context.MethodAdded(self, methodName);
Expand Down
Expand Up @@ -395,9 +395,9 @@ public static class Protocols {
return tt.Type; return tt.Type;
} }


RubyClass rc = value as RubyClass; RubyModule module = value as RubyModule;
if (rc != null) { if (module != null) {
return rc.GetUnderlyingSystemType(); return module.GetUnderlyingSystemType();
} }


throw RubyExceptions.InvalidValueForType(context, value, "Class"); throw RubyExceptions.InvalidValueForType(context, value, "Class");
Expand Down
2 changes: 1 addition & 1 deletion Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyClass.cs
Expand Up @@ -166,7 +166,7 @@ public sealed partial class RubyClass : RubyModule, IDuplicable {
} }
#endif #endif


public Type/*!*/ GetUnderlyingSystemType() { public override Type/*!*/ GetUnderlyingSystemType() {
if (_isSingletonClass) { if (_isSingletonClass) {
throw new InvalidOperationException("Singleton class doesn't have underlying system type."); throw new InvalidOperationException("Singleton class doesn't have underlying system type.");
} }
Expand Down
8 changes: 8 additions & 0 deletions Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs
Expand Up @@ -108,6 +108,14 @@ private enum MemberTableState {
get { return _tracker != null && _tracker.Type.IsInterface; } get { return _tracker != null && _tracker.Type.IsInterface; }
} }


public virtual Type/*!*/ GetUnderlyingSystemType() {
if (IsInterface) {
return _tracker.Type;
} else {
throw new InvalidOperationException();
}
}

public RubyClass/*!*/ SingletonClass { public RubyClass/*!*/ SingletonClass {
get { get {
Debug.Assert(_singletonClass != null); Debug.Assert(_singletonClass != null);
Expand Down
Expand Up @@ -173,11 +173,12 @@ public BlockDefinition(LexicalScope definedScope, CompoundLeftValue/*!*/ paramet
gen.CurrentScopeVariable, gen.CurrentScopeVariable,
gen.CurrentRfcVariable, gen.CurrentRfcVariable,
gen.CurrentSelfVariable, gen.CurrentSelfVariable,
Ast.Lambda( BlockDispatcher.CreateLambda(
BlockDispatcher.GetDelegateType(parameterCount, attributes),
body, body,
RubyExceptionData.EncodeMethodName(gen.SourceUnit, gen.CurrentMethod.MethodName, Location), RubyExceptionData.EncodeMethodName(gen.SourceUnit, gen.CurrentMethod.MethodName, Location),
new ReadOnlyCollection<MSA.ParameterExpression>(parameters) new ReadOnlyCollection<MSA.ParameterExpression>(parameters),
parameterCount,
attributes
), ),
AstUtils.Constant(parameterCount), AstUtils.Constant(parameterCount),
AstUtils.Constant(attributes) AstUtils.Constant(attributes)
Expand Down

0 comments on commit cd98845

Please sign in to comment.