private static DataType ResolveReturnType( ITypeSyntax?returnTypeSyntax, TypeResolver resolver) { var returnType = returnTypeSyntax != null ? resolver.Evaluate(returnTypeSyntax) : DataType.Void; return(returnType); }
private FieldSymbol BuildFieldSymbol(IFieldDeclarationSyntax field) { if (field.Symbol.IsFulfilled) { return(field.Symbol.Result); } field.Symbol.BeginFulfilling(); var resolver = new TypeResolver(field.File, diagnostics); var type = resolver.Evaluate(field.Type); var symbol = new FieldSymbol(field.DeclaringClass.Symbol.Result, field.Name, field.IsMutableBinding, type); field.Symbol.Fulfill(symbol); symbolTree.Add(symbol); return(symbol); }
private FixedList <DataType> ResolveParameterTypes( TypeResolver resolver, IEnumerable <IConstructorParameterSyntax> parameters, IClassDeclarationSyntax?declaringClass) { var types = new List <DataType>(); foreach (var parameter in parameters) { switch (parameter) { default: throw ExhaustiveMatch.Failed(parameter); case INamedParameterSyntax namedParameter: { var type = resolver.Evaluate(namedParameter.Type); types.Add(type); } break; case IFieldParameterSyntax fieldParameter: { var field = (declaringClass ?? throw new InvalidOperationException("Field parameter outside of class declaration")) .Members.OfType <IFieldDeclarationSyntax>() .SingleOrDefault(f => f.Name == fieldParameter.Name); if (field is null) { types.Add(DataType.Unknown); fieldParameter.ReferencedSymbol.Fulfill(null); // TODO report an error throw new NotImplementedException(); } else { var fieldSymbol = BuildFieldSymbol(field); fieldParameter.ReferencedSymbol.Fulfill(fieldSymbol); types.Add(fieldSymbol.DataType); } } break; } } return(types.ToFixedList()); }