-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathast_type.h
executable file
·57 lines (42 loc) · 1.15 KB
/
ast_type.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* File: ast_type.h
* ----------------
* In our parse tree, Type nodes are used to represent and
* store type information. The base Type class is used
* for built-in types, the NamedType for classes and interfaces,
* and the ArrayType for arrays of other types.
*/
#ifndef _H_ast_type
#define _H_ast_type
#include "ast.h"
#include "list.h"
class Type : public Node
{
protected:
char *typeName;
public :
static Type *intType, *doubleType, *boolType, *voidType,
*nullType, *stringType, *errorType;
Type(yyltype loc) : Node(loc) {}
Type(const char *str);
const char *GetPrintNameForNode() { return "Type"; }
void PrintChildren(int indentLevel);
};
class NamedType : public Type
{
protected:
Identifier *id;
public:
NamedType(Identifier *i);
const char *GetPrintNameForNode() { return "NamedType"; }
void PrintChildren(int indentLevel);
};
class ArrayType : public Type
{
protected:
Type *elemType;
public:
ArrayType(yyltype loc, Type *elemType);
const char *GetPrintNameForNode() { return "ArrayType"; }
void PrintChildren(int indentLevel);
};
#endif