* jscript-lexer-parser.g: Keep track of parent for numeric_literal.
* VariableDeclaration.cs: now I handle initialization (ex. var x =
2; or function f () { var x = 4; }) at global scope or at
function's body.
* Literal.cs: Added parent param to NumericLiteral constructor.
* FunctionDeclaration.cs: Added Ret opcode for all function declaration bodies.
svn path=/trunk/mcs/; revision=21306
+2003-12-18 Cesar Lopez Nataren <cesar@ciencias.unam.mx>
+
+ * jscript-lexer-parser.g: Keep track of parent for numeric_literal.
+
+ * VariableDeclaration.cs: now I handle initialization (ex. var x =
+ 2; or function f () { var x = 4; }) at global scope or at
+ function's body.
+
+ * Literal.cs: Added parent param to NumericLiteral constructor.
+
+ * FunctionDeclaration.cs: Added Ret opcode for all function declaration bodies.
+
2003-12-17 Cesar Lopez Nataren <cesar@ciencias.unam.mx>
* CodeGenerator.cs: Added IL emittion for ldnull on default ending code for 'Global Code'.
Function.return_type,
Function.params_types ());
- ec.ig = method.GetILGenerator ();
-
+ ec.ig = method.GetILGenerator ();
Function.body.Emit (ec);
+ ec.ig.Emit (OpCodes.Ret);
}
internal override bool Resolve (IdentificationTable context)
double val;
- internal NumericLiteral (double val)
+ internal NumericLiteral (AST parent, double val)
{
+ this.parent = parent;
this.val = val;
}
field = type.DefineField (id, Type,
FieldAttributes.Public |
FieldAttributes.Static);
- } else
- ec.ig.DeclareLocal (Type);
+ if (val != null) {
+ val.Emit (ec);
+ ec.gc_ig.Emit (OpCodes.Stsfld, field);
+ }
+ } else {
+ ILGenerator ig = ec.ig;
+ LocalBuilder lb = ig.DeclareLocal (Type);
+
+ if (val != null) {
+ val.Emit (ec);
+ ig.Emit (OpCodes.Stloc, lb);
+ }
+ }
}
internal override bool Resolve (IdentificationTable context)
StringLiteral str = new StringLiteral (s.getText ());
l = str;
}
- | l = numeric_literal
+ | l = numeric_literal [parent]
;
property_name_and_value_list
;
property_name
- : (IDENTIFIER | STRING_LITERAL | numeric_literal)
+ : (IDENTIFIER | STRING_LITERAL | numeric_literal [null])
;
array_literal
: OPEN_BRACKET (primary_expr [null] (COMMA primary_expr [null])* | ) CLOSE_BRACKET
;
-numeric_literal returns [NumericLiteral num_lit]
+numeric_literal [AST parent] returns [NumericLiteral num_lit]
{
num_lit = null;
}
- : d:DECIMAL_LITERAL { num_lit = new NumericLiteral (Convert.ToSingle (d.getText ())); }
+ : d:DECIMAL_LITERAL { num_lit = new NumericLiteral (parent, Convert.ToSingle (d.getText ())); }
| HEX_INTEGER_LITERAL
;