Exemplo n.º 1
0
        private static void WriteGlobalVariableTo(GlobalVariableSymbol symbol, TextWriter writer)
        {
            writer.WriteKeyword(symbol.IsReadOnly ? SyntaxKind.LetKeyword : SyntaxKind.VarKeyword);
            writer.WriteSpace();
            writer.WriteIdentifier(symbol.Name);
            writer.WritePunctuation(SyntaxKind.ColonToken);
            writer.WriteSpace();

            symbol.Type.WriteTo(writer);
        }
Exemplo n.º 2
0
        private void BindGlobalVariable(VariableDeclarationStatementSyntax variableDeclarationStatementSyntax)
        {
            var declaration = variableDeclarationStatementSyntax.Declaration;

            foreach (var declarator in declaration.Variables)
            {
                var variableType = _symbolSet.ResolveType(declaration.Type, null, null);

                foreach (var arrayRankSpecifier in declarator.ArrayRankSpecifiers)
                {
                    variableType = new ArraySymbol(variableType);
                }

                var symbol = new GlobalVariableSymbol(declarator, variableType);
                _bindingResult.AddSymbol(declarator, symbol);

                _symbolSet.AddGlobal(symbol);
            }
        }