From e106d93a808876cc7fc2566ee2d76eef0287e467 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9sar=20Natar=C3=A9n?= Date: Mon, 17 Jan 2005 22:35:31 +0000 Subject: [PATCH] 2005-01-17 Cesar Lopez Nataren * CodeGenerator.cs: Added load_engine. * expression.cs (emit_func_call), FunctionDeclaration.cs: Fix computation of VsaEngine. svn path=/trunk/mcs/; revision=39056 --- .../Microsoft.JScript/ChangeLog | 6 ++++++ .../Microsoft.JScript/CodeGenerator.cs | 17 +++++++++++++++++ .../Microsoft.JScript/expression.cs | 9 +++++---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog b/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog index 921ed768e1b..b92a89bbb56 100644 --- a/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog +++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/ChangeLog @@ -1,3 +1,9 @@ +2005-01-17 Cesar Lopez Nataren + + * CodeGenerator.cs: Added load_engine. + * expression.cs (emit_func_call), FunctionDeclaration.cs: Fix + computation of VsaEngine. + 2005-01-11 Cesar Lopez Nataren * StringConstructor.cs: implement CreateInstance. diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/CodeGenerator.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/CodeGenerator.cs index db259553542..e3ae60d76ea 100644 --- a/mcs/class/Microsoft.JScript/Microsoft.JScript/CodeGenerator.cs +++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/CodeGenerator.cs @@ -459,5 +459,22 @@ namespace Microsoft.JScript { } else return false; } + + // + // Loads a current VsaEngine + // + internal static void load_engine (AST parent, ILGenerator ig) + { + // + // If we are in a function declaration at global level, + // we must load the engine associated to the current 'JScript N' instance, + // otherwise pick up the engine at second place in method's signature. + // + if (parent == null || parent.GetType () == typeof (ScriptBlock)) { + ig.Emit (OpCodes.Ldarg_0); + ig.Emit (OpCodes.Ldfld, typeof (ScriptObject).GetField ("engine")); + } else if (parent != null && parent.GetType () == typeof (FunctionDeclaration )) + ig.Emit (OpCodes.Ldarg_1); + } } } diff --git a/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs b/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs index 3fe12731e0e..1787efa60f8 100755 --- a/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs +++ b/mcs/class/Microsoft.JScript/Microsoft.JScript/expression.cs @@ -713,14 +713,15 @@ namespace Microsoft.JScript { { ILGenerator ig = ec.ig; FieldInfo engine = typeof (ScriptObject).GetField ("engine"); - ig.Emit (OpCodes.Ldarg_0); - ig.Emit (OpCodes.Ldfld, engine); + + CodeGenerator.load_engine (parent, ig); + ig.Emit (OpCodes.Call, typeof (VsaEngine).GetMethod ("ScriptObjectStackTop")); Type iact_obj = typeof (IActivationObject); ig.Emit (OpCodes.Castclass, iact_obj); ig.Emit (OpCodes.Callvirt, iact_obj.GetMethod ("GetDefaultThisObject")); - ig.Emit (OpCodes.Ldarg_0); - ig.Emit (OpCodes.Ldfld, engine); + + CodeGenerator.load_engine (parent, ig); args.Emit (ec); -- 2.25.1