Exemplo n.º 1
0
        public virtual VSMXFunction getFunction(int numberOfArguments, VSMXBaseObject[] arguments)
        {
            this.numberOfArguments = numberOfArguments;
            this.arguments         = arguments;
            thisObject             = @object.Value;

            if (@object.hasPropertyValue(name))
            {
                VSMXBaseObject function = @object.getPropertyValue(name).Value;
                if (function != null && function is VSMXFunction)
                {
                    return((VSMXFunction)function);
                }
            }

            if (@object is VSMXFunction && callName.Equals(name))
            {
                // The first argument of the "call()" function call is the "this" object.
                if (numberOfArguments > 0)
                {
                    this.numberOfArguments--;
                    if (arguments.Length > 0)
                    {
                        thisObject     = arguments[0];
                        this.arguments = new VSMXBaseObject[this.numberOfArguments];
                        Array.Copy(arguments, 1, this.arguments, 0, this.numberOfArguments);
                    }
                }

                return((VSMXFunction)@object);
            }

            INativeFunction nativeFunction = null;

            if (@object is VSMXNativeObject)
            {
                VSMXNativeObject nativeObject = (VSMXNativeObject)@object;
                nativeFunction = NativeFunctionFactory.Instance.getNativeFunction(nativeObject, name, numberOfArguments);
            }
            else if (@object is VSMXBaseObject)
            {
                nativeFunction = NativeFunctionFactory.Instance.getNativeFunction(@object, name, numberOfArguments);
            }

            if (nativeFunction != null)
            {
                return(new VSMXNativeFunction(interpreter, nativeFunction));
            }

            return(null);
        }
Exemplo n.º 2
0
        protected internal virtual VSMXBaseObject getRef(int numberOfArguments)
        {
            if (string.ReferenceEquals(refProperty, null))
            {
                return(refObject.getPropertyValue(refIndex));
            }

            if (!refObject.hasPropertyValue(refProperty) && refObject is VSMXNativeObject)
            {
                VSMXNativeObject nativeObject   = (VSMXNativeObject)refObject;
                INativeFunction  nativeFunction = NativeFunctionFactory.Instance.getNativeFunction(nativeObject, refProperty, numberOfArguments);
                if (nativeFunction != null)
                {
                    return(new VSMXNativeFunction(interpreter, nativeFunction));
                }
            }

            return(refObject.getPropertyValue(refProperty));
        }