aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-03 00:08:03 +0000
committerDavid Robillard <d@drobilla.net>2010-12-03 00:08:03 +0000
commit35e977e8786b667155bf6b186bebb9c0938fb587 (patch)
tree26f03047a669924bdd4cec884ebf1a1fce6a0bd4
parent58daa5a8568ee0cc780bad8575e61447be64c77d (diff)
downloadresp-35e977e8786b667155bf6b186bebb9c0938fb587.tar.gz
resp-35e977e8786b667155bf6b186bebb9c0938fb587.tar.bz2
resp-35e977e8786b667155bf6b186bebb9c0938fb587.zip
Move AFn and AType prot() methods to ATuple.
git-svn-id: http://svn.drobilla.net/resp/resp@283 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-rw-r--r--src/lift.cpp6
-rw-r--r--src/resp.hpp10
2 files changed, 7 insertions, 9 deletions
diff --git a/src/lift.cpp b/src/lift.cpp
index c24832f..739d176 100644
--- a/src/lift.cpp
+++ b/src/lift.cpp
@@ -68,7 +68,7 @@ lift_fn(CEnv& cenv, Code& code, AFn* fn) throw()
const AType* paramType = (*tp++)->as<const AType*>();
if (paramType->kind == AType::EXPR && *paramType->head() == *cenv.tenv.Fn) {
AType* fnType = new AType(*paramType);
- fnType->prot(new AType(const_cast<AType*>(cenv.tenv.var()), fnType->prot()->as<AType*>(), Cursor()));
+ fnType->set_prot(new AType(const_cast<AType*>(cenv.tenv.var()), fnType->prot()->as<AType*>(), Cursor()));
paramType = tup<const AType>((*p)->loc, cenv.tenv.Tup, fnType, NULL);
}
cenv.def((*p)->as<const ASymbol*>(), *p, paramType, NULL);
@@ -80,7 +80,7 @@ lift_fn(CEnv& cenv, Code& code, AFn* fn) throw()
* function after lifting the body (so recursive references correctly
* refer to this function by the closure parameter).
*/
- impl->prot(new ATuple(cenv.penv.sym("_"), impl->prot()));
+ impl->set_prot(new ATuple(cenv.penv.sym("_"), impl->prot()));
// Lift body
const AType* implRetT = NULL;
@@ -115,7 +115,7 @@ lift_fn(CEnv& cenv, Code& code, AFn* fn) throw()
}
cenv.liftStack.pop();
- implT->prot(new AType(tupT, implT->prot(), Cursor()));
+ implT->set_prot(new AType(tupT, implT->prot(), Cursor()));
implT->list_ref(2) = const_cast<AType*>(implRetT);
cenv.setType(impl, implT);
diff --git a/src/resp.hpp b/src/resp.hpp
index dd5987a..ff1bc19 100644
--- a/src/resp.hpp
+++ b/src/resp.hpp
@@ -418,6 +418,10 @@ struct ATuple : public AST {
}
void constrain(TEnv& tenv, Constraints& c) const throw(Error);
+ const ATuple* prot() const { return list_ref(1)->as<const ATuple*>(); }
+ ATuple* prot() { return list_ref(1)->as<ATuple*>(); }
+ void set_prot(ATuple* prot) { *iter_at(1) = prot; }
+
private:
size_t _len;
AST** _vec;
@@ -449,9 +453,6 @@ struct AType : public ATuple {
AType(Cursor c, AST* ast, va_list args) : ATuple(c, ast, args), kind(EXPR), id(0) {}
AType(AST* first, AST* rest, Cursor c) : ATuple(first, rest, c), kind(EXPR), id(0) {}
AType(const AType& copy) : ATuple(copy), kind(copy.kind), id(copy.id) {}
- const ATuple* prot() const { assert(kind == EXPR); return list_ref(1)->to<const ATuple*>(); }
- ATuple* prot() { assert(kind == EXPR); return list_ref(1)->to<ATuple*>(); }
- void prot(ATuple* prot) { assert(kind == EXPR); *iter_at(1) = prot; }
bool concrete() const {
switch (kind) {
@@ -530,9 +531,6 @@ struct AFn : public ATuple {
AFn(Cursor c, AST* ast, va_list args) : ATuple(c, ast, args) {}
bool operator==(const AST& rhs) const { return this == &rhs; }
void constrain(TEnv& tenv, Constraints& c) const throw(Error);
- const ATuple* prot() const { return list_ref(1)->to<const ATuple*>(); }
- ATuple* prot() { return list_ref(1)->to<ATuple*>(); }
- void prot(ATuple* prot) { *iter_at(1) = prot; }
string name;
};