/// <summary> /// If the type has not been resolved, this resolves it. This function /// also watches for type cycles and reports an error. /// </summary> private void BuildEntitySymbol(IEntityDeclarationSyntax entity) { switch (entity) { default: throw ExhaustiveMatch.Failed(entity); case IMethodDeclarationSyntax method: BuildMethodSymbol(method); break; case IConstructorDeclarationSyntax constructor: BuildConstructorSymbol(constructor); break; case IAssociatedFunctionDeclarationSyntax associatedFunction: BuildAssociatedFunctionSymbol(associatedFunction); break; case IFieldDeclarationSyntax field: BuildFieldSymbol(field); break; case IFunctionDeclarationSyntax syn: BuildFunctionSymbol(syn); break; case IClassDeclarationSyntax syn: BuildClassSymbol(syn); break; } }
private void ResolveBodyTypes(IEntityDeclarationSyntax declaration) { switch (declaration) { default: throw ExhaustiveMatch.Failed(declaration); case IFunctionDeclarationSyntax function: { var resolver = new BasicBodyAnalyzer(function, symbolTreeBuilder, symbolTrees, stringSymbol, diagnostics, function.Symbol.Result.ReturnDataType); resolver.ResolveTypes(function.Body); break; } case IAssociatedFunctionDeclarationSyntax associatedFunction: { var resolver = new BasicBodyAnalyzer(associatedFunction, symbolTreeBuilder, symbolTrees, stringSymbol, diagnostics, associatedFunction.Symbol.Result.ReturnDataType); resolver.ResolveTypes(associatedFunction.Body); break; } case IConcreteMethodDeclarationSyntax method: { var resolver = new BasicBodyAnalyzer(method, symbolTreeBuilder, symbolTrees, stringSymbol, diagnostics, method.Symbol.Result.ReturnDataType); resolver.ResolveTypes(method.Body); break; } case IAbstractMethodDeclarationSyntax _: // has no body, so nothing to resolve break; case IFieldDeclarationSyntax field: if (field.Initializer != null) { var resolver = new BasicBodyAnalyzer(field, symbolTreeBuilder, symbolTrees, stringSymbol, diagnostics); resolver.CheckType(ref field.Initializer, field.Symbol.Result.DataType); } break; case IConstructorDeclarationSyntax constructor: { var resolver = new BasicBodyAnalyzer(constructor, symbolTreeBuilder, symbolTrees, stringSymbol, diagnostics, constructor.ImplicitSelfParameter.Symbol.Result.DataType); resolver.ResolveTypes(constructor.Body); break; } case IClassDeclarationSyntax _: // body of class is processed as separate items break; } }