* jscript-lexer-parser.g: Build ast for FunctionExpression.
* JSObject.cs: we don't throw NotImplementedException anymore,
this let us use FunctionExpression to build the ast.
* FunctionExpression.cs: Added a FunctionObject as field, a
default constructor.
* FunctionObject.cs: Added default constructor.
svn path=/trunk/mcs/; revision=18229
2003-09-20 <cesar@ciencias.unam.mx>
+ * jscript-lexer-parser.g: Build ast for FunctionExpression.
+
+ * JSObject.cs: we don't throw NotImplementedException anymore,
+ this let us use FunctionExpression to build the ast.
+
+ * FunctionExpression.cs: Added a FunctionObject as field, a
+ default constructor.
+
+ * FunctionObject.cs: Added default constructor.
+
* driver.cs: Deleted the Jsc class. We are not generating code
now. I'm moving to provide something like mcs's EmitContext
instead of the CodeGenerator class having the Reflection.Emit
public class FunctionExpression : AST {
+ internal FunctionObject Function;
+
+ internal FunctionExpression ()
+ {
+ Function = new FunctionObject ();
+ }
+
public static FunctionObject JScriptFunctionExpression (RuntimeTypeHandle handle, string name,
string methodName, string [] formalParams,
JSLocalField [] fields)
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
-namespace Microsoft.JScript.Tmp
-{
- using System;
+using System;
+
+namespace Microsoft.JScript.Tmp {
+
+ public class FunctionObject : ScriptFunction {
- public class FunctionObject : ScriptFunction
- {
internal string Name;
internal string ReturnType;
internal FormalParameterList Params;
internal Block Body;
+ internal FunctionObject ()
+ {
+ Params = new FormalParameterList ();
+ Body = new Block ();
+ }
+
public override string ToString ()
{
throw new NotImplementedException ();
public class JSObject : ScriptObject, IEnumerable, IExpando
{
public JSObject ()
- {
- throw new NotImplementedException ();
- }
+ {}
public FieldInfo AddField (string name)
{
throw new NotImplementedException ();
}
}
-}
\ No newline at end of file
+}
}\r
}\r
\r
- public void function_expression() //throws RecognitionException, TokenStreamException\r
+ public FunctionExpression function_expression() //throws RecognitionException, TokenStreamException\r
{\r
+ FunctionExpression fe;\r
\r
+ Token id = null;\r
+ fe = new FunctionExpression ();\r
\r
try { // for error handling\r
match(LITERAL_function);\r
{\r
case IDENTIFIER:\r
{\r
+ id = LT(1);\r
match(IDENTIFIER);\r
+ if (0==inputState.guessing)\r
+ {\r
+ fe.Function.Name = id.getText ();\r
+ }\r
break;\r
}\r
case LPAREN:\r
{\r
case IDENTIFIER:\r
{\r
- formal_parameter_list(null);\r
+ formal_parameter_list(fe.Function.Params);\r
break;\r
}\r
case RPAREN:\r
}\r
match(RPAREN);\r
match(LBRACE);\r
- function_body(null);\r
+ function_body(fe.Function.Body);\r
match(RBRACE);\r
}\r
catch (RecognitionException ex)\r
throw;\r
}\r
}\r
+ return fe;\r
}\r
\r
public void argument_list() //throws RecognitionException, TokenStreamException\r
expression: assignment_expression (COMMA expression | ) ;
-function_expression
+function_expression returns [FunctionExpression fe]
+{ fe = new FunctionExpression (); }
:
- "function" (IDENTIFIER | ) LPAREN (formal_parameter_list [null] | ) RPAREN LBRACE function_body [null] RBRACE
+ "function"
+ (id:IDENTIFIER { fe.Function.Name = id.getText (); } | )
+ LPAREN (formal_parameter_list [fe.Function.Params] | ) RPAREN
+ LBRACE function_body [fe.Function.Body] RBRACE
;