Skip to content

Commit

Permalink
Sync to head of tfs
Browse files Browse the repository at this point in the history
  • Loading branch information
jredville committed Sep 23, 2009
1 parent 8040396 commit 0b6b16d
Show file tree
Hide file tree
Showing 39 changed files with 407 additions and 197 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Expand Up @@ -4175,7 +4175,7 @@ public static partial class PythonOps {
}

internal static void ScopeSetMember(CodeContext context, Scope scope, string name, object value) {
ScopeStorage scopeStorage = scope.Storage as ScopeStorage;
ScopeStorage scopeStorage = ((object)scope.Storage) as ScopeStorage;
if (scopeStorage != null) {
scopeStorage.SetValue(name, false, value);
return;
Expand All @@ -4185,7 +4185,7 @@ public static partial class PythonOps {
}

internal static object ScopeGetMember(CodeContext context, Scope scope, string name) {
ScopeStorage scopeStorage = scope.Storage as ScopeStorage;
ScopeStorage scopeStorage = ((object)scope.Storage) as ScopeStorage;
if (scopeStorage != null) {
return scopeStorage.GetValue(name, false);
}
Expand All @@ -4194,7 +4194,7 @@ public static partial class PythonOps {
}

internal static bool ScopeTryGetMember(CodeContext context, Scope scope, string name, out object value) {
ScopeStorage scopeStorage = scope.Storage as ScopeStorage;
ScopeStorage scopeStorage = ((object)scope.Storage) as ScopeStorage;
if (scopeStorage != null) {
return scopeStorage.TryGetValue(name, false, out value);
}
Expand All @@ -4203,7 +4203,7 @@ public static partial class PythonOps {
}

internal static bool ScopeContainsMember(CodeContext context, Scope scope, string name) {
ScopeStorage scopeStorage = scope.Storage as ScopeStorage;
ScopeStorage scopeStorage = ((object)scope.Storage) as ScopeStorage;
if (scopeStorage != null) {
return scopeStorage.HasValue(name, false);
}
Expand All @@ -4212,7 +4212,7 @@ public static partial class PythonOps {
}

internal static bool ScopeDeleteMember(CodeContext context, Scope scope, string name) {
ScopeStorage scopeStorage = scope.Storage as ScopeStorage;
ScopeStorage scopeStorage = ((object)scope.Storage) as ScopeStorage;
if (scopeStorage != null) {
return scopeStorage.DeleteValue(name, false);
}
Expand All @@ -4223,7 +4223,7 @@ public static partial class PythonOps {
}

internal static IList<object> ScopeGetMemberNames(CodeContext context, Scope scope) {
ScopeStorage scopeStorage = scope.Storage as ScopeStorage;
ScopeStorage scopeStorage = ((object)scope.Storage) as ScopeStorage;
if (scopeStorage != null) {
List<object> res = new List<object>();

Expand Down
Binary file not shown.
Binary file not shown.
Expand Up @@ -344,7 +344,7 @@ public class EngineTest
ScriptSource src = engine.CreateScriptSourceFromString("x.Bar()");
ScriptScope scope = engine.CreateScope();
scope.SetVariable("x", new Fooable());
AreEqual(src.Execute(scope), "Bar Called");
AreEqual((object)src.Execute(scope), "Bar Called");
}

class MyInvokeMemberBinder : InvokeMemberBinder {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Merlin/Main/Languages/Ruby/Console/Ruby.Console.Build.csproj
Binary file not shown.
Expand Up @@ -21,7 +21,7 @@ public partial class Tests {
Assert(RubyUtils.TryUnmangleName("stack") == "Stack");
Assert(RubyUtils.TryUnmangleName("this_is_my_long_name") == "ThisIsMyLongName");
Assert(RubyUtils.TryUnmangleName("f") == "F");
Assert(RubyUtils.TryUnmangleName("initialize") == null);
Assert(RubyUtils.TryUnmangleName("initialize") == "Initialize");

// non-alpha characters are treated as lower-case letters:
Assert(RubyUtils.TryUnmangleName("foo_bar=") == "FooBar=");
Expand Down Expand Up @@ -72,13 +72,18 @@ public partial class Tests {
Assert(RubyUtils.TryUnmangleName("foo__bar") == null);
Assert(RubyUtils.TryUnmangleName("_foo") == null);
Assert(RubyUtils.TryUnmangleName("foo_") == null);

// special method names:
Assert(RubyUtils.TryUnmangleMethodName("initialize") == null);
Assert(RubyUtils.TryUnmangleMethodName("class") == null);
Assert(RubyUtils.TryUnmangleMethodName("message") == "Message"); // we don't special case Exception.Message
}

public void NameMangling2() {
Assert(RubyUtils.TryMangleName("Stack") == "stack");
Assert(RubyUtils.TryMangleName("ThisIsMyLongName") == "this_is_my_long_name");
Assert(RubyUtils.TryMangleName("F") == "f");
Assert(RubyUtils.TryMangleName("Initialize") == null);
Assert(RubyUtils.TryMangleName("Initialize") == "initialize");
Assert(RubyUtils.TryMangleName("fooBar") == "foo_bar");

// characters that are not upper case letters are treated as lower-case:
Expand Down Expand Up @@ -139,6 +144,11 @@ public partial class Tests {
Assert(RubyUtils.TryMangleName("foo__bar") == null);
Assert(RubyUtils.TryMangleName("_foo") == null);
Assert(RubyUtils.TryMangleName("foo_") == null);

// special method names:
Assert(RubyUtils.TryMangleMethodName("Initialize") == null);
Assert(RubyUtils.TryMangleMethodName("Class") == null);
Assert(RubyUtils.TryMangleMethodName("Message") == "message"); // we don't special case Exception.Message
}
}
}
Expand Up @@ -891,13 +891,13 @@ public static class ModuleOps {
var symbolicNames = self.Context.RubyOptions.Compatibility > RubyCompatibility.Ruby18;

using (self.Context.ClassHierarchyLocker()) {
self.ForEachMember(inherited, attributes, foreignMembers, (name, module, member) =>
result.Add(
member.IsInteropMember && (module.Restrictions & ModuleRestrictions.NoNameMangling) == 0 ?
new ClrName(name) :
CreateMethodName(name, symbolicNames)
)
);
self.ForEachMember(inherited, attributes, foreignMembers, (name, module, member) => {
if (member.IsInteropMember && (module.Restrictions & ModuleRestrictions.NoNameMangling) == 0 && RubyUtils.HasMangledName(name)) {
result.Add(new ClrName(name));
} else {
result.Add(CreateMethodName(name, symbolicNames));
}
});
}
return result;
}
Expand Down
Expand Up @@ -621,9 +621,8 @@ public sealed class ClrBigInteger {
/// <returns>true or false</returns>
/// <remarks>Returns false if other is NaN.</remarks>
[RubyMethod("==")]
public static bool Equal(BigInteger/*!*/ self, double other) {
if (Double.IsNaN(other)) return false;
return (double)self == other;
public static bool Equal(RubyContext/*!*/ context, BigInteger/*!*/ self, double other) {
return !Double.IsNaN(other) && Protocols.ConvertToDouble(context, self) == other;
}

/// <summary>
Expand Down Expand Up @@ -902,13 +901,7 @@ public sealed class ClrBigInteger {
/// <returns>self as a Float</returns>
[RubyMethod("to_f")]
public static double ToFloat(RubyContext/*!*/ context, BigInteger/*!*/ self) {
try {
return self.ToFloat64();
} catch (OverflowException) {
// If the BigInteger is too big for a float then we return infinity.
context.ReportWarning("Bignum out of Float range");
return self.Sign > 0 ? Double.PositiveInfinity : Double.NegativeInfinity;
}
return Protocols.ConvertToDouble(context, self);
}

#endregion
Expand Down
Expand Up @@ -86,8 +86,8 @@ public static class ClrFloat {
/// </summary>
/// <returns>Float</returns>
[RubyMethod("*")]
public static double Multiply(double self, [NotNull]BigInteger/*!*/ other) {
return self * (double)other;
public static double Multiply(RubyContext/*!*/ context, double self, [NotNull]BigInteger/*!*/ other) {
return self * Protocols.ConvertToDouble(context, other);
}

/// <summary>
Expand Down Expand Up @@ -126,8 +126,8 @@ public static class ClrFloat {
/// </summary>
/// <returns>Float</returns>
[RubyMethod("+")]
public static double Add(double self, [NotNull]BigInteger/*!*/ other) {
return self + (double)other;
public static double Add(RubyContext/*!*/ context, double self, [NotNull]BigInteger/*!*/ other) {
return self + Protocols.ConvertToDouble(context, other);
}

/// <summary>
Expand Down Expand Up @@ -166,8 +166,8 @@ public static class ClrFloat {
/// </summary>
/// <returns>Float</returns>
[RubyMethod("-")]
public static double Subtract(double self, [NotNull]BigInteger/*!*/ other) {
return self - (double)other;
public static double Subtract(RubyContext/*!*/ context, double self, [NotNull]BigInteger/*!*/ other) {
return self - Protocols.ConvertToDouble(context, other);
}

/// <summary>
Expand Down Expand Up @@ -206,8 +206,8 @@ public static class ClrFloat {
/// </summary>
/// <returns>Float</returns>
[RubyMethod("/")]
public static double Divide(double self, [NotNull]BigInteger/*!*/ other) {
return self / (double)other;
public static double Divide(RubyContext/*!*/ context, double self, [NotNull]BigInteger/*!*/ other) {
return self / Protocols.ConvertToDouble(context, other);
}

/// <summary>
Expand Down Expand Up @@ -246,8 +246,8 @@ public static class ClrFloat {
/// </summary>
/// <returns>Float</returns>
[RubyMethod("%"), RubyMethod("modulo")]
public static double Modulo(double self, [NotNull]BigInteger/*!*/ other) {
return (double)InternalDivMod(self, (double)other)[1];
public static double Modulo(RubyContext/*!*/ context, double self, [NotNull]BigInteger/*!*/ other) {
return (double)InternalDivMod(self, Protocols.ConvertToDouble(context, other))[1];
}

/// <summary>
Expand Down Expand Up @@ -293,8 +293,8 @@ public static class ClrFloat {
/// Raises <code>self</code> the <code>other</code> power, where other is Bignum.
/// </summary>
[RubyMethod("**")]
public static double Power(double self, [NotNull]BigInteger/*!*/ other) {
return Math.Pow(self, (double)other);
public static double Power(RubyContext/*!*/ context, double self, [NotNull]BigInteger/*!*/ other) {
return Math.Pow(self, Protocols.ConvertToDouble(context, other));
}

/// <summary>
Expand Down Expand Up @@ -347,8 +347,8 @@ public static class ClrFloat {
/// The quotient is rounded toward -infinity
/// </remarks>
[RubyMethod("divmod")]
public static RubyArray DivMod(double self, [NotNull]BigInteger/*!*/ other) {
return DivMod(self, (double)other);
public static RubyArray DivMod(RubyContext/*!*/ context, double self, [NotNull]BigInteger/*!*/ other) {
return DivMod(self, Protocols.ConvertToDouble(context, other));
}

/// <summary>
Expand Down Expand Up @@ -642,11 +642,11 @@ public static class ClrFloat {
/// This is the basis for the tests in <code>Comparable</code>.
/// </remarks>
[RubyMethod("<=>")]
public static object Compare(double self, [NotNull]BigInteger/*!*/ other) {
public static object Compare(RubyContext/*!*/ context, double self, [NotNull]BigInteger/*!*/ other) {
if (Double.IsNaN(self)) {
return null;
}
return self.CompareTo((double)other);
return self.CompareTo(Protocols.ConvertToDouble(context, other));
}

/// <summary>
Expand Down Expand Up @@ -693,8 +693,8 @@ public static class ClrFloat {
/// Returns true if self is less than other, where other is Bignum.
/// </summary>
[RubyMethod("<")]
public static bool LessThan(double self, [NotNull]BigInteger/*!*/ other) {
return LessThan(self, (double)other);
public static bool LessThan(RubyContext/*!*/ context, double self, [NotNull]BigInteger/*!*/ other) {
return LessThan(self, Protocols.ConvertToDouble(context, other));
}

/// <summary>
Expand Down Expand Up @@ -732,8 +732,8 @@ public static class ClrFloat {
/// Returns true if self is less than or equal to other, where other is Bignum.
/// </summary>
[RubyMethod("<=")]
public static bool LessThanOrEqual(double self, [NotNull]BigInteger/*!*/ other) {
return LessThanOrEqual(self, (double)other);
public static bool LessThanOrEqual(RubyContext/*!*/ context, double self, [NotNull]BigInteger/*!*/ other) {
return LessThanOrEqual(self, Protocols.ConvertToDouble(context, other));
}

/// <summary>
Expand Down Expand Up @@ -771,8 +771,8 @@ public static class ClrFloat {
/// Returns true if self is greater than other, where other is Bignum.
/// </summary>
[RubyMethod(">")]
public static bool GreaterThan(double self, [NotNull]BigInteger/*!*/ other) {
return GreaterThan(self, (double)other);
public static bool GreaterThan(RubyContext/*!*/ context, double self, [NotNull]BigInteger/*!*/ other) {
return GreaterThan(self, Protocols.ConvertToDouble(context, other));
}

/// <summary>
Expand Down Expand Up @@ -810,8 +810,8 @@ public static class ClrFloat {
/// Returns true if self is greater than or equal to other, where other is Bignum.
/// </summary>
[RubyMethod(">=")]
public static bool GreaterThanOrEqual(double self, [NotNull]BigInteger/*!*/ other) {
return GreaterThanOrEqual(self, (double)other);
public static bool GreaterThanOrEqual(RubyContext/*!*/ context, double self, [NotNull]BigInteger/*!*/ other) {
return GreaterThanOrEqual(self, Protocols.ConvertToDouble(context, other));
}

/// <summary>
Expand Down

0 comments on commit 0b6b16d

Please sign in to comment.