-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacore.hpp
69 lines (59 loc) · 1.76 KB
/
acore.hpp
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
// acore.hpp - ALisp core header
//
// Included by most files for basic type information.
// Should not be included by itself in other programs.
#pragma once
#include <exception>
#include <memory>
#include <string>
#include <vector>
// Macros
// Because VC++ complains about ignoring throw(...) sections
#if _MSC_VER
#define THROW(x) throw(...)
#else
#define THROW(x) throw(x)
#endif
// Standard exceptions
class Exception : public std::exception {
public:
#if _MSC_VER
Exception(std::string message) : std::exception(message.c_str()) { }
#else
std::string msg;
Exception(std::string message) : msg(message) { }
#ifndef _GLIBCXX_TXN_SAFE_DYN
#define _GLIBCXX_TXN_SAFE_DYN
#endif
#ifndef _GLIBCXX_USE_NOEXCEPT
#define _GLIBCXX_USE_NOEXCEPT
#endif
const char *what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT { return msg.c_str(); }
#endif
};
#define EXCEPT THROW(Exception)
#ifdef _MSC_VER
#define NOMINMAX
#include <Windows.h>
#define debugger_attached() IsDebuggerPresent()
#else
#define debugger_attached() false
#endif
namespace ALisp {
struct Cell; // From cell.hpp
class Environment; // From environment.hpp
// Basic types
typedef size_t AtomType;
typedef std::string StringType;
typedef long IntegerType;
typedef double FloatType;
typedef std::vector<Cell> ListType;
typedef std::shared_ptr<Environment> EnvironmentType;
typedef std::weak_ptr<Environment> EnvironmentReference;
// Callable function types
typedef Cell(*ProcType)(const ListType &args);
typedef Cell(*ProcEnvType)(const ListType &args, EnvironmentType env);
// Always-present cells (see core.cpp)
extern Cell Nil, True, False;
extern AtomType _if, _quote, _define, _set, _lambda, _macro, _begin;
}