internal JSFunctionObject(functionExpressionNode def, JSEnvRec Scope)
     : base(JSContext.CurrentGlobalContext.FunctionPrototype, JSContext.CurrentGlobalContext.FunctionCtor)
 {
     this.FunctionDef = def;
     JSObject p = new JSObject();
     p.SetDataProp("constructor", this, true, false, true);
     base.SetDataProp("prototype", p, true, false, false);
     this.Scope = Scope;
 }
 public override int GenerateFunction(functionExpressionNode node, string name, StatementNode r, out FunctionDelegate _delegate)
 {
     DynamicMethod method = new DynamicMethod(name, MethodAttributes.Static | MethodAttributes.Public, CallingConventions.Standard, typeof(JSValue), new Type[] { typeof(JSContext) }, typeof(JSContext), false);
     ILGenerator tmp = method.GetILGenerator();
     base.GenerateFunctionBody(r, tmp);
     _delegate = (FunctionDelegate) method.CreateDelegate(typeof(FunctionDelegate));
     base.Source.FunctionList.Add(node);
     return (base.Source.FunctionList.Count - 1);
 }
        internal JSFunctionObject(functionExpressionNode def, JSEnvRec Scope) : base(JSContext.CurrentGlobalContext.FunctionPrototype, JSContext.CurrentGlobalContext.FunctionCtor)
        {
            this.FunctionDef = def;
            JSObject p = new JSObject();

            p.SetDataProp("constructor", this, true, false, true);
            base.SetDataProp("prototype", p, true, false, false);
            this.Scope = Scope;
        }
        public override int GenerateFunction(functionExpressionNode node, string name, StatementNode r, out FunctionDelegate _delegate)
        {
            DynamicMethod method = new DynamicMethod(name, MethodAttributes.Static | MethodAttributes.Public, CallingConventions.Standard, typeof(JSValue), new Type[] { typeof(JSContext) }, typeof(JSContext), false);
            ILGenerator   tmp    = method.GetILGenerator();

            base.GenerateFunctionBody(r, tmp);
            _delegate = (FunctionDelegate)method.CreateDelegate(typeof(FunctionDelegate));
            base.Source.FunctionList.Add(node);
            return(base.Source.FunctionList.Count - 1);
        }
 public override int GenerateFunction(functionExpressionNode node, string name, StatementNode r, out FunctionDelegate _delegate)
 {
     int n = this.FunctionList.Count;
     MethodBuilder method = this.tb.DefineMethod(name + "_" + n, MethodAttributes.Static | MethodAttributes.Public, typeof(JSValue), new Type[] { typeof(JSContext) });
     method.DefineParameter(1, ParameterAttributes.None, "context");
     base.GenerateFunctionBody(r, method.GetILGenerator());
     this.FunctionList.Add(new _FncInfo() { args=node.ParameterList.Names, mb = method});
     _delegate = null;
     return n;
 }
Example #6
0
        public override int GenerateFunction(functionExpressionNode node, string name, StatementNode r, out FunctionDelegate _delegate)
        {
            int           n      = this.FunctionList.Count;
            MethodBuilder method = this.tb.DefineMethod(name + "_" + n, MethodAttributes.Static | MethodAttributes.Public, typeof(JSValue), new Type[] { typeof(JSContext) });

            method.DefineParameter(1, ParameterAttributes.None, "context");
            base.GenerateFunctionBody(r, method.GetILGenerator());
            this.FunctionList.Add(new _FncInfo()
            {
                args = node.ParameterList.Names, mb = method
            });
            _delegate = null;
            return(n);
        }
Example #7
0
        protected internal virtual JSValue GetFunctionReference(int key, JSEnvRec r)
        {
            JSContext ctx = this;

            if (ctx.Source == null)
            {
                return(this.Parent.GetFunctionReference(key, r));
            }
            functionExpressionNode fncNode = ctx.Source.FunctionList[key];
            JSFunctionObject       fnc     = new JSFunctionObject(fncNode, r);

            fnc.SetDataProp("length", (double)fncNode.ParameterList.Names.Length, false, false, false);
            return(fnc);
        }
    private void GenStatementCode(CompileContext compileContext)
    {
        functionExpressionNode fnc = (functionExpressionNode)base.Children[0];
        string fncName             = fnc.Name;

        compileContext.gen.Emit(OpCodes.Ldarg_0);
        compileContext.gen.Emit(OpCodes.Ldstr, fncName);
        compileContext.gen.EmitCallV(CompileContext.mi_CreateMutableBinding);
        compileContext.gen.Emit(OpCodes.Ldarg_0);
        compileContext.gen.Emit(OpCodes.Ldstr, fncName);
        compileContext.gen.Emit(OpCodes.Ldarg_0);
        fnc.GenFunctionRef(compileContext);
        compileContext.gen.EmitCallV(CompileContext.mi_GetFunctionReference);
        compileContext.gen.EmitCallV(CompileContext.mi_SetVarBinding);
    }
 public abstract int GenerateFunction(functionExpressionNode node, string name, StatementNode r, out FunctionDelegate _delegate);
Example #10
0
 public abstract int GenerateFunction(functionExpressionNode node, string name, StatementNode r, out FunctionDelegate _delegate);