5 // Cesar Octavio Lopez Nataren
7 // (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
12 using System.Reflection;
13 using System.Collections;
15 namespace Microsoft.JScript {
17 public class FunctionObject : ScriptFunction {
19 internal MethodAttributes attr;
21 internal string type_annot;
22 internal Type return_type;
23 internal FormalParameterList parameters;
27 internal FunctionObject (AST parent, string name,
28 FormalParameterList p,
29 string ret_type, Block body)
33 // 1) Must collect the attributes given.
34 // 2) Check if they are semantically correct.
35 // 3) Assign those values to 'attr'.
37 this.attr = MethodAttributes.Public | MethodAttributes.Static;
43 this.type_annot = ret_type;
45 // FIXME: Must check that return_type it's a valid type,
46 // and assign that to 'return_type' field.
48 this.return_type = typeof (void);
53 internal FunctionObject ()
55 this.parameters = new FormalParameterList ();
56 this.body = new Block (parent);
59 public override string ToString ()
61 StringBuilder sb = new StringBuilder ();
63 sb.Append ("function ");
64 sb.Append (name + " ");
67 if (parameters != null)
68 sb.Append (this.parameters.ToString ());
71 sb.Append (" : " + return_type);
75 sb.Append (body.ToString ());
79 return sb.ToString ();
82 internal Type [] params_types ()
84 if (parameters == null)
86 new Type [] {typeof (Object), typeof (Microsoft.JScript.Vsa.VsaEngine)};
89 ArrayList p = parameters.ids;
93 Type [] types = new Type [size];
95 types [0] = typeof (Object);
96 types [1] = typeof (Microsoft.JScript.Vsa.VsaEngine);
98 for (i = 2; i < size; i++)
99 types [i] = ((FormalParam) p [i - 2]).type;