* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / Microsoft.JScript / Microsoft.JScript / BooleanPrototype.cs
index 82228fa7da8af94e60be1cac96822b002b766334..daeaece6703de1a7c56006b2ba6eef09b006e05d 100644 (file)
@@ -34,6 +34,8 @@ namespace Microsoft.JScript {
 
        public class BooleanPrototype : BooleanObject {
 
+               internal static BooleanPrototype Proto = new BooleanPrototype (null, null);
+
                public static BooleanConstructor constructor {
                        get { return BooleanConstructor.Ctr; }
                }
@@ -41,7 +43,12 @@ namespace Microsoft.JScript {
                [JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Boolean_toString)]
                public static string toString (object thisObj)
                {
-                       SemanticAnalyser.assert_type (thisObj, typeof (BooleanObject));
+                       if (!Convert.IsBoolean (thisObj))
+                               throw new JScriptException (JSError.BooleanExpected);
+
+                       if (thisObj is bool)
+                               return (bool) thisObj ? "true" : "false";
+
                        BooleanObject bo = thisObj as BooleanObject;
                        return bo.value ? "true" : "false";
                }
@@ -49,14 +56,18 @@ namespace Microsoft.JScript {
                [JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Boolean_valueOf)]
                public static object valueOf (object thisObj)
                {
-                       SemanticAnalyser.assert_type (thisObj, typeof (BooleanObject));
+                       if (!Convert.IsBoolean (thisObj))
+                               throw new JScriptException (JSError.BooleanExpected);
+
+                       if (thisObj is bool)
+                               return thisObj;
+
                        BooleanObject bo = thisObj as BooleanObject;
                        return bo.value;
                }
 
                protected BooleanPrototype (ObjectPrototype prototype, Type baseType)
                {
-                       throw new NotImplementedException ();
                }
        }
 }