source: src/Parser/TypeData.h @ e4d7c1c

ADTast-experimental
Last change on this file since e4d7c1c was e4d7c1c, checked in by JiadaL <j82liang@…>, 19 months ago

Implement enum Hiding

  • Property mode set to 100644
File size: 4.7 KB
RevLine 
[b87a5ed]1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
[148f7290]7// TypeData.h --
[b87a5ed]8//
[fec3e9a]9// Author           : Peter A. Buhr
[b87a5ed]10// Created On       : Sat May 16 15:18:36 2015
[e612146c]11// Last Modified By : Peter A. Buhr
[66406f3]12// Last Modified On : Tue May 10 22:18:49 2022
13// Update Count     : 203
[b87a5ed]14//
15
[6b0b624]16#pragma once
[51b7345]17
[fec3e9a]18#include <iosfwd>                                                                               // for ostream
19#include <list>                                                                                 // for list
20#include <string>                                                                               // for string
[d180746]21
[fec3e9a]22#include "ParseNode.h"                                                                  // for DeclarationNode, DeclarationNode::Ag...
23#include "SynTree/LinkageSpec.h"                                                // for Spec
24#include "SynTree/Type.h"                                                               // for Type, ReferenceToType (ptr only)
25#include "SynTree/SynTree.h"                                                    // for Visitor Nodes
[51b7345]26
[c8ffe20b]27struct TypeData {
[f7e4db27]28        enum Kind { Basic, Pointer, Reference, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic,
[66406f3]29                                SymbolicInst, Tuple, Basetypeof, Typeof, Vtable, Builtin, GlobalScope, Qualified, Unknown };
[b87a5ed]30
31        struct Aggregate_t {
[312029a]32                AggregateDecl::Aggregate kind;
[5509ff4]33                const std::string * name = nullptr;
34                DeclarationNode * params = nullptr;
[fec3e9a]35                ExpressionNode * actuals = nullptr;                             // holds actual parameters later applied to AggInst
[5509ff4]36                DeclarationNode * fields = nullptr;
[5d125e4]37                bool body;
[3d7e53b]38                bool anon;
[6ea87486]39
40                bool tagged;
[5509ff4]41                const std::string * parent = nullptr;
[b87a5ed]42        };
43
44        struct AggInst_t {
[5509ff4]45                TypeData * aggregate = nullptr;
46                ExpressionNode * params = nullptr;
[43c89a7]47                bool hoistType;
[b87a5ed]48        };
49
50        struct Array_t {
[5509ff4]51                ExpressionNode * dimension = nullptr;
[b87a5ed]52                bool isVarLen;
53                bool isStatic;
54        };
55
56        struct Enumeration_t {
[5509ff4]57                const std::string * name = nullptr;
58                DeclarationNode * constants = nullptr;
[ca1a547]59                bool body;
[3d7e53b]60                bool anon;
[b0d9ff7]61                bool typed;
[e4d7c1c]62                EnumHiding hiding;
[b87a5ed]63        };
64
65        struct Function_t {
[fec3e9a]66                mutable DeclarationNode * params = nullptr;             // mutables modified in buildKRFunction
67                mutable DeclarationNode * idList = nullptr;             // old-style
[5509ff4]68                mutable DeclarationNode * oldDeclList = nullptr;
69                StatementNode * body = nullptr;
[fec3e9a]70                ExpressionNode * withExprs = nullptr;                   // expressions from function's with_clause
[b87a5ed]71        };
72
73        struct Symbolic_t {
[5509ff4]74                const std::string * name = nullptr;
[721f17a]75                bool isTypedef;                                                                 // false => TYPEGENname, true => TYPEDEFname
[5509ff4]76                DeclarationNode * params = nullptr;
77                ExpressionNode * actuals = nullptr;
78                DeclarationNode * assertions = nullptr;
[b87a5ed]79        };
80
[f7e4db27]81        struct Qualified_t {                                                            // qualified type S.T
[5509ff4]82                TypeData * parent = nullptr;
83                TypeData * child = nullptr;
[c194661]84        };
85
[0b0f1dd]86        CodeLocation location;
87
[28307be]88        Kind kind;
[413ad05]89        TypeData * base;
[5b639ee]90        DeclarationNode::BasicType basictype = DeclarationNode::NoBasicType;
91        DeclarationNode::ComplexType complextype = DeclarationNode::NoComplexType;
92        DeclarationNode::Signedness signedness = DeclarationNode::NoSignedness;
93        DeclarationNode::Length length = DeclarationNode::NoLength;
[148f7290]94        DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType;
[c3396e0]95
[738e304]96        Type::Qualifiers qualifiers;
[5509ff4]97        DeclarationNode * forall = nullptr;
[413ad05]98
[c3396e0]99        Aggregate_t aggregate;
100        AggInst_t aggInst;
101        Array_t array;
102        Enumeration_t enumeration;
103        Function_t function;
104        Symbolic_t symbolic;
[c194661]105        Qualified_t qualified;
[5509ff4]106        DeclarationNode * tuple = nullptr;
107        ExpressionNode * typeexpr = nullptr;
[b87a5ed]108
[413ad05]109        TypeData( Kind k = Unknown );
110        ~TypeData();
111        void print( std::ostream &, int indent = 0 ) const;
112        TypeData * clone() const;
[7de22b28]113
114        const std::string * leafName() const;
[51b7345]115};
116
[413ad05]117Type * typebuild( const TypeData * );
118TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true );
119Type::Qualifiers buildQualifiers( const TypeData * td );
120Type * buildBasicType( const TypeData * );
121PointerType * buildPointer( const TypeData * );
122ArrayType * buildArray( const TypeData * );
[ce8c12f]123ReferenceType * buildReference( const TypeData * );
[c0aa336]124AggregateDecl * buildAggregate( const TypeData *, std::list< Attribute * > );
[fa4805f]125ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes, LinkageSpec::Spec linkage );
[413ad05]126ReferenceToType * buildAggInst( const TypeData * );
127TypeDecl * buildVariable( const TypeData * );
[bd46af4]128EnumDecl * buildEnum( const TypeData *, std::list< Attribute * >, LinkageSpec::Spec );
[413ad05]129TypeInstType * buildSymbolicInst( const TypeData * );
130TupleType * buildTuple( const TypeData * );
131TypeofType * buildTypeof( const TypeData * );
[93bbbc4]132VTableType * buildVtable( const TypeData * );
[8f91c9ae]133Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, Expression * asmName,
134                                                 Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() );
[413ad05]135FunctionType * buildFunction( const TypeData * );
[f135b50]136Declaration * addEnumBase( Declaration *, const TypeData * );
[3a5131ed]137void buildKRFunction( const TypeData::Function_t & function );
[413ad05]138
[b87a5ed]139// Local Variables: //
140// tab-width: 4 //
141// mode: c++ //
142// compile-command: "make install" //
143// End: //
Note: See TracBrowser for help on using the repository browser.