Inheritance: ClassOrStructSymbol
Esempio n. 1
0
 public ClassMethodBinder(SharedBinderState sharedBinderState, Binder parent, ClassSymbol classSymbol)
     : base(sharedBinderState, parent)
 {
     _classSymbol = classSymbol;
 }
Esempio n. 2
0
        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.Span);

            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.BindVariableDeclarationStatement(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());
        }
Esempio n. 3
0
 public BoundClassType(ClassSymbol classSymbol, ImmutableArray<BoundNode> members)
     : base(BoundNodeKind.ClassType, classSymbol)
 {
     ClassSymbol = classSymbol;
     Members = members;
 }