From cc8d52479fea5b2f4419463daf027ec11e813dc8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 15 Oct 2009 16:55:19 +0000 Subject: Replace use of ATuple::at(0) with ATuple::head(). git-svn-id: http://svn.drobilla.net/resp/tuplr@227 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/constrain.cpp | 12 ++++++------ src/parse.cpp | 2 +- src/tuplr.hpp | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/constrain.cpp b/src/constrain.cpp index b4afe09..2fd3fa9 100644 --- a/src/constrain.cpp +++ b/src/constrain.cpp @@ -112,13 +112,13 @@ ACall::constrain(TEnv& tenv, Constraints& c) const for (size_t i = 0; i < size(); ++i) at(i)->constrain(tenv, c); - const AType* fnType = tenv.var(at(0)); + const AType* fnType = tenv.var(head()); if (fnType->kind != AType::VAR) { if (fnType->kind == AType::PRIM || fnType->size() < 2 - || !fnType->at(0)->to() - || fnType->at(0)->to()->cppstr != "Fn") - throw Error(loc, (format("call to non-function `%1%'") % at(0)->str()).str()); + || !fnType->head()->to() + || fnType->head()->to()->cppstr != "Fn") + throw Error(loc, (format("call to non-function `%1%'") % head()->str()).str()); size_t numArgs = fnType->at(1)->to()->size(); THROW_IF(numArgs != size() - 1, loc, @@ -130,7 +130,7 @@ ACall::constrain(TEnv& tenv, Constraints& c) const for (size_t i = 1; i < size(); ++i) argsT->push_back(tenv.var(at(i))); - c.constrain(tenv, at(0), tup(at(0)->loc, tenv.penv.sym("Fn"), argsT, retT, 0)); + c.constrain(tenv, head(), tup(head()->loc, tenv.penv.sym("Fn"), argsT, retT, 0)); c.constrain(tenv, this, retT); } @@ -169,7 +169,7 @@ AIf::constrain(TEnv& tenv, Constraints& c) const void APrimitive::constrain(TEnv& tenv, Constraints& c) const { - const string n = at(0)->to()->str(); + const string n = head()->to()->str(); enum { ARITHMETIC, BINARY, LOGICAL, COMPARISON } type; if (n == "+" || n == "-" || n == "*" || n == "/") type = ARITHMETIC; diff --git a/src/parse.cpp b/src/parse.cpp index ac232de..c7209aa 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -53,7 +53,7 @@ macDef(PEnv& penv, const AST* exp) for (; i != tup->end(); ++i) fnExp->push_back(*i); ATuple* ret = new ATuple(exp->loc); - ret->push_back(const_cast(tup->front())); + ret->push_back(const_cast(tup->head())); ret->push_back(const_cast(name)); ret->push_back(fnExp); return ret; diff --git a/src/tuplr.hpp b/src/tuplr.hpp index a89b612..02d79af 100644 --- a/src/tuplr.hpp +++ b/src/tuplr.hpp @@ -241,7 +241,7 @@ struct ATuple : public AST { newvec[_len++] = ast; _vec = newvec; } - const AST* front() const { assert(_len > 0); return _vec[0]; } + const AST* head() const { assert(_len > 0); return _vec[0]; } const AST* at(size_t i) const { assert(i < _len); return _vec[i]; } AST*& at(size_t i) { assert(i < _len); return _vec[i]; } size_t size() const { return _len; } @@ -483,15 +483,15 @@ struct PEnv : private map { const ATuple* tup = exp->to(); if (tup) { if (tup->empty()) throw Error(exp->loc, "call to empty list"); - if (!tup->front()->to()) { - MF mf = mac(*tup->front()->to()); + if (!tup->head()->to()) { + MF mf = mac(*tup->head()->to()); const AST* expanded = (mf ? mf(*this, exp) : exp); const ATuple* expanded_tup = expanded->to(); - const PEnv::Handler* h = handler(true, *expanded_tup->front()->to()); + const PEnv::Handler* h = handler(true, *expanded_tup->head()->to()); if (h) return h->func(*this, expanded, h->arg); } - ATuple* parsed_tup = parseTuple(tup); // FIXME: leak + ATuple* parsed_tup = parseTuple(tup); return new ACall(parsed_tup); // Parse as regular call } const AString* str = exp->to(); -- cgit v1.2.1