CallValue() private method

private CallValue ( Object thisob, Object val, Object arguments, bool construct, bool brackets, VsaEngine engine ) : Object
thisob Object
val Object
arguments Object
construct bool
brackets bool
engine Microsoft.JScript.Vsa.VsaEngine
return Object
Esempio n. 1
0
 public object InvokeMember(string name, BindingFlags flags, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo locale, string[] namedParameters)
 {
     if ((flags & BindingFlags.CreateInstance) == BindingFlags.Default)
     {
         return(LateBinding.CallValue(this.elementType, args, true, true, null, null, binder, locale, namedParameters));
     }
     return(Typeob.Array.InvokeMember(name, flags, binder, target, args, modifiers, locale, namedParameters));
 }
Esempio n. 2
0
 public Object InvokeMember(String name, BindingFlags flags, Binder binder, Object target,
                            Object[] args, ParameterModifier[] modifiers, CultureInfo locale, String[] namedParameters)
 {
     if ((flags & BindingFlags.CreateInstance) == 0)
     {
         //Try to create an instance of the array
         return(LateBinding.CallValue(this.elementType, args, true, true, null, null, binder, locale, namedParameters));
     }
     return(Typeob.Array.InvokeMember(name, flags, binder, target, args, modifiers, locale, namedParameters));
 }
        public static object CallConstructor(string typename, object[] arguments, VsaEngine engine)
        {
            if (engine == null)
            {
                engine = VsaEngine.CreateEngine();
            }
            object type = GetType(typename);

            return(LateBinding.CallValue(null, type, arguments, true, false, engine));
        }
Esempio n. 4
0
        internal override Object Invoke(Object obj, Object thisob, BindingFlags options, Binder binder, Object[] parameters, CultureInfo culture)
        {
            bool   construct = (options & BindingFlags.CreateInstance) != 0;
            bool   brackets  = (options & BindingFlags.GetProperty) != 0 && (options & BindingFlags.InvokeMethod) == 0;
            Object f         = this.func;

            if (f == null)
            {
                f = this.field.GetValue(this.obj);
            }
            FunctionObject func = f as FunctionObject;
            JSObject       jsOb = obj as JSObject;

            if (jsOb != null && func != null && func.isMethod && (func.attributes & MethodAttributes.Virtual) != 0 &&
                jsOb.GetParent() != func.enclosing_scope && ((ClassScope)func.enclosing_scope).HasInstance(jsOb))
            {
                LateBinding lb = new LateBinding(func.name);
                lb.obj = jsOb;
                return(lb.Call(parameters, construct, brackets, ((ScriptObject)this.obj).engine));
            }
            return(LateBinding.CallValue(f, parameters, construct, brackets, ((ScriptObject)this.obj).engine, thisob, binder, culture, null));
        }
Esempio n. 5
0
        internal override object Invoke(object obj, object thisob, BindingFlags options, Binder binder, object[] parameters, CultureInfo culture)
        {
            bool   construct = (options & BindingFlags.CreateInstance) != BindingFlags.Default;
            bool   brackets  = ((options & BindingFlags.GetProperty) != BindingFlags.Default) && ((options & BindingFlags.InvokeMethod) == BindingFlags.Default);
            object func      = this.func;

            if (func == null)
            {
                func = this.field.GetValue(base.obj);
            }
            FunctionObject obj3 = func as FunctionObject;
            JSObject       ob   = obj as JSObject;

            if ((((ob != null) && (obj3 != null)) && (obj3.isMethod && ((obj3.attributes & MethodAttributes.Virtual) != MethodAttributes.PrivateScope))) && ((ob.GetParent() != obj3.enclosing_scope) && ((ClassScope)obj3.enclosing_scope).HasInstance(ob)))
            {
                LateBinding binding = new LateBinding(obj3.name)
                {
                    obj = ob
                };
                return(binding.Call(parameters, construct, brackets, ((ScriptObject)base.obj).engine));
            }
            return(LateBinding.CallValue(func, parameters, construct, brackets, ((ScriptObject)base.obj).engine, thisob, binder, culture, null));
        }
