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>()); } }
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); } }
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."); }
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)); }
private static IMethodDeclaration locateMethod(MethodDeclarationMap map, String cmdLineArgs) { if (cmdLineArgs == null) { return(locateMethod(map)); } else { return(locateMethod(map, new DictType(TextType.Instance))); } }
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>()); }
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); }
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)); }