-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype.h
81 lines (69 loc) · 1.28 KB
/
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#pragma once
#include "globals.h"
#include "operations.h"
class type;
class property
{
public:
string name;
type* dtype;
property(string n, type* dt)
: name(n)
, dtype(dt)
{ }
void debugProperty();
};
class method
{
public:
string name;
operation* code;
type* rtype;
vector<type*> ptypes;
method(string n, type* r, vector<type*> p)
: name(n)
, code(new op_start())
, rtype(r)
, ptypes(p)
{ }
void debugMethod();
};
class type
{
public:
string name;
type* superclass;
bool ptrtype; // if it is an object reference, i.e. can have methods assoc with it
bool arraytype;
int size; // in bytes
vector<property*> props;
vector<method*> methods;
type(string nm, type* sc, bool pt, bool ar, int sz)
: name(nm)
, superclass(sc)
, ptrtype(pt)
, arraytype(ar)
, size(sz)
{ }
void addMethod(method* m)
{ methods.push_back(m); }
void addProperty(property* p)
{ props.push_back(p); }
void numberCode();
void debugCode();
void debugType();
method* getMethodByName(string name);
property* getPropertyByName(string name);
};
class typelibrary
{
public:
vector<type*> types;
typelibrary();
void addType(type* t);
type* getTypeByName(string tname);
void numberCode();
void debugCode();
void debugTypes();
type* getOrCreateType(string tname);
};