IEnumerable <CrawlMethodType> GetMethodTypesFromTypeInformation(TypeInformation tif) { if (tif.NeedsABetterNameType == NeedsABetterNameType.Class) { CrawlConstructedType ctype = (CrawlConstructedType)tif.Type; TypeInformation[] constructors = ctype.FindSymbol(".ctor"); foreach (TypeInformation constructor in constructors) { yield return((CrawlMethodType)constructor.Type); } } else { yield return((CrawlMethodType)tif.Type); } }
protected override CrawlSyntaxNode VisitBlock(BlockNode block) { string ns = block.FindNameSpace()?.Module ?? ""; BlockScope scope = new BlockScope(); List <CrawlSyntaxNode> children = new List <CrawlSyntaxNode>(); foreach (CrawlSyntaxNode child in block) { CrawlSyntaxNode afterVisit = Visit(child); ClassTypeDeclerationNode asClass = afterVisit as ClassTypeDeclerationNode; if (asClass != null) { CrawlConstructedType type = scope.AddClass(asClass, ns); children.Add(asClass.WithClassType(type)); } else { children.Add(afterVisit); } } return(block.Update(block.Interval, children, scope)); }
public CrawlConstructedType AddClass(ClassTypeDeclerationNode node, string ns) { DeclaringScope declaringScope = DeclaringScope.MethodLike; if (node.Parent is ClassTypeDeclerationNode || node.Parent is TranslationUnitNode) { declaringScope = DeclaringScope.ClassLike; //Workingish, parrent == TranslationUnit probably going to require a little special handling } string name = node.Identifier.Value; CrawlConstructedType type = new CrawlConstructedType(name, ns); TypeInformation info = new TypeInformation(type, node.ProtectionLevel, node.Interval.a, declaringScope, NeedsABetterNameType.Class); //Update contents. If not existing add a new array (line 2) //Otherwise, linq to append to array _scopeDictionary.AddOrUpdate( name, new[] { info }, (s, informations) => informations.Concat(info.AsSingleIEnumerable()).ToArray() ); _classes.Add(type); return(type); }