5 // Cesar Lopez Nataren (cesar@ciencias.unam.mx)
7 // (C) 2003, Cesar Lopez Nataren
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using Microsoft.JScript.Vsa;
34 namespace Microsoft.JScript {
36 public sealed class Convert {
38 public static bool IsBadIndex (AST ast)
40 throw new NotImplementedException ();
44 public static double CheckIfDoubleIsInteger (double d)
46 if (d == Math.Round (d))
48 throw new NotImplementedException ();
52 public static Single CheckIfSingleIsInteger (Single s)
54 if (s == Math.Round (s))
56 throw new NotImplementedException ();
60 public static object Coerce (object value, object type)
62 throw new NotImplementedException ();
66 public static object CoerceT (object value, Type t, bool explicitOK)
68 throw new NotImplementedException ();
72 public static object Coerce2 (object value, TypeCode target,
73 bool truncationPermitted)
75 throw new NotImplementedException ();
78 public static void ThrowTypeMismatch (object val)
80 throw new NotImplementedException ();
84 public static bool ToBoolean (double d)
86 throw new NotImplementedException ();
90 public static bool ToBoolean (object value)
92 throw new NotImplementedException ();
96 public static bool ToBoolean (object value, bool explicitConversion)
102 public static object ToForInObject (object value, VsaEngine engine)
104 throw new NotImplementedException ();
108 public static int ToInt32 (object value)
110 throw new NotImplementedException ();
114 public static double ToNumber (object value)
116 throw new NotImplementedException ();
120 public static double ToNumber (string str)
122 throw new NotImplementedException ();
126 public static object ToNativeArray (object value, RuntimeTypeHandle handle)
128 throw new NotImplementedException ();
132 public static object ToObject (object value, VsaEngine engine)
134 throw new NotImplementedException ();
138 public static object ToObject2 (object value, VsaEngine engine)
140 throw new NotImplementedException ();
144 internal static string ToString (object obj)
146 return Convert.ToString (obj, true);
149 public static string ToString (object value, bool explicitOK)
151 IConvertible ic = value as IConvertible;
152 TypeCode tc = Convert.GetTypeCode (value, ic);
155 case TypeCode.DBNull:
158 case TypeCode.String:
159 case TypeCode.Double:
160 return ic.ToString (null);
162 case TypeCode.Object:
163 if (value is ArrayObject)
164 return ArrayPrototype.toString (value);
165 else if (value is BooleanObject)
166 return BooleanPrototype.toString (value);
167 else if (value is DateObject)
168 return DatePrototype.toString (value);
169 else if (value is ErrorObject)
170 return ErrorPrototype.toString (value);
171 else if (value is FunctionObject)
172 return FunctionPrototype.toString (value);
173 else if (value is NumberObject)
174 return NumberPrototype.toString (value, 10);
175 else if (value is ObjectPrototype)
176 return ObjectPrototype.toString (value);
177 else if (value is RegExpObject)
178 return RegExpPrototype.toString (value);
179 else if (value is StringObject)
180 return StringPrototype.toString (value);
181 throw new NotImplementedException ();
183 throw new NotImplementedException ();
188 public static string ToString (bool b)
190 return b ? "true" : "false";
194 public static string ToString (double d)
196 IConvertible ic = d as IConvertible;
197 return ic.ToString (null);
203 internal static TypeCode GetTypeCode (object obj, IConvertible ic)
206 return TypeCode.Empty;
208 return TypeCode.Object;
210 return ic.GetTypeCode ();