aboutsummaryrefslogtreecommitdiffstats
path: root/src/resp.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-04 23:12:06 +0000
committerDavid Robillard <d@drobilla.net>2010-12-04 23:12:06 +0000
commit1f488a7bd89d4cef07bd41ab22a290b0e230172d (patch)
treeb96a87f0b35167ffd3c62f6da3f7da872ee8d7f6 /src/resp.hpp
parent8ee352054cff3512c8e6dc3fd4738ee24ad267af (diff)
downloadresp-1f488a7bd89d4cef07bd41ab22a290b0e230172d.tar.gz
resp-1f488a7bd89d4cef07bd41ab22a290b0e230172d.tar.bz2
resp-1f488a7bd89d4cef07bd41ab22a290b0e230172d.zip
More const-correctness (remove all use of const_cast from lift.cpp).
git-svn-id: http://svn.drobilla.net/resp/resp@296 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src/resp.hpp')
-rw-r--r--src/resp.hpp20
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]));
}