Esempio n. 6
0
        internal override object Evaluate()
        {
            object obj3;

            if ((this.outParameterCount > 0) && VsaEngine.executeForJSEE)
            {
                throw new JScriptException(JSError.RefParamsNonSupportedInDebugger);
            }
            LateBinding callee = this.func.EvaluateAsLateBinding();

            object[] objArray = (this.args == null) ? null : this.args.EvaluateAsArray();
            base.Globals.CallContextStack.Push(new CallContext(base.context, callee, objArray));
            try
            {
                object             obj2 = null;
                CallableExpression func = this.func as CallableExpression;
                if ((func == null) || !(func.expression is Call))
                {
                    obj2 = callee.Call(objArray, this.isConstructor, this.inBrackets, base.Engine);
                }
                else
                {
                    obj2 = LateBinding.CallValue(callee.obj, objArray, this.isConstructor, this.inBrackets, base.Engine, func.GetObject2(), JSBinder.ob, null, null);
                }
                if (this.outParameterCount > 0)
                {
                    int index = 0;
                    int count = this.args.count;
                    while (index < count)
                    {
                        if (this.args[index] is AddressOf)
                        {
                            this.args[index].SetValue(objArray[index]);
                        }
                        index++;
                    }
                }
                obj3 = obj2;
            }
            catch (TargetInvocationException exception)
            {
                JScriptException innerException;
                if (exception.InnerException is JScriptException)
                {
                    innerException = (JScriptException)exception.InnerException;
                    if (innerException.context == null)
                    {
                        if (innerException.Number == -2146823281)
                        {
                            innerException.context = this.func.context;
                        }
                        else
                        {
                            innerException.context = base.context;
                        }
                    }
                }
                else
                {
                    innerException = new JScriptException(exception.InnerException, base.context);
                }
                throw innerException;
            }
            catch (JScriptException exception3)
            {
                if (exception3.context == null)
                {
                    if (exception3.Number == -2146823281)
                    {
                        exception3.context = this.func.context;
                    }
                    else
                    {
                        exception3.context = base.context;
                    }
                }
                throw exception3;
            }
            catch (Exception exception4)
            {
                throw new JScriptException(exception4, base.context);
            }
            finally
            {
                base.Globals.CallContextStack.Pop();
            }
            return(obj3);
        }
Esempio n. 7
0
 internal Object Construct(Object thisob, Object[] args)
 {
     return(LateBinding.CallValue(this.cons, args, true, false, cons.engine, thisob, JSBinder.ob, null, null));
 }
Esempio n. 8
0
 public override Object Invoke(BindingFlags options, Binder binder, Object[] parameters, CultureInfo culture)
 {
     return(LateBinding.CallValue(this.cons, parameters, true, false, this.cons.engine, null, binder, culture, null));
 }
Esempio n. 9
0
        internal override Object Evaluate()
        {
            if (this.outParameterCount > 0 && VsaEngine.executeForJSEE)
            {
                throw new JScriptException(JSError.RefParamsNonSupportedInDebugger);
            }
            LateBinding funcref = this.func.EvaluateAsLateBinding();

            Object[] actual_arguments = this.args == null ? null : this.args.EvaluateAsArray();
            Globals.CallContextStack.Push(new CallContext(this.context, funcref, actual_arguments));
            try{
                try{
                    Object             result = null;
                    CallableExpression cexpr  = this.func as CallableExpression;
                    if (cexpr == null || !(cexpr.expression is Call))
                    {
                        result = funcref.Call(actual_arguments, this.isConstructor, this.inBrackets, this.Engine);
                    }
                    else
                    {
                        result = LateBinding.CallValue(funcref.obj, actual_arguments, this.isConstructor, this.inBrackets, this.Engine,
                                                       cexpr.GetObject2(), JSBinder.ob, null, null);
                    }
                    if (this.outParameterCount > 0)
                    {
                        for (int i = 0, n = this.args.count; i < n; i++)
                        {
                            if (this.args[i] is AddressOf)
                            {
                                this.args[i].SetValue(actual_arguments[i]);
                            }
                        }
                    }
                    return(result);
                }catch (TargetInvocationException e) {
                    JScriptException se;
                    if (e.InnerException is JScriptException)
                    {
                        se = (JScriptException)e.InnerException;
                        if (se.context == null)
                        {
                            if (((uint)se.Number) == (0x800A0000 | (uint)JSError.ObjectExpected))
                            {
                                se.context = this.func.context;
                            }
                            else
                            {
                                se.context = this.context;
                            }
                        }
                    }
                    else
                    {
                        se = new JScriptException(e.InnerException, this.context);
                    }
                    throw se;
                }catch (JScriptException e) {
                    if (e.context == null)
                    {
                        if (((uint)e.Number) == (0x800A0000 | (uint)JSError.ObjectExpected))
                        {
                            e.context = this.func.context;
                        }
                        else
                        {
                            e.context = this.context;
                        }
                    }
                    throw e;
                }catch (Exception e) {
                    throw new JScriptException(e, this.context);
                }catch {
                    throw new JScriptException(JSError.NonClsException, this.context);
                }
            }finally{
                Globals.CallContextStack.Pop();
            }
        }
Esempio n. 10
0
 internal override object Construct(object[] args)
 {
     return(LateBinding.CallValue(this.field.GetValue(base.obj), args, true, false, ((ScriptObject)base.obj).engine, null, JSBinder.ob, null, null));
 }