예제 #1
0
        void AddDeclaration(object a)
        {
            if (!(a is Statement statement))
            {
                return;
            }
            _tu.AddStatement(statement);

            if (statement is MultiDeclaratorStatement mds)
            {
                switch (mds.Specifiers.StorageClassSpecifier)
                {
                case StorageClassSpecifier.Typedef when mds.InitDeclarators != null:
                    foreach (var i in mds.InitDeclarators)
                    {
                        lexer.AddTypedef(i.Declarator.DeclaredIdentifier);
                    }
                    break;

                case StorageClassSpecifier.None when mds.Specifiers.TypeSpecifiers.Count > 0:
                    foreach (var i in mds.Specifiers.TypeSpecifiers)
                    {
                        if (i.Kind == TypeSpecifierKind.Class ||
                            i.Kind == TypeSpecifierKind.Struct ||
                            i.Kind == TypeSpecifierKind.Union ||
                            i.Kind == TypeSpecifierKind.Enum)
                        {
                            Debug.WriteLine($"Add typedef `{i.Name}`");
                            lexer.AddTypedef(i.Name);
                        }
                    }
                    break;
                }
            }
        }
예제 #2
0
        void AddDeclaration(object a)
        {
            if (!(a is Statement statement))
            {
                return;
            }
            _tu.AddStatement(statement);

            if (statement is MultiDeclaratorStatement mds)
            {
                switch (mds.Specifiers.StorageClassSpecifier)
                {
                case StorageClassSpecifier.Typedef when mds.InitDeclarators != null:
                    foreach (var i in mds.InitDeclarators)
                    {
                        lexer.AddTypedef(i.Declarator.DeclaredIdentifier);
                    }
                    break;
                }
            }
        }
예제 #3
0
 void AddDeclaration(object a)
 {
     _tu.AddStatement((Statement)a);
 }