Author: cesar
Date: 2005-07-05 17:35:16 -0400 (Tue, 05 Jul 2005)
New Revision: 46974
Modified:
trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog
trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionExpression.cs
trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/Parser.cs
trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs
Log:
2005-07-05 Cesar Lopez Nataren <[EMAIL PROTECTED]>
Fixes bug #75442
* FunctionExpression.cs (Emit): use InFunction instead of testing by
hand.
* Parser.cs (MemberExpr): pass parent as the parameter not pn.
* expression.cs (get_global_scope_or_this): use
CodeGenerator.load_engine for loading the engine, and invoke
GetGlobalScope when the member_exp is a function expression.
Modified: trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog
===================================================================
--- trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog
2005-07-05 21:03:27 UTC (rev 46973)
+++ trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog
2005-07-05 21:35:16 UTC (rev 46974)
@@ -1,5 +1,15 @@
+2005-07-05 Cesar Lopez Nataren <[EMAIL PROTECTED]>
+
+ Fixes bug #75442
+ * FunctionExpression.cs (Emit): use InFunction instead of testing by
hand.
+ * Parser.cs (MemberExpr): pass parent as the parameter not pn.
+ * expression.cs (get_global_scope_or_this): use
+ CodeGenerator.load_engine for loading the engine, and invoke
+ GetGlobalScope when the member_exp is a function expression.
+
2005-07-04 Cesar Lopez Nataren <[EMAIL PROTECTED]>
+ Fixes bug #75440
* expression.cs (emit_late_get_or_set, emit_late_call): Take care the
case where
the left hand side of a late bound expression is a literal.
* SemanticAnalizer.cs: Added IsLiteral method.
Modified:
trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionExpression.cs
===================================================================
--- trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionExpression.cs
2005-07-05 21:03:27 UTC (rev 46973)
+++ trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/FunctionExpression.cs
2005-07-05 21:35:16 UTC (rev 46974)
@@ -116,18 +116,15 @@
set_custom_attr (method_builder);
EmitContext new_ec = new EmitContext (ec.type_builder,
ec.mod_builder,
method_builder.GetILGenerator ());
-
- if (parent == null || parent.GetType () == typeof
(ScriptBlock)) {
+ if (InFunction) {
+ local_script_func = ig.DeclareLocal (typeof
(ScriptFunction));
+ local_func = ig.DeclareLocal (typeof
(FunctionObject));
+ } else {
if (name != String.Empty) {
field = type.DefineField (name, typeof
(object), FieldAttributes.Public | FieldAttributes.Static);
local_func = ig.DeclareLocal (typeof
(FunctionObject));
} else
local_func = ig.DeclareLocal (typeof
(FunctionObject));
- } else if (parent != null &&
- (parent.GetType () == typeof
(FunctionDeclaration)
- || parent.GetType () == typeof
(FunctionExpression))) {
- local_script_func = ig.DeclareLocal (typeof
(ScriptFunction));
- local_func = ig.DeclareLocal (typeof
(FunctionObject));
}
build_closure (ec, full_name);
func_obj.body.Emit (new_ec);
Modified: trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/Parser.cs
===================================================================
--- trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/Parser.cs
2005-07-05 21:03:27 UTC (rev 46973)
+++ trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/Parser.cs
2005-07-05 21:35:16 UTC (rev 46974)
@@ -997,7 +997,7 @@
pn = PrimaryExpr (parent);
} else
pn = PrimaryExpr (parent);
- return MemberExprTail (pn, allow_call_syntax, pn);
+ return MemberExprTail (parent, allow_call_syntax, pn);
}
AST MemberExprTail (AST parent, bool allow_call_syntax, AST pn)
Modified: trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs
===================================================================
--- trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs
2005-07-05 21:03:27 UTC (rev 46973)
+++ trunk/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs
2005-07-05 21:35:16 UTC (rev 46974)
@@ -771,22 +771,20 @@
internal void get_global_scope_or_this (ILGenerator ig)
{
- if (InFunction)
- ig.Emit (OpCodes.Ldarg_1);
- else {
- ig.Emit (OpCodes.Ldarg_0);
- ig.Emit (OpCodes.Ldfld, typeof
(ScriptObject).GetField ("engine"));
- }
-
+ CodeGenerator.load_engine (InFunction, ig);
ig.Emit (OpCodes.Call, typeof
(Microsoft.JScript.Vsa.VsaEngine).GetMethod ("ScriptObjectStackTop"));
Type iact_obj = typeof (IActivationObject);
ig.Emit (OpCodes.Castclass, iact_obj);
//
- //FIXME: when is each of them (GetGlobalScope |
GetDefaultThisObject?
+ //FIXME: Find out the exact discrimination for:
GetGlobalScope and GetDefaultThisObject
+ // For example, in program: print (function () { return
1; } ());
+ // we invoke GetGlobalScope, in other cases
GetDefaultThisObject
//
- // ig.Emit (OpCodes.Callvirt, iact_obj.GetMethod
("GetGlobalScope"));
- ig.Emit (OpCodes.Callvirt, iact_obj.GetMethod
("GetDefaultThisObject"));
+ if (member_exp is FunctionExpression)
+ ig.Emit (OpCodes.Callvirt, iact_obj.GetMethod
("GetGlobalScope"));
+ else
+ ig.Emit (OpCodes.Callvirt, iact_obj.GetMethod
("GetDefaultThisObject"));
}
void init_late_binding (EmitContext ec, LocalBuilder local)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches