dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/JScript/Jsc BitwiseBinary.cs, 1.1, 1


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/JScript/Jsc BitwiseBinary.cs, 1.1, 1.2 Instanceof.cs, 1.1, 1.2 Plus.cs, 1.1, 1.2 Relational.cs, 1.1, 1.2
Date: Wed, 06 Aug 2003 20:39:20 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/JScript/Jsc
In directory subversions:/tmp/cvs-serv2589/JScript/Jsc

Modified Files:
        BitwiseBinary.cs Instanceof.cs Plus.cs Relational.cs 
Log Message:


Implement some easy TODO's in JScript.


Index: BitwiseBinary.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Jsc/BitwiseBinary.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** BitwiseBinary.cs    13 Jan 2003 10:53:19 -0000      1.1
--- BitwiseBinary.cs    7 Aug 2003 00:39:18 -0000       1.2
***************
*** 39,44 ****
        public Object EvaluateBitwiseBinary(Object v1, Object v2)
                        {
!                               // TODO
!                               return null;
                        }
  
--- 39,63 ----
        public Object EvaluateBitwiseBinary(Object v1, Object v2)
                        {
!                               int val1 = Convert.ToInt32(v1);
!                               int val2 = Convert.ToInt32(v2);
!                               Object result;
!                               switch(operatorTok)
!                               {
!                                       case JSToken.BitwiseAnd:
!                                               result = val1 & val2; break;
!                                       case JSToken.BitwiseOr:
!                                               result = val1 | val2; break;
!                                       case JSToken.BitwiseXor:
!                                               result = val1 ^ val2; break;
!                                       case JSToken.LeftShift:
!                                               result = val1 << val2; break;
!                                       case JSToken.RightShift:
!                                               result = val1 >> val2; break;
!                                       case JSToken.UnsignedRightShift:
!                                               result = ((uint)val1) >> val2; 
break;
!                                       default:
!                                               throw new 
JScriptException(JSError.InternalError);
!                               }
!                               return result;
                        }
  

Index: Instanceof.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Jsc/Instanceof.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Instanceof.cs       13 Jan 2003 10:53:20 -0000      1.1
--- Instanceof.cs       7 Aug 2003 00:39:18 -0000       1.2
***************
*** 35,40 ****
        public static bool JScriptInstanceof(Object v1, Object v2)
                        {
!                               // TODO
!                               return false;
                        }
  
--- 35,69 ----
        public static bool JScriptInstanceof(Object v1, Object v2)
                        {
!                               if(v2 is ScriptFunction)
!                               {
!                                       // Check for function instances.
!                                       return 
((ScriptFunction)v2).HasInstance(v1);
!                               }
!                               else if(v1 == null)
!                               {
!                                       // Null is never an instance of any 
type.
!                                       return false;
!                               }
!                               else if(v2 is Type)
!                               {
!                                       // Try to coerce to the destination 
type.
!                                       Type type = (Type)v2;
!                                       if(v1 is IConvertible)
!                                       {
!                                               try
!                                               {
!                                                       Convert.CoerceT(v1, 
type, false);
!                                               }
!                                               catch(JScriptException)
!                                               {
!                                                       return false;
!                                               }
!                                       }
!                                       return 
type.IsAssignableFrom(v1.GetType());
!                               }
!                               else
!                               {
!                                       throw new 
JScriptException(JSError.NeedType);
!                               }
                        }
  

Index: Plus.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Jsc/Plus.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Plus.cs     13 Jan 2003 10:53:20 -0000      1.1
--- Plus.cs     7 Aug 2003 00:39:18 -0000       1.2
***************
*** 34,39 ****
        public Object EvaluatePlus(Object v1, Object v2)
                        {
!                               // TODO
!                               return null;
                        }
  
--- 34,38 ----
        public Object EvaluatePlus(Object v1, Object v2)
                        {
!                               return DoOp(v1, v2);
                        }
  
***************
*** 41,46 ****
        public static Object DoOp(Object v1, Object v2)
                        {
!                               // TODO
!                               return null;
                        }
  
--- 40,53 ----
        public static Object DoOp(Object v1, Object v2)
                        {
!                               v1 = Convert.ToPrimitive(v1, 
DefaultValueHint.None);
!                               v2 = Convert.ToPrimitive(v2, 
DefaultValueHint.None);
!                               if(v1 is String || v2 is String)
!                               {
!                                       return ((String)v1) + ((String)v2);
!                               }
!                               else
!                               {
!                                       return Convert.ToNumber(v1) + 
Convert.ToNumber(v2);
!                               }
                        }
  

Index: Relational.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Jsc/Relational.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Relational.cs       13 Jan 2003 10:53:20 -0000      1.1
--- Relational.cs       7 Aug 2003 00:39:18 -0000       1.2
***************
*** 37,44 ****
  
        // Evaluate a relational operator on two values.
!       public double EvaluatRelational(Object v1, Object v2)
                        {
!                               // TODO
!                               return 0.0;
                        }
  
--- 37,43 ----
  
        // Evaluate a relational operator on two values.
!       public double EvaluateRelational(Object v1, Object v2)
                        {
!                               return JScriptCompare(v1, v2);
                        }
  
***************
*** 46,51 ****
        public static double JScriptCompare(Object v1, Object v2)
                        {
!                               // TODO
!                               return 0.0;
                        }
  
--- 45,58 ----
        public static double JScriptCompare(Object v1, Object v2)
                        {
!                               v1 = Convert.ToPrimitive(v1, 
DefaultValueHint.None);
!                               v2 = Convert.ToPrimitive(v2, 
DefaultValueHint.None);
!                               if(v1 is String && v2 is String)
!                               {
!                                       return 
String.CompareOrdinal((String)v1, (String)v2);
!                               }
!                               else
!                               {
!                                       return (Convert.ToNumber(v1) - 
Convert.ToNumber(v2));
!                               }
                        }
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]