ParseFunctionExpression() private method

private ParseFunctionExpression ( ) : AST
return AST
 internal ScriptFunction Construct(object[] args, VsaEngine engine)
 {
     ScriptFunction function;
     StringBuilder builder = new StringBuilder("function anonymous(");
     int index = 0;
     int num2 = args.Length - 2;
     while (index < num2)
     {
         builder.Append(Microsoft.JScript.Convert.ToString(args[index]));
         builder.Append(", ");
         index++;
     }
     if (args.Length > 1)
     {
         builder.Append(Microsoft.JScript.Convert.ToString(args[args.Length - 2]));
     }
     builder.Append(") {\n");
     if (args.Length > 0)
     {
         builder.Append(Microsoft.JScript.Convert.ToString(args[args.Length - 1]));
     }
     builder.Append("\n}");
     Context context = new Context(new DocumentContext("anonymous", engine), builder.ToString());
     JSParser parser = new JSParser(context);
     engine.PushScriptObject(((IActivationObject) engine.ScriptObjectStackTop()).GetGlobalScope());
     try
     {
         function = (ScriptFunction) parser.ParseFunctionExpression().PartiallyEvaluate().Evaluate();
     }
     finally
     {
         engine.PopScriptObject();
     }
     return function;
 }
        internal ScriptFunction Construct(Object[] args, VsaEngine engine)
        {
            StringBuilder func_string = new StringBuilder("function anonymous(");

            for (int i = 0, n = args.Length - 2; i < n; i++)
            {
                func_string.Append(Convert.ToString(args[i]));
                func_string.Append(", ");
            }
            if (args.Length > 1)
            {
                func_string.Append(Convert.ToString(args[args.Length - 2]));
            }
            func_string.Append(") {\n");
            if (args.Length > 0)
            {
                func_string.Append(Convert.ToString(args[args.Length - 1]));
            }
            func_string.Append("\n}");
            Context  context = new Context(new DocumentContext("anonymous", engine), func_string.ToString());
            JSParser p       = new JSParser(context);

            engine.PushScriptObject(((IActivationObject)engine.ScriptObjectStackTop()).GetGlobalScope());
            try{
                return((ScriptFunction)p.ParseFunctionExpression().PartiallyEvaluate().Evaluate());
            }finally{
                engine.PopScriptObject();
            }
        }
Example #3
0
 internal ScriptFunction Construct(Object[] args, VsaEngine engine){
   StringBuilder func_string = new StringBuilder("function anonymous(");
   for (int i = 0, n = args.Length-2; i < n; i++){
     func_string.Append(Convert.ToString(args[i]));
     func_string.Append(", ");
   }
   if (args.Length > 1)
     func_string.Append(Convert.ToString(args[args.Length-2]));
   func_string.Append(") {\n");
   if (args.Length > 0)
     func_string.Append(Convert.ToString(args[args.Length-1]));
   func_string.Append("\n}");
   Context context = new Context(new DocumentContext("anonymous", engine), func_string.ToString());
   JSParser p = new JSParser(context);
   engine.PushScriptObject(((IActivationObject)Globals.contextEngine.ScriptObjectStackTop()).GetGlobalScope());
   try{
     return (ScriptFunction)p.ParseFunctionExpression().PartiallyEvaluate().Evaluate();
   }finally{
     engine.PopScriptObject();
   }
 }
        internal ScriptFunction Construct(object[] args, VsaEngine engine)
        {
            ScriptFunction function;
            StringBuilder  builder = new StringBuilder("function anonymous(");
            int            index   = 0;
            int            num2    = args.Length - 2;

            while (index < num2)
            {
                builder.Append(Microsoft.JScript.Convert.ToString(args[index]));
                builder.Append(", ");
                index++;
            }
            if (args.Length > 1)
            {
                builder.Append(Microsoft.JScript.Convert.ToString(args[args.Length - 2]));
            }
            builder.Append(") {\n");
            if (args.Length > 0)
            {
                builder.Append(Microsoft.JScript.Convert.ToString(args[args.Length - 1]));
            }
            builder.Append("\n}");
            Context  context = new Context(new DocumentContext("anonymous", engine), builder.ToString());
            JSParser parser  = new JSParser(context);

            engine.PushScriptObject(((IActivationObject)engine.ScriptObjectStackTop()).GetGlobalScope());
            try
            {
                function = (ScriptFunction)parser.ParseFunctionExpression().PartiallyEvaluate().Evaluate();
            }
            finally
            {
                engine.PopScriptObject();
            }
            return(function);
        }