[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/JScript/Builtins ArrayConstructor.cs
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/JScript/Builtins ArrayConstructor.cs,1.1,1.2 BuiltinFunction.cs,1.1,1.2 FunctionConstructor.cs,1.2,1.3 FunctionObject.cs,1.3,1.4 FunctionPrototype.cs,1.3,1.4 ObjectConstructor.cs,1.2,1.3 |
Date: |
Thu, 06 Mar 2003 20:08:40 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetlib/JScript/Builtins
In directory subversions:/tmp/cvs-serv26973/JScript/Builtins
Modified Files:
ArrayConstructor.cs BuiltinFunction.cs FunctionConstructor.cs
FunctionObject.cs FunctionPrototype.cs ObjectConstructor.cs
Log Message:
Implement builtin function invocation support; make Call/Construct re-entrant.
Index: ArrayConstructor.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Builtins/ArrayConstructor.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ArrayConstructor.cs 13 Jan 2003 10:53:19 -0000 1.1
--- ArrayConstructor.cs 7 Mar 2003 01:08:35 -0000 1.2
***************
*** 64,68 ****
// Perform a call on this object.
! internal override Object Call(Object thisob, Object[] args)
{
return Invoke(args);
--- 64,69 ----
// Perform a call on this object.
! internal override Object Call
! (VsaEngine engine, Object thisob, Object[] args)
{
return Invoke(args);
***************
*** 70,74 ****
// Perform a constructor call on this object.
! internal override Object CallConstructor(Object[] args)
{
return CreateInstance(args);
--- 71,75 ----
// Perform a constructor call on this object.
! internal override Object Construct(VsaEngine engine, Object[] args)
{
return CreateInstance(args);
Index: BuiltinFunction.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Builtins/BuiltinFunction.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** BuiltinFunction.cs 13 Jan 2003 10:53:19 -0000 1.1
--- BuiltinFunction.cs 7 Mar 2003 01:08:35 -0000 1.2
***************
*** 25,28 ****
--- 25,29 ----
using System.Reflection;
using System.Globalization;
+ using Microsoft.JScript.Vsa;
internal sealed class BuiltinFunction : ScriptFunction
***************
*** 67,71 ****
// Perform a call on this object.
! internal override Object Call(Object thisob, Object[] args)
{
// Invoke the builtin method using reflection.
--- 68,73 ----
// Perform a call on this object.
! internal override Object Call
! (VsaEngine engine, Object thisob,
Object[] args)
{
// Invoke the builtin method using reflection.
Index: FunctionConstructor.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Builtins/FunctionConstructor.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** FunctionConstructor.cs 14 Jan 2003 10:35:49 -0000 1.2
--- FunctionConstructor.cs 7 Mar 2003 01:08:35 -0000 1.3
***************
*** 53,58 ****
public new ScriptFunction CreateInstance(params Object[] args)
{
! // TODO
! return null;
}
--- 53,57 ----
public new ScriptFunction CreateInstance(params Object[] args)
{
! return (ScriptFunction)Construct(engine, args);
}
***************
*** 61,77 ****
public ScriptFunction Invoke(params Object[] args)
{
! return CreateInstance(args);
}
// Perform a call on this object.
! internal override Object Call(Object thisob, Object[] args)
{
! return CreateInstance(args);
}
// Perform a constructor call on this object.
! internal override Object CallConstructor(Object[] args)
{
! return CreateInstance(args);
}
--- 60,116 ----
public ScriptFunction Invoke(params Object[] args)
{
! return (ScriptFunction)Construct(engine, args);
}
// Perform a call on this object.
! internal override Object Call
! (VsaEngine engine, Object thisob, Object[] args)
{
! return Construct(engine, args);
}
// Perform a constructor call on this object.
! internal override Object Construct(VsaEngine engine, Object[] args)
{
! String parameters;
! String body;
! String defn;
! int index;
! JSParser parser;
! JFunction func;
!
! // Collect up the parameters and body.
! if(args.Length == 0)
! {
! parameters = String.Empty;
! body = String.Empty;
! }
! else if(args.Length == 1)
! {
! parameters = String.Empty;
! body = Convert.ToString(args[0]);
! }
! else
! {
! parameters = Convert.ToString(args[0]);
! for(index = 1; index < (args.Length -
1); ++index)
! {
! parameters =
!
String.Concat(parameters, ",",
!
Convert.ToString(args[index]));
! }
! body =
Convert.ToString(args[args.Length - 1]);
! }
!
! // Build a complete function definition and
parse it.
! defn = "function (" + parameters + ") { " +
body + " }";
! parser = new JSParser(new Context(defn));
! func = parser.ParseFunctionSource();
!
! // Build the function object and return it.
! return new FunctionObject
!
(EngineInstance.GetEngineInstance(engine)
! .GetFunctionPrototype(), func,
! engine.GetMainScope());
}
Index: FunctionObject.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Builtins/FunctionObject.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** FunctionObject.cs 6 Mar 2003 04:47:17 -0000 1.3
--- FunctionObject.cs 7 Mar 2003 01:08:35 -0000 1.4
***************
*** 49,53 ****
// Perform a call on this object.
! internal override Object Call(Object thisob, Object[] args)
{
// Create a new scope object and initialize the
parameters.
--- 49,54 ----
// Perform a call on this object.
! internal override Object Call
! (VsaEngine engine, Object thisob, Object[] args)
{
// Create a new scope object and initialize the
parameters.
Index: FunctionPrototype.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Builtins/FunctionPrototype.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** FunctionPrototype.cs 26 Feb 2003 02:13:55 -0000 1.3
--- FunctionPrototype.cs 7 Mar 2003 01:08:35 -0000 1.4
***************
*** 91,97 ****
// Perform a call on this object.
! internal override Object Call(Object thisob, Object[] args)
{
! // TODO
return null;
}
--- 91,98 ----
// Perform a call on this object.
! internal override Object Call
! (VsaEngine engine, Object thisob, Object[] args)
{
! // Not used on function prototypes.
return null;
}
Index: ObjectConstructor.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/JScript/Builtins/ObjectConstructor.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** ObjectConstructor.cs 14 Jan 2003 10:35:49 -0000 1.2
--- ObjectConstructor.cs 7 Mar 2003 01:08:35 -0000 1.3
***************
*** 51,77 ****
// Construct a new "Object" instance.
public JSObject ConstructObject()
{
! ScriptObject prototype =
! EngineInstance.GetEngineInstance(engine)
! .GetObjectPrototype();
! return new JSObject(prototype);
}
[JSFunction(JSFunctionAttributeEnum.HasVarArgs)]
public new Object CreateInstance(params Object[] args)
{
! if(args.Length == 0)
! {
! return ConstructObject();
! }
! else if(args[0] == null || args[0] ==
DBNull.Value)
! {
! return ConstructObject();
! }
! else
! {
! // TODO
! return args[0];
! }
}
--- 51,68 ----
// Construct a new "Object" instance.
+ private static JSObject ConstructNewObject(VsaEngine engine)
+ {
+ return new JSObject
+
(EngineInstance.GetEngineInstance(engine)
+ .GetObjectPrototype());
+ }
public JSObject ConstructObject()
{
! return ConstructNewObject(engine);
}
[JSFunction(JSFunctionAttributeEnum.HasVarArgs)]
public new Object CreateInstance(params Object[] args)
{
! return Construct(engine, args);
}
***************
*** 80,108 ****
public Object Invoke(params Object[] args)
{
! return Call(null, args);
}
// Perform a call on this object.
! internal override Object Call(Object thisob, Object[] args)
{
if(args.Length == 0)
{
! return ConstructObject();
}
else if(args[0] == null || args[0] ==
DBNull.Value)
{
! return CreateInstance(args);
}
else
{
! // TODO
! return this;
}
}
// Perform a constructor call on this object.
! internal override Object CallConstructor(Object[] args)
{
! return CreateInstance(args);
}
--- 71,110 ----
public Object Invoke(params Object[] args)
{
! return Call(engine, null, args);
}
// Perform a call on this object.
! internal override Object Call
! (VsaEngine engine, Object thisob, Object[] args)
{
if(args.Length == 0)
{
! return ConstructNewObject(engine);
}
else if(args[0] == null || args[0] ==
DBNull.Value)
{
! return ConstructNewObject(engine);
}
else
{
! return Convert.ToObject(args[0],
engine);
}
}
// Perform a constructor call on this object.
! internal override Object Construct(VsaEngine engine, Object[] args)
{
! if(args.Length == 0)
! {
! return ConstructNewObject(engine);
! }
! else if(args[0] == null || args[0] ==
DBNull.Value)
! {
! return ConstructNewObject(engine);
! }
! else
! {
! return Convert.ToObject(args[0],
engine);
! }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/JScript/Builtins ArrayConstructor.cs,1.1,1.2 BuiltinFunction.cs,1.1,1.2 FunctionConstructor.cs,1.2,1.3 FunctionObject.cs,1.3,1.4 FunctionPrototype.cs,1.3,1.4 ObjectConstructor.cs,1.2,1.3,
Rhys Weatherley <address@hidden> <=