private BindField ( VariableDeclarationStatementSyntax variableDeclarationStatementSyntax, |
||
variableDeclarationStatementSyntax | VariableDeclarationStatementSyntax | |
parentType | ||
return |
private BoundStructType BindStructDeclaration(StructTypeSyntax declaration, Symbol parent) { ClassOrStructSymbol baseType; List <InterfaceSymbol> baseInterfaces; BindBaseList(declaration.BaseList, parent, out baseType, out baseInterfaces); var structSymbol = new StructSymbol(declaration, parent, baseType, baseInterfaces.ToImmutableArray()); AddSymbol(structSymbol, declaration.Name?.SourceRange ?? declaration.SourceRange); var variables = new List <BoundMultipleVariableDeclarations>(); var structBinder = new Binder(_sharedBinderState, this); foreach (var variableDeclarationStatement in declaration.Fields) { variables.Add(structBinder.Bind(variableDeclarationStatement, x => structBinder.BindField(x, structSymbol))); } foreach (var member in structBinder.LocalSymbols.Values.SelectMany(x => x)) { structSymbol.AddMember(member); } return(new BoundStructType(structSymbol, variables.ToImmutableArray())); }
private BoundStructType BindStructDeclaration(StructTypeSyntax declaration, Symbol parent) { ClassOrStructSymbol baseType; List<InterfaceSymbol> baseInterfaces; BindBaseList(declaration.BaseList, parent, out baseType, out baseInterfaces); var structSymbol = new StructSymbol(declaration, parent, baseType, baseInterfaces.ToImmutableArray()); AddSymbol(structSymbol, declaration.Name?.Span ?? declaration.GetTextSpanSafe()); var variables = new List<BoundMultipleVariableDeclarations>(); var structBinder = new Binder(_sharedBinderState, this); foreach (var variableDeclarationStatement in declaration.Fields) variables.Add(structBinder.Bind(variableDeclarationStatement, x => structBinder.BindField(x, structSymbol))); foreach (var member in structBinder.LocalSymbols.Values.SelectMany(x => x)) structSymbol.AddMember(member); return new BoundStructType(structSymbol, variables.ToImmutableArray()); }
private BoundClassType BindClassDeclaration(ClassTypeSyntax declaration, Symbol parent) { ClassOrStructSymbol baseType; List <InterfaceSymbol> baseInterfaces; BindBaseList(declaration.BaseList, parent, out baseType, out baseInterfaces); var classBinder = new Binder(_sharedBinderState, this); var classSymbol = new ClassSymbol(declaration, parent, baseType, baseInterfaces.ToImmutableArray(), classBinder); AddSymbol(classSymbol, declaration.Name.SourceRange); var members = new List <BoundNode>(); foreach (var memberSyntax in declaration.Members) { switch (memberSyntax.Kind) { case SyntaxKind.VariableDeclarationStatement: members.Add(classBinder.Bind((VariableDeclarationStatementSyntax)memberSyntax, x => classBinder.BindField(x, classSymbol))); break; case SyntaxKind.FunctionDeclaration: members.Add(classBinder.Bind((FunctionDeclarationSyntax)memberSyntax, x => classBinder.BindFunctionDeclaration(x, classSymbol))); break; case SyntaxKind.FunctionDefinition: members.Add(classBinder.Bind((FunctionDefinitionSyntax)memberSyntax, x => classBinder.BindFunctionDefinition(x, classSymbol))); break; } } foreach (var member in classBinder.LocalSymbols.Values.SelectMany(x => x)) { classSymbol.AddMember(member); } return(new BoundClassType(classSymbol, members.ToImmutableArray())); }