* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / Microsoft.JScript / Microsoft.JScript / BooleanPrototype.cs
index 12efd1411c38591392e2a092401eea19da06e72b..daeaece6703de1a7c56006b2ba6eef09b006e05d 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-namespace Microsoft.JScript.Tmp
-{
-       using System;
+using System;
+
+namespace Microsoft.JScript {
+
+       public class BooleanPrototype : BooleanObject {
+
+               internal static BooleanPrototype Proto = new BooleanPrototype (null, null);
 
-       public class BooleanPrototype : BooleanObject
-       {
                public static BooleanConstructor constructor {
-                       get { throw new NotImplementedException (); }
+                       get { return BooleanConstructor.Ctr; }
                }
 
-       
+               [JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Boolean_toString)]
                public static string toString (object thisObj)
                {
-                       throw new NotImplementedException ();
-               }
+                       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";
+               }
+
+               [JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Boolean_valueOf)]
                public static object valueOf (object thisObj)
                {
-                       throw new NotImplementedException ();
+                       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)
+               {
                }
        }
-}
\ No newline at end of file
+}
+
+