source: src/Parser/TypeData.h @ 9fa61f5

ADTast-experimental
Last change on this file since 9fa61f5 was 702e826, checked in by Andrew Beach <ajbeach@…>, 16 months ago

Pre-translation pass on the parser. Entirely code readability improvements, no behaviour (on a larger scale) should be effected.

  • Property mode set to 100644
File size: 4.8 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
[dc3c9b1]12// Last Modified On : Fri Feb 24 14:25:02 2023
13// Update Count     : 205
[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                bool tagged;
[5509ff4]40                const std::string * parent = nullptr;
[b87a5ed]41        };
42
[dc3c9b1]43        struct AggInst_t {                                                                      // handles SUE
[5509ff4]44                TypeData * aggregate = nullptr;
45                ExpressionNode * params = nullptr;
[43c89a7]46                bool hoistType;
[b87a5ed]47        };
48
49        struct Array_t {
[5509ff4]50                ExpressionNode * dimension = nullptr;
[b87a5ed]51                bool isVarLen;
52                bool isStatic;
53        };
54
55        struct Enumeration_t {
[5509ff4]56                const std::string * name = nullptr;
57                DeclarationNode * constants = nullptr;
[ca1a547]58                bool body;
[3d7e53b]59                bool anon;
[b0d9ff7]60                bool typed;
[e4d7c1c]61                EnumHiding hiding;
[b87a5ed]62        };
63
64        struct Function_t {
[fec3e9a]65                mutable DeclarationNode * params = nullptr;             // mutables modified in buildKRFunction
66                mutable DeclarationNode * idList = nullptr;             // old-style
[5509ff4]67                mutable DeclarationNode * oldDeclList = nullptr;
68                StatementNode * body = nullptr;
[fec3e9a]69                ExpressionNode * withExprs = nullptr;                   // expressions from function's with_clause
[b87a5ed]70        };
71
72        struct Symbolic_t {
[5509ff4]73                const std::string * name = nullptr;
[721f17a]74                bool isTypedef;                                                                 // false => TYPEGENname, true => TYPEDEFname
[5509ff4]75                DeclarationNode * params = nullptr;
76                ExpressionNode * actuals = nullptr;
77                DeclarationNode * assertions = nullptr;
[b87a5ed]78        };
79
[f7e4db27]80        struct Qualified_t {                                                            // qualified type S.T
[5509ff4]81                TypeData * parent = nullptr;
82                TypeData * child = nullptr;
[c194661]83        };
84
[0b0f1dd]85        CodeLocation location;
86
[28307be]87        Kind kind;
[413ad05]88        TypeData * base;
[5b639ee]89        DeclarationNode::BasicType basictype = DeclarationNode::NoBasicType;
90        DeclarationNode::ComplexType complextype = DeclarationNode::NoComplexType;
91        DeclarationNode::Signedness signedness = DeclarationNode::NoSignedness;
92        DeclarationNode::Length length = DeclarationNode::NoLength;
[148f7290]93        DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType;
[c3396e0]94
[738e304]95        Type::Qualifiers qualifiers;
[5509ff4]96        DeclarationNode * forall = nullptr;
[413ad05]97
[c3396e0]98        Aggregate_t aggregate;
99        AggInst_t aggInst;
100        Array_t array;
101        Enumeration_t enumeration;
102        Function_t function;
103        Symbolic_t symbolic;
[c194661]104        Qualified_t qualified;
[5509ff4]105        DeclarationNode * tuple = nullptr;
106        ExpressionNode * typeexpr = nullptr;
[b87a5ed]107
[413ad05]108        TypeData( Kind k = Unknown );
109        ~TypeData();
110        void print( std::ostream &, int indent = 0 ) const;
111        TypeData * clone() const;
[7de22b28]112
113        const std::string * leafName() const;
[51b7345]114};
115
[413ad05]116Type * typebuild( const TypeData * );
117TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true );
118Type::Qualifiers buildQualifiers( const TypeData * td );
119Type * buildBasicType( const TypeData * );
120PointerType * buildPointer( const TypeData * );
121ArrayType * buildArray( const TypeData * );
[ce8c12f]122ReferenceType * buildReference( const TypeData * );
[c0aa336]123AggregateDecl * buildAggregate( const TypeData *, std::list< Attribute * > );
[fa4805f]124ReferenceToType * buildComAggInst( const TypeData *, std::list< Attribute * > attributes, LinkageSpec::Spec linkage );
[413ad05]125ReferenceToType * buildAggInst( const TypeData * );
126TypeDecl * buildVariable( const TypeData * );
[bd46af4]127EnumDecl * buildEnum( const TypeData *, std::list< Attribute * >, LinkageSpec::Spec );
[413ad05]128TypeInstType * buildSymbolicInst( const TypeData * );
129TupleType * buildTuple( const TypeData * );
130TypeofType * buildTypeof( const TypeData * );
[93bbbc4]131VTableType * buildVtable( const TypeData * );
[702e826]132Declaration * buildDecl(
133        const TypeData *, const std::string &, Type::StorageClasses, Expression *,
134        Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, Expression * asmName,
135        Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() );
[413ad05]136FunctionType * buildFunction( const TypeData * );
[f135b50]137Declaration * addEnumBase( Declaration *, const TypeData * );
[3a5131ed]138void buildKRFunction( const TypeData::Function_t & function );
[413ad05]139
[b87a5ed]140// Local Variables: //
141// tab-width: 4 //
142// mode: c++ //
143// compile-command: "make install" //
144// End: //
Note: See TracBrowser for help on using the repository browser.