2004-11-08 Cesar Lopez Nataren <cesar@ciencias.unam.mx>
authorCésar Natarén <cesar@mono-cvs.ximian.com>
Mon, 8 Nov 2004 23:33:28 +0000 (23:33 -0000)
committerCésar Natarén <cesar@mono-cvs.ximian.com>
Mon, 8 Nov 2004 23:33:28 +0000 (23:33 -0000)
* expression.cs: emit unary operator code.
* TypeOf.cs: back to Microsoft.JScript namespace. fix typo.
* Literal.cs: constrain more the case of negative numeric literal.

svn path=/trunk/mcs/; revision=35868

mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog
mcs/class/Microsoft.JScript/Microsoft.JScript/Literal.cs
mcs/class/Microsoft.JScript/Microsoft.JScript/TypeOf.cs
mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs

index a7de33c13b027a59126f9fdb93024b3efb5a2091..4aa5860bd6e69a3fa348369634e29f52ef064130 100644 (file)
@@ -1,5 +1,9 @@
 2004-11-08  Cesar Lopez Nataren  <cesar@ciencias.unam.mx>
 
+       * expression.cs: emit unary operator code.
+       * TypeOf.cs: back to Microsoft.JScript namespace. fix typo.
+       * Literal.cs: constrain more the case of negative numeric literal.
+
        * expression.cs (emit_func_call): pop if function's return type is
        non-void and has no effect. 
 
index ed6bec4b5dfd920fc755423ae44160539e997021..5700443aa103b82b12138287d3621a99d6aca016 100644 (file)
@@ -122,11 +122,9 @@ namespace Microsoft.JScript {
                internal override void Emit (EmitContext ec)
                {
                        ILGenerator ig = ec.ig;
-                       if (parent is Unary) {
-                               Unary tmp = parent as Unary;
-                               if (tmp.oper == JSToken.Minus)
-                                       ig.Emit (OpCodes.Ldc_R8, (double) (val * -1));
-                       } else
+                       if (parent is Unary && (parent as Unary).oper == JSToken.Minus)
+                               ig.Emit (OpCodes.Ldc_R8, (double) (val * -1));
+                       else
                                ig.Emit (OpCodes.Ldc_R8, (double) val);
                        ig.Emit (OpCodes.Box, typeof (System.Double));
                        if (no_effect)
index 0188443adefd3a42801cb953ce2800e466008f04..477560cf0d0afbfbb5bfcb8bc712022dca8ff5f8 100644 (file)
 
 using System;
 
-namespace Microsoft.JScript.Tmp {
+namespace Microsoft.JScript {
 
-       public sealed class TypeOf : UnaryOp {
+       public sealed class Typeof : UnaryOp {
 
-               public static string JScriptTypeOf (object value)
+               public static string JScriptTypeof (object value)
                {
                        throw new NotImplementedException ();
                }
index ed966efcba12c94bad4b5fd9c1598b50d6cfc34a..2c5746bbe02466deff2b08423ef95ff0505897c9 100755 (executable)
@@ -83,8 +83,20 @@ namespace Microsoft.JScript {
                internal override void Emit (EmitContext ec)
                {
                        if (operand != null)
-                               operand.Emit (ec);                      
-               }                       
+                               operand.Emit (ec);
+                       if (oper != JSToken.Minus)
+                               emit_unary_op (ec);
+               }
+
+               internal void emit_unary_op (EmitContext ec)
+               {
+                       ILGenerator ig = ec.ig;
+                       switch (oper) {
+                       case JSToken.Typeof:
+                               ig.Emit (OpCodes.Call, typeof (Typeof).GetMethod ("JScriptTypeof"));
+                               break;
+                       }
+               }
        }
 
        internal class Binary : BinaryOp, IAssignable {