[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/JScript/Execute ActivationObject.cs,
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/JScript/Execute ActivationObject.cs,1.2,1.3 Convert.cs,1.1,1.2 DBNull.cs,1.1,1.2 IVariableAccess.cs,1.1,1.2 ScriptFunction.cs,1.2,1.3 Support.cs,1.3,1.4 WithScope.cs,1.1,1.2 |
Date: |
Fri, 17 Jan 2003 01:34:50 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute
In directory subversions:/tmp/cvs-serv29381/JScript/Execute
Modified Files:
ActivationObject.cs Convert.cs DBNull.cs IVariableAccess.cs
ScriptFunction.cs Support.cs WithScope.cs
Log Message:
Implement evaluation logic for JScript expressions.
Index: ActivationObject.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute/ActivationObject.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** ActivationObject.cs 14 Jan 2003 10:35:49 -0000 1.2
--- ActivationObject.cs 17 Jan 2003 06:34:46 -0000 1.3
***************
*** 119,122 ****
--- 119,126 ----
storage.Put(name, value);
}
+ IVariableAccess IVariableAccess.GetParentScope()
+ {
+ return (parent as IVariableAccess);
+ }
}; // class ActivationObject
Index: Convert.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute/Convert.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Convert.cs 13 Jan 2003 10:53:19 -0000 1.1
--- Convert.cs 17 Jan 2003 06:34:46 -0000 1.2
***************
*** 624,627 ****
--- 624,711 ----
}
+ // Convert an object into a primitive value.
+ public static Object ToPrimitive(Object value, DefaultValueHint hint)
+ {
+ if(value is ScriptObject)
+ {
+ // Let the object handle conversion for
JScript objects.
+ return
((ScriptObject)value).DefaultValue(hint);
+ }
+ else
+ {
+ // Handle non-JScript objects.
+ switch(hint)
+ {
+ case DefaultValueHint.None:
+ {
+
switch(Support.TypeCodeForObject(value))
+ {
+ case
TypeCode.SByte:
+ case
TypeCode.Byte:
+ case
TypeCode.Int16:
+ case
TypeCode.UInt16:
+ case
TypeCode.Int32:
+ case
TypeCode.UInt32:
+ case
TypeCode.Int64:
+ case
TypeCode.UInt64:
+ case
TypeCode.Single:
+ case
TypeCode.Double:
+ case
TypeCode.Decimal:
+ {
+ value =
ToNumber(value);
+ }
+ break;
+
+ default:
+ {
+ value =
ToString(value);
+ }
+ break;
+ }
+ }
+ break;
+
+ case DefaultValueHint.Number:
+ {
+ value = ToNumber(value);
+ }
+ break;
+
+ case DefaultValueHint.String:
+ case
DefaultValueHint.LocaleString:
+ {
+ value = ToString(value);
+ }
+ break;
+ }
+ return value;
+ }
+ }
+
+ // Normalize a value down to primitive, but don't apply hard
conversions.
+ internal static Object NormalizePrimitive(Object value)
+ {
+ switch(Support.TypeCodeForObject(value))
+ {
+ case TypeCode.Char:
+ return Convert.ToString(value);
+
+ case TypeCode.SByte:
+ case TypeCode.Byte:
+ case TypeCode.Int16:
+ case TypeCode.UInt16:
+ case TypeCode.Int32:
+ case TypeCode.UInt32:
+ case TypeCode.Int64:
+ case TypeCode.UInt64:
+ case TypeCode.Single:
+ case TypeCode.Double:
+ return Convert.ToNumber(value);
+
+ default: break;
+ }
+ return value;
+ }
+
}; // class Convert
Index: DBNull.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute/DBNull.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** DBNull.cs 13 Jan 2003 10:53:19 -0000 1.1
--- DBNull.cs 17 Jan 2003 06:34:46 -0000 1.2
***************
*** 42,45 ****
--- 42,51 ----
public override String ToString() { return String.Empty; }
+ // Determine if a value is DBNull.
+ internal static bool IsDBNull(Object value)
+ {
+ return (value == Value);
+ }
+
}; // class DBNull
Index: IVariableAccess.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute/IVariableAccess.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** IVariableAccess.cs 13 Jan 2003 10:53:19 -0000 1.1
--- IVariableAccess.cs 17 Jan 2003 06:34:46 -0000 1.2
***************
*** 36,39 ****
--- 36,42 ----
void SetVariable(String name, Object value);
+ // Get the parent variable scope.
+ IVariableAccess GetParentScope();
+
}; // interface IVariableAccess
Index: ScriptFunction.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute/ScriptFunction.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** ScriptFunction.cs 14 Jan 2003 10:35:50 -0000 1.2
--- ScriptFunction.cs 17 Jan 2003 06:34:46 -0000 1.3
***************
*** 162,165 ****
--- 162,172 ----
}
+ // Determine if an object is an instance of this class.
+ internal virtual bool HasInstance(Object obj)
+ {
+ // TODO
+ return false;
+ }
+
// Get the internal "[[Class]]" property for this object.
internal override String Class
Index: Support.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute/Support.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Support.cs 14 Jan 2003 12:37:36 -0000 1.3
--- Support.cs 17 Jan 2003 06:34:46 -0000 1.4
***************
*** 282,285 ****
--- 282,339 ----
}
+ // Get the length of an expression list.
+ public static int ExprListLength(JExprList list)
+ {
+ JExprListElem elem = list.first;
+ int len = 0;
+ while(elem != null)
+ {
+ ++len;
+ elem = elem.next;
+ }
+ return len;
+ }
+
+ // Evaluate an argument list.
+ private static int EvalArgs(Object[] args, int posn, JNode node,
+ VsaEngine
engine)
+ {
+ if(node == null)
+ {
+ return posn;
+ }
+ else if(!(node is JArgList))
+ {
+ args[posn] = node.Eval(engine);
+ return posn + 1;
+ }
+ else
+ {
+ posn = EvalArgs(args, posn,
((JArgList)node).expr1, engine);
+ args[posn] =
(((JArgList)node).expr2).Eval(engine);
+ return posn + 1;
+ }
+ }
+ public static Object[] EvalArgList(JNode node, VsaEngine engine)
+ {
+ int len;
+ if(node == null)
+ {
+ len = 0;
+ }
+ else
+ {
+ len = 1;
+ while(node is JArgList)
+ {
+ ++len;
+ node = ((JArgList)node).expr1;
+ }
+ }
+ Object[] args = new Object [len];
+ EvalArgs(args, 0, node, engine);
+ return args;
+ }
+
// Evaluate and print an expression tree.
public static void Print(VsaEngine engine, JNode expr)
Index: WithScope.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Execute/WithScope.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** WithScope.cs 13 Jan 2003 10:53:19 -0000 1.1
--- WithScope.cs 17 Jan 2003 06:34:46 -0000 1.2
***************
*** 25,29 ****
using System.Reflection;
! internal sealed class WithScope : ScriptObject, IActivationObject
{
// Internal state.
--- 25,30 ----
using System.Reflection;
! internal sealed class WithScope : ScriptObject, IActivationObject,
!
IVariableAccess
{
// Internal state.
***************
*** 74,77 ****
--- 75,104 ----
// TODO
return null;
+ }
+
+ // Implement the internal "IVariableAccess" interface.
+ bool IVariableAccess.HasVariable(String name)
+ {
+ return
((ScriptObject)withObject).HasProperty(name);
+ }
+ Object IVariableAccess.GetVariable(String name)
+ {
+ if(((ScriptObject)withObject).HasProperty(name))
+ {
+ return
((ScriptObject)withObject).Get(name);
+ }
+ else
+ {
+ ((ScriptObject)withObject).Put(name,
null);
+ return null;
+ }
+ }
+ void IVariableAccess.SetVariable(String name, Object value)
+ {
+ ((ScriptObject)withObject).Put(name, value);
+ }
+ IVariableAccess IVariableAccess.GetParentScope()
+ {
+ return (parent as IVariableAccess);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/JScript/Execute ActivationObject.cs,1.2,1.3 Convert.cs,1.1,1.2 DBNull.cs,1.1,1.2 IVariableAccess.cs,1.1,1.2 ScriptFunction.cs,1.2,1.3 Support.cs,1.3,1.4 WithScope.cs,1.1,1.2,
Rhys Weatherley <address@hidden> <=