source: src/Parser/TypeData.h@ d6c464d

ADT
Last change on this file since d6c464d was 561354f, checked in by JiadaL <j82liang@…>, 2 years ago

Save progress

  • Property mode set to 100644
File size: 5.1 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 : Andrew Beach
12// Last Modified On : Wed Mar 1 10:44:00 2023
13// Update Count : 206
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, Adt, Ctor, Unknown };
28
29 struct Aggregate_t {
30 ast::AggregateDecl::Aggregate kind;
31 const std::string * name = nullptr;
32 DeclarationNode * params = nullptr;
33 ExpressionNode * actuals = nullptr; // holds actual parameters later applied to AggInst
34 DeclarationNode * fields = nullptr;
35 bool body;
36 bool anon;
37 bool tagged;
38 const std::string * parent = nullptr;
39 };
40
41 struct AggInst_t {
42 TypeData * aggregate = nullptr;
43 ExpressionNode * params = nullptr;
44 bool hoistType;
45 };
46
47 struct Array_t {
48 ExpressionNode * dimension = nullptr;
49 bool isVarLen;
50 bool isStatic;
51 };
52
53 struct Enumeration_t {
54 const std::string * name = nullptr;
55 DeclarationNode * constants = nullptr;
56 bool body;
57 bool anon;
58 bool typed;
59 EnumHiding hiding;
60 bool isData = false;
61
62 DeclarationNode * data_constructors = nullptr;
63 };
64
65 struct ADT_t {
66 const std::string * name = nullptr;
67 DeclarationNode * data_constructors;
68 };
69
70 struct Function_t {
71 mutable DeclarationNode * params = nullptr; // mutables modified in buildKRFunction
72 mutable DeclarationNode * idList = nullptr; // old-style
73 mutable DeclarationNode * oldDeclList = nullptr;
74 StatementNode * body = nullptr;
75 ExpressionNode * withExprs = nullptr; // expressions from function's with_clause
76 };
77
78 struct Symbolic_t {
79 const std::string * name = nullptr;
80 bool isTypedef; // false => TYPEGENname, true => TYPEDEFname
81 DeclarationNode * params = nullptr;
82 ExpressionNode * actuals = nullptr;
83 DeclarationNode * assertions = nullptr;
84 };
85
86 struct Qualified_t { // qualified type S.T
87 TypeData * parent = nullptr;
88 TypeData * child = nullptr;
89 };
90
91 CodeLocation location;
92
93 Kind kind;
94 TypeData * base;
95 DeclarationNode::BasicType basictype = DeclarationNode::NoBasicType;
96 DeclarationNode::ComplexType complextype = DeclarationNode::NoComplexType;
97 DeclarationNode::Signedness signedness = DeclarationNode::NoSignedness;
98 DeclarationNode::Length length = DeclarationNode::NoLength;
99 DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType;
100
101 ast::CV::Qualifiers qualifiers;
102 DeclarationNode * forall = nullptr;
103
104 Aggregate_t aggregate;
105 AggInst_t aggInst;
106 Array_t array;
107 Enumeration_t enumeration;
108 ADT_t adt;
109
110 Function_t function;
111 Symbolic_t symbolic;
112 Qualified_t qualified;
113 DeclarationNode * tuple = nullptr;
114 ExpressionNode * typeexpr = nullptr;
115
116 TypeData( Kind k = Unknown );
117 ~TypeData();
118 void print( std::ostream &, int indent = 0 ) const;
119 TypeData * clone() const;
120
121 const std::string * leafName() const;
122};
123
124ast::Type * typebuild( const TypeData * );
125TypeData * typeextractAggregate( const TypeData * td, bool toplevel = true );
126ast::CV::Qualifiers buildQualifiers( const TypeData * td );
127ast::Type * buildBasicType( const TypeData * );
128ast::PointerType * buildPointer( const TypeData * );
129ast::ArrayType * buildArray( const TypeData * );
130ast::ReferenceType * buildReference( const TypeData * );
131ast::AggregateDecl * buildAggregate( const TypeData *, std::vector<ast::ptr<ast::Attribute>> );
132ast::BaseInstType * buildComAggInst( const TypeData *, std::vector<ast::ptr<ast::Attribute>> && attributes, ast::Linkage::Spec linkage );
133ast::BaseInstType * buildAggInst( const TypeData * );
134ast::TypeDecl * buildVariable( const TypeData * );
135ast::EnumDecl * buildEnum( const TypeData *, std::vector<ast::ptr<ast::Attribute>> &&, ast::Linkage::Spec );
136ast::EnumDecl * buildAst( const TypeData *, std::vector<ast::ptr<ast::Attribute>> &&, ast::Linkage::Spec );
137ast::TypeInstType * buildSymbolicInst( const TypeData * );
138ast::TupleType * buildTuple( const TypeData * );
139ast::TypeofType * buildTypeof( const TypeData * );
140ast::VTableType * buildVtable( const TypeData * );
141ast::Decl * buildDecl(
142 const TypeData *, const std::string &, ast::Storage::Classes, ast::Expr *,
143 ast::Function::Specs funcSpec, ast::Linkage::Spec, ast::Expr * asmName,
144 ast::Init * init = nullptr, std::vector<ast::ptr<ast::Attribute>> && attributes = std::vector<ast::ptr<ast::Attribute>>() );
145ast::FunctionType * buildFunctionType( const TypeData * );
146ast::Decl * addEnumBase( Declaration *, const TypeData * );
147void buildKRFunction( const TypeData::Function_t & function );
148
149// Local Variables: //
150// tab-width: 4 //
151// mode: c++ //
152// compile-command: "make install" //
153// End: //
Note: See TracBrowser for help on using the repository browser.