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