-
Notifications
You must be signed in to change notification settings - Fork 0
/
LispSymbol.cpp
49 lines (37 loc) · 924 Bytes
/
LispSymbol.cpp
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
#include <cassert>
#include <string>
#include <list>
#include <vector>
#include <ios>
#include <iostream>
#include <sstream>
#include "LispObj.h"
#include "LispNil.h"
#include "LispSymbol.h"
namespace Lisp {
LispObjRef make_symbol(const char* string)
{
std::string tempstr(string);
LispSymbol sym(tempstr, nil);
return boost::shared_ptr<LispObj>(new LispObj(SymbolType(sym)));
}
LispObjRef set_symbol_val(LispObjRef sym, LispObjRef rhs)
{
SymbolType& symref = boost::get<SymbolType>(*sym);
static_cast<LispSymbol>(symref).value = rhs;
return static_cast<LispSymbol>(symref).value;
}
LispObjRef get_symbol_value(LispObjRef sym)
{
assert(is_symbol(sym));
return get_ctype<SymbolType>(sym).value;
}
bool is_symbol(LispObjRef obj)
{
return (obj->which() == SYMBOL);
}
bool is_quote_symbol(LispObjRef obj)
{
return ((is_symbol(obj)) && (get_ctype<SymbolType>(obj).name == "QUOTE"));
}
} // namespace Lisp