示例#1
0
        private ISet <IMethodDeclaration> findMemberCandidates(bool checkInstance)
        {
            MethodSelector selector = methodCall.getSelector();

            if (selector.getParent() == null)
            {
                // if called from a member method, could be a member method called without this/self
                InstanceContext instance = context.getClosestInstanceContext();
                if (instance != null)
                {
                    IType type = instance.getInstanceType();
                    ConcreteCategoryDeclaration cd = context.getRegisteredDeclaration <ConcreteCategoryDeclaration>(type.GetTypeName());
                    if (cd != null)
                    {
                        MethodDeclarationMap members = cd.getMemberMethods(context, selector.getName());
                        if (members != null)
                        {
                            return(new HashSet <IMethodDeclaration>(members.Values));
                        }
                    }
                }
                return(new HashSet <IMethodDeclaration>());
            }
            else
            {
                IType parentType = selector.checkParentType(context, checkInstance);
                return(parentType != null?parentType.getMemberMethods(context, selector.getName()) : new HashSet <IMethodDeclaration>());
            }
        }
示例#2
0
        public override INamed getRegistered(string name)
        {
            if (widgetFields != null)
            {
                WidgetField field = null;
                if (widgetFields.TryGetValue(name, out field))
                {
                    return(field);
                }
            }
            INamed actual = base.getRegistered(name);

            if (actual != null)
            {
                return(actual);
            }
            ConcreteCategoryDeclaration decl    = getDeclaration();
            MethodDeclarationMap        methods = decl.getMemberMethods(this, name);

            if (methods != null && methods.Count > 0)
            {
                return(methods);
            }
            else if (decl.hasAttribute(this, name))
            {
                return(getRegisteredDeclaration <AttributeDeclaration>(name));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
 private static IMethodDeclaration locateMethod(MethodDeclarationMap map, params IType[] argTypes)
 {
     // try exact match first
     foreach (IMethodDeclaration method in map.Values)
     {
         if (identicalArguments(method.getParameters(), argTypes))
         {
             return(method);
         }
     }
     // match Text{} argument, will pass null
     if (argTypes.Length == 0)
     {
         foreach (IMethodDeclaration method in map.Values)
         {
             if (isSingleTextDictArgument(method.getParameters()))
             {
                 return(method);
             }
         }
     }
     // match no argument, will ignore options
     foreach (IMethodDeclaration method in map.Values)
     {
         if (method.getParameters().Count == 0)
         {
             return(method);
         }
     }
     throw new SyntaxError("Could not find a compatible \"" + map.GetName() + "\" method.");
 }
示例#4
0
        private static IMethodDeclaration locateMethod(Context context, String methodName, String cmdLineArgs)
        {
            MethodDeclarationMap map = context.getRegisteredDeclaration <MethodDeclarationMap>(methodName);

            if (map == null)
            {
                throw new SyntaxError("Could not find a \"" + methodName + "\" method.");
            }
            return(locateMethod(map, cmdLineArgs));
        }
示例#5
0
 private static IMethodDeclaration locateMethod(MethodDeclarationMap map, String cmdLineArgs)
 {
     if (cmdLineArgs == null)
     {
         return(locateMethod(map));
     }
     else
     {
         return(locateMethod(map, new DictType(TextType.Instance)));
     }
 }
示例#6
0
        private ISet <IMethodDeclaration> findGlobalCandidates(bool checkInstance)
        {
            MethodSelector selector = methodCall.getSelector();

            if (selector.getParent() != null)
            {
                return(new HashSet <IMethodDeclaration>());
            }
            MethodDeclarationMap globals = context.getRegisteredDeclaration <MethodDeclarationMap>(selector.getName());

            return(globals != null ? new HashSet <IMethodDeclaration>(globals.Values) : new HashSet <IMethodDeclaration>());
        }
示例#7
0
        public void registerDeclaration(IMethodDeclaration declaration)
        {
            INamed actual = getRegistered(declaration.GetName());

            if (actual != null && !(actual is MethodDeclarationMap))
            {
                throw new SyntaxError("Duplicate name: \"" + declaration.GetName() + "\"");
            }
            if (actual == null)
            {
                actual = new MethodDeclarationMap(declaration.GetName());
                declarations[declaration.GetName()] = (MethodDeclarationMap)actual;
            }
            ((MethodDeclarationMap)actual).register(declaration, this);
        }
示例#8
0
 public override T getRegisteredDeclaration <T>(string name)
 {
     if (typeof(T) == typeof(MethodDeclarationMap))
     {
         ConcreteCategoryDeclaration decl = getDeclaration();
         if (decl != null)
         {
             MethodDeclarationMap methods = decl.getMemberMethods(this, name);
             if (methods != null && methods.Count > 0)
             {
                 return(TypeUtils.downcast <T>(methods));
             }
         }
     }
     return(base.getRegisteredDeclaration <T>(name));
 }