Microsoft.JScript.FunctionConstructor.Construct C# (CSharp) Method

Construct() private method

private Construct ( Object args, VsaEngine engine ) : ScriptFunction
args Object
engine Microsoft.JScript.Vsa.VsaEngine
return ScriptFunction
      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();
        }
      }
      

Same methods

FunctionConstructor::Construct ( Object args ) : Object