From 35e977e8786b667155bf6b186bebb9c0938fb587 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 3 Dec 2010 00:08:03 +0000 Subject: Move AFn and AType prot() methods to ATuple. git-svn-id: http://svn.drobilla.net/resp/resp@283 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/lift.cpp | 6 +++--- src/resp.hpp | 10 ++++------ 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(); if (paramType->kind == AType::EXPR && *paramType->head() == *cenv.tenv.Fn) { AType* fnType = new AType(*paramType); - fnType->prot(new AType(const_cast(cenv.tenv.var()), fnType->prot()->as(), Cursor())); + fnType->set_prot(new AType(const_cast(cenv.tenv.var()), fnType->prot()->as(), Cursor())); paramType = tup((*p)->loc, cenv.tenv.Tup, fnType, NULL); } cenv.def((*p)->as(), *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(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(); } + ATuple* prot() { return list_ref(1)->as(); } + 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(); } - ATuple* prot() { assert(kind == EXPR); return list_ref(1)->to(); } - 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(); } - ATuple* prot() { return list_ref(1)->to(); } - void prot(ATuple* prot) { *iter_at(1) = prot; } string name; }; -- cgit v1.2.1