source: src/Parser/TypeData.h@ 56b47b9

Last change on this file since 56b47b9 was af60383, checked in by Andrew Beach <ajbeach@…>, 19 months ago

Moved a field and functions from DeclarationNode to TypeData. Trying to make the line between them cleaner.

  • Property mode set to 100644
File size: 5.2 KB
Line 
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//
7// TypeData.h --
8//
9// Author : Peter A. Buhr
10// Created On : Sat May 16 15:18:36 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Thu Feb 22 16:30:31 2024
13// Update Count : 210
14//
15
16#pragma once
17
18#include <iosfwd> // for ostream
19#include <list> // for list
20#include <string> // for string
21
22#include "AST/Type.hpp" // for Type
23#include "DeclarationNode.h" // for DeclarationNode
24
25struct TypeData {
26 enum Kind { Basic, Pointer, Reference, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic,
27 SymbolicInst, Tuple, Basetypeof, Typeof, Vtable, Builtin, GlobalScope, Qualified, Unknown };
28
29 struct Aggregate_t {
30 ast::AggregateDecl::Aggregate kind;
31 const std::string * name = nullptr;
32 const std::string * parent = nullptr;
33 DeclarationNode * params = nullptr;
34 ExpressionNode * actuals = nullptr; // holds actual parameters later applied to AggInst
35 DeclarationNode * fields = nullptr;
36 std::vector<ast::ptr<ast::Attribute>> attributes;
37 bool body;
38 bool anon;
39 bool tagged;
40 };
41
42 struct AggInst_t {
43 TypeData * aggregate = nullptr;
44 ExpressionNode * params = nullptr;
45 bool hoistType;
46 };
47
48 struct Array_t {
49 ExpressionNode * dimension = nullptr;
50 bool isVarLen;
51 bool isStatic;
52 };
53
54 struct Enumeration_t {
55 const std::string * name = nullptr;
56 DeclarationNode * constants = nullptr;
57 bool body;
58 bool anon;
59 bool typed;
60 EnumHiding hiding;
61 };
62
63 struct Function_t {
64 mutable DeclarationNode * params = nullptr; // mutables modified in buildKRFunction
65 mutable DeclarationNode * idList = nullptr; // old-style
66 mutable DeclarationNode * oldDeclList = nullptr;
67 StatementNode * body = nullptr;
68 ExpressionNode * withExprs = nullptr; // expressions from function's with_clause
69 };
70
71 struct Symbolic_t {
72 const std::string * name = nullptr;
73 bool isTypedef; // false => TYPEGENname, true => TYPEDEFname
74 DeclarationNode * params = nullptr;
75 ExpressionNode * actuals = nullptr;
76 DeclarationNode * assertions = nullptr;
77 };
78
79 struct Qualified_t { // qualified type S.T
80 TypeData * parent = nullptr;
81 TypeData * child = nullptr;
82 };
83
84 CodeLocation location;
85
86 Kind kind;
87 TypeData * base;
88 DeclarationNode::BasicType basictype = DeclarationNode::NoBasicType;
89 DeclarationNode::ComplexType complextype = DeclarationNode::NoComplexType;
90 DeclarationNode::Signedness signedness = DeclarationNode::NoSignedness;
91 DeclarationNode::Length length = DeclarationNode::NoLength;
92 DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType;
93
94 ast::CV::Qualifiers qualifiers;
95 DeclarationNode * forall = nullptr;
96
97 Aggregate_t aggregate;
98 AggInst_t aggInst;
99 Array_t array;
100 Enumeration_t enumeration;
101 Function_t function;
102 Symbolic_t symbolic;
103 Qualified_t qualified;
104 DeclarationNode * tuple = nullptr;
105 ExpressionNode * typeexpr = nullptr;
106
107 TypeData( Kind k = Unknown );
108 ~TypeData();
109 void print( std::ostream &, int indent = 0 ) const;
110 TypeData * clone() const;
111
112 const std::string * leafName() const;
113
114 TypeData * getLastBase();
115 void setLastBase( TypeData * );
116};
117
118TypeData * addQualifiers( TypeData * ltype, TypeData * rtype );
119TypeData * addType( TypeData * ltype, TypeData * rtype, std::vector<ast::ptr<ast::Attribute>> & );
120TypeData * cloneBaseType( TypeData * type, TypeData * other );
121TypeData * makeNewBase( TypeData * type );
122
123ast::Type * typebuild( const TypeData * );
124TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true );
125ast::CV::Qualifiers buildQualifiers( const TypeData * td );
126ast::Type * buildBasicType( const TypeData * );
127ast::PointerType * buildPointer( const TypeData * );
128ast::ArrayType * buildArray( const TypeData * );
129ast::ReferenceType * buildReference( const TypeData * );
130ast::AggregateDecl * buildAggregate( const TypeData *, std::vector<ast::ptr<ast::Attribute>> );
131ast::BaseInstType * buildComAggInst( const TypeData *, std::vector<ast::ptr<ast::Attribute>> && attributes, ast::Linkage::Spec linkage );
132ast::BaseInstType * buildAggInst( const TypeData * );
133ast::TypeDecl * buildVariable( const TypeData * );
134ast::EnumDecl * buildEnum( const TypeData *, std::vector<ast::ptr<ast::Attribute>> &&, ast::Linkage::Spec );
135ast::TypeInstType * buildSymbolicInst( const TypeData * );
136ast::TupleType * buildTuple( const TypeData * );
137ast::TypeofType * buildTypeof( const TypeData * );
138ast::VTableType * buildVtable( const TypeData * );
139ast::Decl * buildDecl(
140 const TypeData *, const std::string &, ast::Storage::Classes, ast::Expr *,
141 ast::Function::Specs funcSpec, ast::Linkage::Spec, ast::Expr * asmName,
142 ast::Init * init = nullptr, std::vector<ast::ptr<ast::Attribute>> && attributes = std::vector<ast::ptr<ast::Attribute>>() );
143ast::FunctionType * buildFunctionType( const TypeData * );
144void buildKRFunction( const TypeData::Function_t & function );
145
146// Local Variables: //
147// tab-width: 4 //
148// mode: c++ //
149// compile-command: "make install" //
150// End: //
Note: See TracBrowser for help on using the repository browser.