GetMainScope() public method

public GetMainScope ( ) : GlobalScope
return Microsoft.JScript.GlobalScope
Esempio n. 1
0
	public override Object Eval(VsaEngine engine)
#line 97 "./Nodes/JExpr.tc"
	{
		IVariableAccess scope = (engine.ScriptObjectStackTop() as IVariableAccess);
		while(scope != null)
		{
			if(scope.HasVariable(name))
			{
				return scope.GetVariable(name);
			}
			scope = scope.GetParentScope();
		}
		return ((IVariableAccess)(engine.GetMainScope())).GetVariable(name);
	}
Esempio n. 2
0
	public override Object GetAndPrepare(VsaEngine engine, ref Object data1, ref Object data2)
#line 130 "./Nodes/JExpr.tc"
	{
		IVariableAccess scope = (engine.ScriptObjectStackTop() as IVariableAccess);
		while(scope != null)
		{
			if(scope.HasVariable(name))
			{
				data1 = scope;
				return scope.GetVariable(name);
			}
			scope = scope.GetParentScope();
		}
		scope = (IVariableAccess)(engine.GetMainScope());
		data1 = scope;
		return scope.GetVariable(name);
	}
	// Perform a constructor call on this object.
	internal override Object Construct(VsaEngine engine, Object[] args)
			{
				String parameters;
				String body;
				String defn;
				int index;
				JSParser parser;
				JFunction func;

				// Collect up the parameters and body.
				if(args.Length == 0)
				{
					parameters = String.Empty;
					body = String.Empty;
				}
				else if(args.Length == 1)
				{
					parameters = String.Empty;
					body = Convert.ToString(args[0]);
				}
				else
				{
					parameters = Convert.ToString(args[0]);
					for(index = 1; index < (args.Length - 1); ++index)
					{
						parameters =
							String.Concat(parameters, ",",
										  Convert.ToString(args[index]));
					}
					body = Convert.ToString(args[args.Length - 1]);
				}

				// Build a complete function definition and parse it.
				defn = "function (" + parameters + ") { " + body + " }";
				parser = new JSParser(new Context(defn));
				func = parser.ParseFunctionSource();

				// Build the function object and return it.
				return new FunctionObject
					(EngineInstance.GetEngineInstance(engine)
						.GetFunctionPrototype(), func,
					 engine.GetMainScope());
			}