[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/JScript/Jsc ForIn.cs,1.1,1.2 Numeric
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/JScript/Jsc ForIn.cs,1.1,1.2 NumericBinary.cs,1.1,1.2 NumericUnary.cs,1.1,1.2 |
Date: |
Tue, 21 Jan 2003 17:11:51 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/JScript/Jsc
In directory subversions:/tmp/cvs-serv20060/JScript/Jsc
Modified Files:
ForIn.cs NumericBinary.cs NumericUnary.cs
Log Message:
Implement function calls; "for-in" statements; variable declarations;
property enums.
Index: ForIn.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Jsc/ForIn.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ForIn.cs 13 Jan 2003 10:53:19 -0000 1.1
--- ForIn.cs 21 Jan 2003 22:11:49 -0000 1.2
***************
*** 35,41 ****
public static IEnumerator JScriptGetEnumerator(Object coll)
{
! // TODO
! return null;
}
}; // class ForIn
--- 35,105 ----
public static IEnumerator JScriptGetEnumerator(Object coll)
{
! if(coll is IEnumerator)
! {
! return (IEnumerator)coll;
! }
! else if(coll is ScriptObject)
! {
! return
((ScriptObject)coll).GetPropertyEnumerator();
! }
! else if(coll is Array)
! {
! Array array = (Array)coll;
! return new
ArrayIndexEnumerator(array.GetLowerBound(0),
!
array.GetUpperBound(0));
! }
! else if(coll is IEnumerable)
! {
! IEnumerator e =
((IEnumerable)coll).GetEnumerator();
! if(e == null)
! {
! return new NullEnumerator();
! }
! else
! {
! return e;
! }
! }
! else
! {
! throw new
JScriptException(JSError.NotCollection);
! }
}
+
+ // Enumerator class for indexes in an array range.
+ private sealed class ArrayIndexEnumerator : IEnumerator
+ {
+ // Internal state.
+ private int lower;
+ private int upper;
+ private int current;
+
+ // Constructor.
+ public ArrayIndexEnumerator(int lower, int upper)
+ {
+ this.lower = lower;
+ this.upper = upper;
+ this.current = lower - 1;
+ }
+
+ // Implement the IEnumerator interface.
+ public bool MoveNext()
+ {
+ ++current;
+ return (current <= upper);
+ }
+ public void Reset()
+ {
+ current = lower - 1;
+ }
+ public Object Current
+ {
+ get
+ {
+ return current;
+ }
+ }
+
+ }; // class ArrayIndexEnumerator
}; // class ForIn
Index: NumericBinary.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Jsc/NumericBinary.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** NumericBinary.cs 13 Jan 2003 10:53:20 -0000 1.1
--- NumericBinary.cs 21 Jan 2003 22:11:49 -0000 1.2
***************
*** 38,43 ****
public Object EvaluateNumericBinary(Object v1, Object v2)
{
! // TODO
! return null;
}
--- 38,42 ----
public Object EvaluateNumericBinary(Object v1, Object v2)
{
! return DoOp(v1, v2, operatorTok);
}
***************
*** 45,50 ****
public static Object DoOp(Object v1, Object v2, JSToken operatorTok)
{
! // TODO
! return null;
}
--- 44,76 ----
public static Object DoOp(Object v1, Object v2, JSToken operatorTok)
{
! double n1 = Convert.ToNumber(v1);
! double n2 = Convert.ToNumber(v2);
! switch(operatorTok)
! {
! case JSToken.Minus:
! {
! return (n1 - n2);
! }
! // Not reached.
!
! case JSToken.Multiply:
! {
! return (n1 * n2);
! }
! // Not reached.
!
! case JSToken.Divide:
! {
! return (n1 / n2);
! }
! // Not reached.
!
! case JSToken.Modulo:
! {
! return (n1 % n2);
! }
! // Not reached.
! }
! throw new
JScriptException(JSError.InternalError);
}
Index: NumericUnary.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Jsc/NumericUnary.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** NumericUnary.cs 13 Jan 2003 10:53:20 -0000 1.1
--- NumericUnary.cs 21 Jan 2003 22:11:49 -0000 1.2
***************
*** 38,43 ****
public Object EvaluateUnary(Object v)
{
! // TODO
! return null;
}
--- 38,68 ----
public Object EvaluateUnary(Object v)
{
! switch(operatorTok)
! {
! case JSToken.BitwiseNot:
! {
! return ~(Convert.ToInt32(v));
! }
! // Not reached.
!
! case JSToken.LogicalNot:
! {
! return !(Convert.ToBoolean(v));
! }
! // Not reached.
!
! case JSToken.Minus:
! {
! return -(Convert.ToNumber(v));
! }
! // Not reached.
!
! case JSToken.Plus:
! {
! return Convert.ToNumber(v);
! }
! // Not reached.
! }
! throw new
JScriptException(JSError.InternalError);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/JScript/Jsc ForIn.cs,1.1,1.2 NumericBinary.cs,1.1,1.2 NumericUnary.cs,1.1,1.2,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/JScript/Builtins ArrayObject.cs,1.1,1.2 FunctionObject.cs,1.1,1.2
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/JScript/Execute FunctionScope.cs,NONE,1.1 NullEnumerator.cs,NONE,1.1 ActivationObject.cs,1.3,1.4 BlockScope.cs,1.1,1.2 Convert.cs,1.2,1.3 IVariableAccess.cs,1.2,1.3 JSObject.cs,1.2,1.3 PropertyAttributes.cs,1.1,1.2 ScriptObject.cs,1.2,1.3 WithScope.cs,1.2,1.3
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/JScript/Builtins ArrayObject.cs,1.1,1.2 FunctionObject.cs,1.1,1.2
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/JScript/Execute FunctionScope.cs,NONE,1.1 NullEnumerator.cs,NONE,1.1 ActivationObject.cs,1.3,1.4 BlockScope.cs,1.1,1.2 Convert.cs,1.2,1.3 IVariableAccess.cs,1.2,1.3 JSObject.cs,1.2,1.3 PropertyAttributes.cs,1.1,1.2 ScriptObject.cs,1.2,1.3 WithScope.cs,1.2,1.3
- Index(es):