示例#1
0
        public JsInstance get(JsInstance that, JsInstance index)
        {
            JsIndexerGetter getter = m_getOverload.ResolveOverload(new JsInstance[] { index }, null);

            if (getter == null)
            {
                throw new JintException("No matching overload found");
            }
            return(getter(that, index));
        }
示例#2
0
        public void set(JsInstance that, JsInstance index, JsInstance value)
        {
            JsIndexerSetter setter = m_setOverload.ResolveOverload(new JsInstance[] { index, value }, null);

            if (setter == null)
            {
                throw new JintException("No matching overload found");
            }

            setter(that, index, value);
        }
示例#3
0
        /// <summary>
        /// Finds a best matched constructor and uses it to create a native object instance
        /// </summary>
        /// <param name="visitor">Execution visitor</param>
        /// <param name="parameters">Parameters for a constructor</param>
        /// <returns>A newly created native object</returns>
        object CreateInstance(Jint.Expressions.IJintVisitor visitor, JsInstance[] parameters)
        {
            ConstructorImpl impl = m_overloads.ResolveOverload(parameters, null);

            if (impl == null)
            {
                throw new JintException(
                          String.Format("No matching overload found {0}({1})",
                                        reflectedType.FullName,
                                        String.Join(",", Array.ConvertAll <JsInstance, string>(parameters, p => p.ToString()))
                                        )
                          );
            }

            return(impl(visitor.Global, parameters));
        }
示例#4
0
 public override JsInstance Execute(IJintVisitor visitor, JsDictionaryObject that, JsInstance[] parameters, Type[] genericArguments)
 {
     if (m_generics.Count == 0 && (genericArguments != null && genericArguments.Length > 0))
     {
         return(base.Execute(visitor, that, parameters, genericArguments));
     }
     else
     {
         JsMethodImpl impl = m_overloads.ResolveOverload(parameters, genericArguments);
         if (impl == null)
         {
             throw new JintException(String.Format("No matching overload found {0}<{1}>", Name, genericArguments));
         }
         visitor.Return(impl(visitor.Global, that, parameters));
         return(that);
     }
 }