diff options
Diffstat (limited to 'src/resp.hpp')
-rw-r--r-- | src/resp.hpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/resp.hpp b/src/resp.hpp index 2756f23..5da4214 100644 --- a/src/resp.hpp +++ b/src/resp.hpp @@ -307,11 +307,11 @@ private: struct ATuple : public AST { ATuple(Cursor c) : AST(T_TUPLE, c), _len(0), _vec(0) {} ATuple(const ATuple& exp) : AST(T_TUPLE, exp.loc), _len(exp._len) { - _vec = (AST**)malloc(sizeof(AST*) * _len); + _vec = (const AST**)malloc(sizeof(AST*) * _len); memcpy(_vec, exp._vec, sizeof(AST*) * _len); } - ATuple(AST* first, AST* rest, Cursor c=Cursor()) : AST(T_TUPLE, c), _len(2) { - _vec = (AST**)malloc(sizeof(AST*) * _len); + ATuple(const AST* first, const AST* rest, Cursor c=Cursor()) : AST(T_TUPLE, c), _len(2) { + _vec = (const AST**)malloc(sizeof(AST*) * _len); _vec[0] = first; _vec[1] = rest; } @@ -319,7 +319,7 @@ struct ATuple : public AST { if (!ast) return; _len = 2; - _vec = (AST**)malloc(sizeof(AST*) * _len); + _vec = (const AST**)malloc(sizeof(AST*) * _len); _vec[0] = ast; _vec[1] = NULL; @@ -332,9 +332,7 @@ struct ATuple : public AST { } const AST* head() const { assert(_len > 0); return _vec[0]; } - AST*& head() { assert(_len > 0); return _vec[0]; } const AST* last() const { return _vec[_len - 1]; } - AST*& last() { return _vec[_len - 1]; } bool empty() const { return _len == 0; } size_t tup_len() const { return _len; } @@ -410,8 +408,8 @@ struct ATuple : public AST { private: friend class GC; - size_t _len; - AST** _vec; + size_t _len; + const AST** _vec; }; static bool @@ -438,7 +436,7 @@ struct AType : public ATuple { AType(Cursor c, unsigned i) : ATuple(c), kind(VAR), id(i) { tag(T_TYPE); } AType(Cursor c, Kind k=EXPR) : ATuple(c), kind(k), id(0) { tag(T_TYPE); } AType(Cursor c, AST* ast, va_list args) : ATuple(c, ast, args), kind(EXPR), id(0) { tag(T_TYPE); } - AType(AST* first, AST* rest, Cursor c) : ATuple(first, rest, c), kind(EXPR), id(0) { tag(T_TYPE); } + AType(const AST* first, const AST* rest, Cursor c) : ATuple(first, rest, c), kind(EXPR), id(0) { tag(T_TYPE); } AType(const AType& copy) : ATuple(copy), kind(copy.kind), id(copy.id) { tag(T_TYPE); } bool concrete() const { @@ -495,7 +493,7 @@ struct List { CT* tail; }; -typedef List<AType, AType> TList; +typedef List<AType, const AType> TList; inline bool list_equals(const ATuple* lhs, const ATuple* rhs) @@ -815,7 +813,7 @@ struct CEnv { tenv.vars.insert(make_pair(ast, tvar)); tsubst.add(tvar, type); } - void setTypeSameAs(AST* ast, AST* typedAst) { + void setTypeSameAs(const AST* ast, const AST* typedAst) { tenv.vars.insert(make_pair(ast, tenv.vars[typedAst])); } |