diff options
author | David Robillard <d@drobilla.net> | 2009-06-20 18:42:10 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-06-20 18:42:10 +0000 |
commit | 5423a36aee3156332183bc59c097a907e4d8c503 (patch) | |
tree | 78fbd2e405b19154ef7119969f2753205a6995c1 | |
parent | a34fdc61633467976971f4bd88c7c32d353fa8d0 (diff) | |
download | resp-5423a36aee3156332183bc59c097a907e4d8c503.tar.gz resp-5423a36aee3156332183bc59c097a907e4d8c503.tar.bz2 resp-5423a36aee3156332183bc59c097a907e4d8c503.zip |
Shorten AST names to match code names.
git-svn-id: http://svn.drobilla.net/resp/tuplr@136 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-rw-r--r-- | llvm.cpp | 18 | ||||
-rw-r--r-- | tuplr.cpp | 10 | ||||
-rw-r--r-- | tuplr.hpp | 12 | ||||
-rw-r--r-- | typing.cpp | 10 |
4 files changed, 25 insertions, 25 deletions
@@ -193,7 +193,7 @@ ASymbol::compile(CEnv& cenv) } void -AClosure::lift(CEnv& cenv) +AFn::lift(CEnv& cenv) { cenv.push(); for (const_iterator p = prot()->begin(); p != prot()->end(); ++p) @@ -214,7 +214,7 @@ AClosure::lift(CEnv& cenv) } void -AClosure::liftCall(CEnv& cenv, const AType& argsT) +AFn::liftCall(CEnv& cenv, const AType& argsT) { TEnv::GenericTypes::const_iterator gt = cenv.tenv.genericTypes.find(this); assert(gt != cenv.tenv.genericTypes.end()); @@ -284,7 +284,7 @@ AClosure::liftCall(CEnv& cenv, const AType& argsT) // Scan out definitions for (size_t i = 0; i < size(); ++i) { - ADefinition* def = at(i)->to<ADefinition*>(); + ADef* def = at(i)->to<ADef*>(); if (def) { const Type* lt = llType(cenv.type(def->at(2))); THROW_IF(!lt, loc, "untyped definition\n"); @@ -327,7 +327,7 @@ AClosure::liftCall(CEnv& cenv, const AType& argsT) } CValue -AClosure::compile(CEnv& cenv) +AFn::compile(CEnv& cenv) { return NULL; } @@ -335,7 +335,7 @@ AClosure::compile(CEnv& cenv) void ACall::lift(CEnv& cenv) { - AClosure* c = cenv.tenv.resolve(at(0))->to<AClosure*>(); + AFn* c = cenv.tenv.resolve(at(0))->to<AFn*>(); AType argsT(loc, NULL); // Lift arguments @@ -357,7 +357,7 @@ ACall::lift(CEnv& cenv) CValue ACall::compile(CEnv& cenv) { - AClosure* c = cenv.tenv.resolve(at(0))->to<AClosure*>(); + AFn* c = cenv.tenv.resolve(at(0))->to<AFn*>(); if (!c) return NULL; // Primitive @@ -382,18 +382,18 @@ ACall::compile(CEnv& cenv) } void -ADefinition::lift(CEnv& cenv) +ADef::lift(CEnv& cenv) { // Define stub first for recursion cenv.def(sym(), at(2), cenv.type(at(2)), NULL); - AClosure* c = at(2)->to<AClosure*>(); + AFn* c = at(2)->to<AFn*>(); if (c) c->name = sym()->str(); at(2)->lift(cenv); } CValue -ADefinition::compile(CEnv& cenv) +ADef::compile(CEnv& cenv) { // Define stub first for recursion cenv.def(sym(), at(2), cenv.type(at(2)), NULL); @@ -175,7 +175,7 @@ parseFn(PEnv& penv, const SExp& exp, void* arg) else if (exp.size() < 3) throw Error(exp.loc, "Missing function body"); SExp::const_iterator a = exp.begin(); ++a; - AClosure* ret = new AClosure(exp.loc, penv.sym("fn"), new ATuple(penv.parseTuple(*a++))); + AFn* ret = new AFn(exp.loc, penv.sym("fn"), new ATuple(penv.parseTuple(*a++))); while (a != exp.end()) ret->push_back(penv.parse(*a++)); return ret; @@ -206,7 +206,7 @@ initLang(PEnv& penv, TEnv& tenv) // Special forms penv.reg(true, "fn", PEnv::Handler(parseFn)); penv.reg(true, "if", PEnv::Handler(parseCall<AIf>)); - penv.reg(true, "def", PEnv::Handler(parseCall<ADefinition>)); + penv.reg(true, "def", PEnv::Handler(parseCall<ADef>)); // Numeric primitives penv.reg(true, "+", PEnv::Handler(parseCall<APrimitive>)); @@ -252,7 +252,7 @@ eval(CEnv& cenv, const string& name, istream& is) exprs.push_back(make_pair(exp, result)); // Add definitions as GC roots - if (result->to<ADefinition*>()) + if (result->to<ADef*>()) cenv.lock(result); // Add types in type substition as GC roots @@ -319,7 +319,7 @@ repl(CEnv& cenv) finishFunction(cenv, f, retVal); cenv.out << call(cenv, f, bodyT); } catch (Error& e) { - ADefinition* def = body->to<ADefinition*>(); + ADef* def = body->to<ADef*>(); if (def) cenv.out << def->sym(); else @@ -329,7 +329,7 @@ repl(CEnv& cenv) cenv.out << " : " << cenv.type(body) << endl; // Add definitions as GC roots - if (body->to<ADefinition*>()) + if (body->to<ADef*>()) cenv.lock(body); Object::pool.collect(Object::pool.roots()); @@ -366,8 +366,8 @@ struct Funcs : public list< pair<AType*, CFunction> > { }; /// Closure (first-class function with captured lexical bindings) -struct AClosure : public ATuple { - AClosure(Cursor c, ASymbol* fn, ATuple* p, const string& n="") +struct AFn : public ATuple { + AFn(Cursor c, ASymbol* fn, ATuple* p, const string& n="") : ATuple(c, fn, p, NULL), name(n) {} bool operator==(const AST& rhs) const { return this == &rhs; } void constrain(TEnv& tenv, Constraints& c) const; @@ -389,8 +389,8 @@ struct ACall : public ATuple { }; /// Definition special form, e.g. "(def x 2)" -struct ADefinition : public ACall { - ADefinition(const SExp& e, const ATuple& t) : ACall(e, t) {} +struct ADef : public ACall { + ADef(const SExp& e, const ATuple& t) : ACall(e, t) {} ASymbol* sym() const { ASymbol* sym = at(1)->to<ASymbol*>(); if (!sym) { @@ -543,8 +543,8 @@ struct TEnv : public Env< const ASymbol*, pair<AST*, AType*> > { } static Subst unify(const Constraints& c); - typedef map<const AST*, AType*> Vars; - typedef map<const AClosure*, const AType*> GenericTypes; + typedef map<const AST*, AType*> Vars; + typedef map<const AFn*, const AType*> GenericTypes; Vars vars; GenericTypes genericTypes; PEnv& penv; @@ -50,7 +50,7 @@ ATuple::constrain(TEnv& tenv, Constraints& c) const } void -AClosure::constrain(TEnv& tenv, Constraints& c) const +AFn::constrain(TEnv& tenv, Constraints& c) const { const AType* genericType; TEnv::GenericTypes::const_iterator gt = tenv.genericTypes.find(this); @@ -75,7 +75,7 @@ AClosure::constrain(TEnv& tenv, Constraints& c) const size_t e = 2; for (; e < size(); ++e) { AST* exp = at(e); - ADefinition* def = exp->to<ADefinition*>(); + ADef* def = exp->to<ADef*>(); if (def) { ASymbol* sym = def->sym(); if (defined.find(sym) != defined.end()) @@ -124,8 +124,8 @@ ACall::constrain(TEnv& tenv, Constraints& c) const for (size_t i = 1; i < size(); ++i) at(i)->constrain(tenv, c); - AST* callee = tenv.resolve(at(0)); - AClosure* closure = callee->to<AClosure*>(); + AST* callee = tenv.resolve(at(0)); + AFn* closure = callee->to<AFn*>(); if (closure) { if (size() - 1 != closure->prot()->size()) throw Error(loc, "incorrect number of arguments"); @@ -148,7 +148,7 @@ ACall::constrain(TEnv& tenv, Constraints& c) const } void -ADefinition::constrain(TEnv& tenv, Constraints& c) const +ADef::constrain(TEnv& tenv, Constraints& c) const { THROW_IF(size() != 3, loc, "`def' requires exactly 2 arguments"); const ASymbol* sym = this->sym(); |