-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsli_arraytype.h
70 lines (58 loc) · 1.43 KB
/
sli_arraytype.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
#ifndef SLI_ARRAYTYPE_H
#define SLI_ARRAYTYPE_H
#include "sli_type.h"
#include "sli_token.h"
#include "sli_array.h"
#include <iostream>
#include <cassert>
namespace sli3
{
class ArrayType: public SLIType
{
public:
ArrayType(SLIInterpreter *sli, char const name[], sli_typeid type)
:SLIType(sli, name, type){}
refcount_t add_reference(Token const& t) const
{
return t.data_.array_val->add_reference();
}
void remove_reference(Token &t) const
{
if(t.data_.array_val->remove_reference() ==0)
{
t.type_=0;
t.data_=Token::value();
}
}
void clear(Token &t) const
{
remove_reference(t);
t.data_.array_val=0;
}
refcount_t references(Token const &t) const
{
if(t.data_.array_val!=0)
return t.data_.array_val->remove_reference();
else
return 0;
}
bool compare(const Token&t1, const Token&t2) const;
std::ostream & print(std::ostream&, const Token &) const;
};
class LitprocedureType: public ArrayType
{
public:
LitprocedureType(SLIInterpreter *sli, char const name[], sli_typeid type)
:ArrayType(sli, name, type){}
std::ostream & print(std::ostream&, const Token &) const;
void execute(Token &);
};
class ProcedureType: public LitprocedureType
{
public:
ProcedureType(SLIInterpreter *sli, char const name[], sli_typeid type)
:LitprocedureType(sli, name, type){}
void execute(Token &);
};
}
#endif