Inheritance: ClassOrStructSymbol
示例#1
0
        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());
        }
示例#2
0
 public BoundStructType(StructSymbol structSymbol, ImmutableArray<BoundMultipleVariableDeclarations> variables)
     : base(BoundNodeKind.StructType, structSymbol)
 {
     StructSymbol = structSymbol;
     Variables = variables;
 }