示例#1
0
        // This is used by other binding APIs to invoke the right binder API
        virtual internal BoundNode Bind(Binder binder, CSharpSyntaxNode node, DiagnosticBag diagnostics)
        {
            var expression = node as ExpressionSyntax;
            if (expression != null)
            {
                var parent = expression.Parent;
                return (parent != null && parent.Kind() == SyntaxKind.GotoStatement)
                    ? binder.BindLabel(expression, diagnostics)
                    : binder.BindNamespaceOrTypeOrExpression(expression, diagnostics);
            }

            var statement = node as StatementSyntax;
            if (statement != null)
            {
                return binder.BindStatement(statement, diagnostics);
            }

            var globalStatement = node as GlobalStatementSyntax;
            if (globalStatement != null)
            {
                BoundStatement bound = binder.BindStatement(globalStatement.Statement, diagnostics);
                return new BoundGlobalStatementInitializer(node, bound);
            }

            return null;
        }