Пример #1
0
        public override object ExecIdCall(IdFunctionObject f, Context cx, IScriptable scope, IScriptable thisObj, object [] args)
        {
            if (!f.HasTag(FUNCTION_TAG))
            {
                return(base.ExecIdCall(f, cx, scope, thisObj, args));
            }
            int id = f.MethodId;

            switch (id)
            {
            case Id_constructor:
                return(JsConstructor(cx, scope, args));


            case Id_toString: {
                BaseFunction realf  = RealFunction(thisObj, f);
                int          indent = ScriptConvert.ToInt32(args, 0);
                return(realf.Decompile(indent, Decompiler.TO_STRING_FLAG));
            }


            case Id_toSource: {
                BaseFunction realf  = RealFunction(thisObj, f);
                int          indent = 0;
                int          flags  = Decompiler.TO_SOURCE_FLAG;
                if (args.Length != 0)
                {
                    indent = ScriptConvert.ToInt32(args [0]);
                    if (indent >= 0)
                    {
                        flags = 0;
                    }
                    else
                    {
                        indent = 0;
                    }
                }
                return(realf.Decompile(indent, flags));
            }


            case Id_apply:
            case Id_call:
                return(ScriptRuntime.applyOrCall(id == Id_apply, cx, scope, thisObj, args));
            }
            throw new ArgumentException(Convert.ToString(id));
        }