2005-07-17 Florian Gross <flgr@ccan.de>
[mono.git] / mcs / class / Microsoft.JScript / Microsoft.JScript / FunctionObject.cs
index 2c82f54ffbf673dd48d0b9d850ff19fffd9b2355..8fdcb5c2f9342f9d1503f5b2483c4a4ffc4d8bf7 100644 (file)
@@ -37,17 +37,29 @@ namespace Microsoft.JScript {
 
        public class FunctionObject : ScriptFunction {
 
-               internal MethodAttributes attr;
                internal string name;
                internal string type_annot;
                internal Type return_type;
                internal FormalParameterList parameters;
                internal Block body;
 
+               internal FunctionObject (string name)
+               {
+                       this.name = name;
+               }
+
+               internal FunctionObject (MethodInfo info)
+               {
+                       this.method = info;
+                       this.name = info.Name;
+                       this.attr = info.Attributes;
+                       this.return_type = info.ReturnType;
+               }
+
                internal FunctionObject (string name, FormalParameterList p, string ret_type, Block body)
                {
                        //
-                       // FIXME
+                       // FIXME
                        // 1) Must collect the attributes given.
                        // 2) Check if they are semantically correct.
                        // 3) Assign those values to 'attr'.
@@ -77,20 +89,23 @@ namespace Microsoft.JScript {
                        StringBuilder sb = new StringBuilder ();
 
                        sb.Append ("function ");
-                       sb.Append (name + " ");
+                       sb.Append (name);
                        sb.Append ("(");
 
                        if (parameters != null)
                                sb.Append (this.parameters.ToString ());
                                        
                        sb.Append (")");
-                       sb.Append (" : " + return_type);
-                       sb.Append ("{");
+                       if (return_type != null && return_type != typeof (void))
+                               sb.Append (" : " + return_type);
+                       sb.Append (" {\n");
 
                        if (body != null)
                                sb.Append (body.ToString ());
+                       else
+                               sb.Append ("    [native code]");
 
-                       sb.Append ("}");
+                       sb.Append ("\n}");
 
                        return sb.ToString ();          
                }