aboutsummaryrefslogtreecommitdiffstats
path: root/src/resp.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/resp.hpp')
-rw-r--r--src/resp.hpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/resp.hpp b/src/resp.hpp
index a7080fe..a972d48 100644
--- a/src/resp.hpp
+++ b/src/resp.hpp
@@ -57,7 +57,7 @@ struct Cursor {
unsigned col;
};
-/// Compiler error
+/// Compilation error
struct Error {
Error(Cursor c, const string& m) : loc(c), msg(m) {}
const string what() const { return (loc ? loc.str() + ": " : "") + "error: " + msg; }
@@ -152,17 +152,21 @@ private:
/// Garbage collected object (including AST and runtime data)
struct Object {
- enum Tag { OBJECT = 123, AST = 456 };
+ enum Tag { OBJECT = 1<<1, AST = 1<<2 };
struct Header {
- uint32_t mark;
- uint32_t tag;
+ uint32_t tag; ///< Rightmost bit is mark
};
- inline Tag tag() const { return (Tag)header()->tag; }
- inline void tag(Tag t) { header()->tag = t; }
- inline bool marked() const { return header()->mark != 0; }
- inline void mark(bool b) const { header()->mark = (b ? 1 : 0); }
+ inline Tag tag() const { return (Tag)((header()->tag >> 1) << 1); }
+ inline void tag(Tag t) { header()->tag = (t | (marked() ? 1 : 0)); }
+ inline bool marked() const { return (header()->tag & 1); }
+ inline void mark(bool b) const {
+ if (b)
+ header()->tag |= 1;
+ else
+ header()->tag = ((header()->tag >> 1) << 1);
+ }
static void* operator new(size_t size) { return pool.alloc(size); }
static void operator delete(void* ptr) {}
@@ -713,7 +717,7 @@ Engine* resp_new_c_engine();
/// Compile-Time Environment
struct CEnv {
CEnv(PEnv& p, TEnv& t, Engine* e, ostream& os=std::cout, ostream& es=std::cerr)
- : out(os), err(es), penv(p), tenv(t), _engine(e)
+ : out(os), err(es), penv(p), tenv(t), currentFn(NULL), _engine(e)
{}
~CEnv() { Object::pool.collect(GC::Roots()); }