Пример #1
0
 internal MemberInfo[] GetDefaultMembers()
 {
     MemberInfo[] result = this.defaultMembers;
     if (result == null)
     {
         result = JSBinder.GetDefaultMembers(this.type);
         if (result == null)
         {
             result = new MemberInfo[0];
         }
         TypeReflector.WrapMembers(this.defaultMembers = result);
     }
     return(result);
 }
 internal MemberInfo[] GetDefaultMembers()
 {
     MemberInfo[] defaultMembers = this.defaultMembers;
     if (defaultMembers == null)
     {
         defaultMembers = JSBinder.GetDefaultMembers(this.type);
         if (defaultMembers == null)
         {
             defaultMembers = new MemberInfo[0];
         }
         WrapMembers(this.defaultMembers = defaultMembers);
     }
     return(defaultMembers);
 }
        internal override void ResolveCall(ASTList args, IReflect[] argIRs, bool constructor, bool brackets)
        {
            string str;

            if (constructor || !brackets)
            {
                if (this.isSuper)
                {
                    base.context.HandleError(JSError.IllegalUseOfSuper);
                    return;
                }
                base.context.HandleError(JSError.IllegalUseOfThis);
                return;
            }
            IReflect reflect = this.InferType(null);
            Type     t       = (reflect is Type) ? ((Type)reflect) : null;

            if (reflect is ClassScope)
            {
                t = ((ClassScope)reflect).GetBakedSuperType();
            }
            MemberInfo[] defaultMembers = JSBinder.GetDefaultMembers(t);
            if ((defaultMembers != null) && (defaultMembers.Length > 0))
            {
                try
                {
                    this.method = JSBinder.SelectMethod(defaultMembers, argIRs);
                    if (this.method == null)
                    {
                        goto Label_00C5;
                    }
                    if (!Binding.CheckParameters(this.method.GetParameters(), argIRs, args, base.context, 0, false, true))
                    {
                        this.method = null;
                    }
                }
                catch (AmbiguousMatchException)
                {
                    base.context.HandleError(JSError.AmbiguousMatch);
                }
                return;
            }
Label_00C5:
            str = (reflect is ClassScope) ? ((ClassScope)reflect).GetName() : ((Type)reflect).Name;
            base.context.HandleError(JSError.NotIndexable, str);
        }
Пример #4
0
        internal override void ResolveCall(ASTList args, IReflect[] argIRs, bool constructor, bool brackets)
        {
            if (constructor || !brackets)
            {
                if (this.isSuper)
                {
                    this.context.HandleError(JSError.IllegalUseOfSuper);
                }
                else
                {
                    this.context.HandleError(JSError.IllegalUseOfThis);
                }
                return;
            }
            IReflect ir = this.InferType(null);
            Type     t  = ir is Type ? (Type)ir : null;

            if (ir is ClassScope)
            {
                t = ((ClassScope)ir).GetBakedSuperType();
            }
            MemberInfo[] defaultMembers = JSBinder.GetDefaultMembers(t);
            if (defaultMembers != null && defaultMembers.Length > 0)
            {
                try{
                    this.method = JSBinder.SelectMethod(defaultMembers, argIRs); //Returns property getters as well
                    if (this.method != null)
                    {
                        if (!Binding.CheckParameters(this.method.GetParameters(), argIRs, args, this.context, 0, false, true))
                        {
                            this.method = null;
                        }
                        return;
                    }
                }catch (AmbiguousMatchException) {
                    this.context.HandleError(JSError.AmbiguousMatch);
                    return;
                }
            }
            String tname = ir is ClassScope ? ((ClassScope)ir).GetName() : ((Type)ir).Name;

            this.context.HandleError(JSError.NotIndexable, tname);
        }
        internal void ResolveAssignmentToDefaultIndexedProperty(ASTList args, IReflect[] argIRs, AST rhvalue)
        {
            string   str;
            IReflect reflect = this.InferType(null);
            Type     t       = (reflect is Type) ? ((Type)reflect) : null;

            if (reflect is ClassScope)
            {
                t = ((ClassScope)reflect).GetBakedSuperType();
            }
            MemberInfo[] defaultMembers = JSBinder.GetDefaultMembers(t);
            if ((defaultMembers != null) && (defaultMembers.Length > 0))
            {
                try
                {
                    PropertyInfo prop = JSBinder.SelectProperty(defaultMembers, argIRs);
                    if (prop == null)
                    {
                        goto Label_00B1;
                    }
                    this.method = JSProperty.GetSetMethod(prop, true);
                    if (this.method == null)
                    {
                        base.context.HandleError(JSError.AssignmentToReadOnly, true);
                    }
                    if (!Binding.CheckParameters(prop.GetIndexParameters(), argIRs, args, base.context, 0, false, true))
                    {
                        this.method = null;
                    }
                }
                catch (AmbiguousMatchException)
                {
                    base.context.HandleError(JSError.AmbiguousMatch);
                }
                return;
            }
Label_00B1:
            str = (reflect is ClassScope) ? ((ClassScope)reflect).GetName() : ((Type)reflect).Name;
            base.context.HandleError(JSError.NotIndexable, str);
        }
Пример #6
0
        internal void ResolveAssignmentToDefaultIndexedProperty(ASTList args, IReflect[] argIRs, AST rhvalue)
        {
            IReflect ir = this.InferType(null);
            Type     t  = ir is Type ? (Type)ir : null;

            if (ir is ClassScope)
            {
                t = ((ClassScope)ir).GetBakedSuperType();
            }
            MemberInfo[] defaultMembers = JSBinder.GetDefaultMembers(t);
            if (defaultMembers != null && defaultMembers.Length > 0)
            {
                try{
                    PropertyInfo prop = JSBinder.SelectProperty(defaultMembers, argIRs); //Returns property getters as well
                    if (prop != null)
                    {
                        this.method = JSProperty.GetSetMethod(prop, true);
                        if (this.method == null)
                        {
                            this.context.HandleError(JSError.AssignmentToReadOnly, true);
                        }
                        if (!Binding.CheckParameters(prop.GetIndexParameters(), argIRs, args, this.context, 0, false, true))
                        {
                            this.method = null;
                        }
                        return;
                    }
                }catch (AmbiguousMatchException) {
                    this.context.HandleError(JSError.AmbiguousMatch);
                    return;
                }
            }
            String tname = ir is ClassScope ? ((ClassScope)ir).GetName() : ((Type)ir).Name;

            this.context.HandleError(JSError.NotIndexable, tname);
        }