diff options
author | David Robillard <d@drobilla.net> | 2009-03-07 05:49:13 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-03-07 05:49:13 +0000 |
commit | 835fa4439303938731517dc56f185f012896e6f4 (patch) | |
tree | c26c2e535a2d4a7ab8a3c6c8ae3222cc3486e012 | |
parent | 5faf51234f0279c057c58a6c26cf35f4266bedaf (diff) | |
download | resp-835fa4439303938731517dc56f185f012896e6f4.tar.gz resp-835fa4439303938731517dc56f185f012896e6f4.tar.bz2 resp-835fa4439303938731517dc56f185f012896e6f4.zip |
Shorter and more consistent names (AST -> A).
git-svn-id: http://svn.drobilla.net/resp/tuplr@78 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-rw-r--r-- | llvm.cpp | 60 | ||||
-rw-r--r-- | tuplr.cpp | 40 | ||||
-rw-r--r-- | tuplr.hpp | 92 | ||||
-rw-r--r-- | typing.cpp | 30 | ||||
-rw-r--r-- | write.cpp | 10 |
5 files changed, 116 insertions, 116 deletions
@@ -125,9 +125,9 @@ CEnv::write(std::ostream& os) #define LITERAL(CT, NAME, COMPILED) \ template<> CValue \ -ASTLiteral<CT>::compile(CEnv& cenv) { return (COMPILED); } \ +ALiteral<CT>::compile(CEnv& cenv) { return (COMPILED); } \ template<> void \ -ASTLiteral<CT>::constrain(TEnv& tenv) const { tenv.constrain(this, tenv.named(NAME)); } +ALiteral<CT>::constrain(TEnv& tenv) const { tenv.constrain(this, tenv.named(NAME)); } /// Literal template instantiations LITERAL(int32_t, "Int", ConstantInt::get(Type::Int32Ty, val, true)) @@ -135,7 +135,7 @@ LITERAL(float, "Float", ConstantFP::get(Type::FloatTy, val)) LITERAL(bool, "Bool", ConstantInt::get(Type::Int1Ty, val, false)) static Function* -compileFunction(CEnv& cenv, const std::string& name, const Type* retT, const ASTTuple& prot, +compileFunction(CEnv& cenv, const std::string& name, const Type* retT, const ATuple& prot, const vector<string> argNames=vector<string>()) { Function::LinkageTypes linkage = Function::ExternalLinkage; @@ -177,20 +177,20 @@ compileFunction(CEnv& cenv, const std::string& name, const Type* retT, const AST ***************************************************************************/ void -ASTSymbol::lift(CEnv& cenv) +ASymbol::lift(CEnv& cenv) { if (!cenv.code.ref(this)) throw Error((string("undefined symbol `") + cppstr + "'").c_str(), loc); } CValue -ASTSymbol::compile(CEnv& cenv) +ASymbol::compile(CEnv& cenv) { return cenv.compile(*cenv.code.ref(this)); } void -ASTClosure::lift(CEnv& cenv) +AClosure::lift(CEnv& cenv) { AType* type = cenv.tenv.type(this); if (!type->concrete() || funcs.find(type)) @@ -206,7 +206,7 @@ ASTClosure::lift(CEnv& cenv) vector<Value*> args; const_iterator p = prot()->begin(); for (Function::arg_iterator a = f->arg_begin(); a != f->arg_end(); ++a, ++p) - cenv.vals.def(dynamic_cast<ASTSymbol*>(*p), &*a); + cenv.vals.def(dynamic_cast<ASymbol*>(*p), &*a); // Write function body try { @@ -238,7 +238,7 @@ static AST* maybeLookup(CEnv& cenv, AST* ast) { - ASTSymbol* s = dynamic_cast<ASTSymbol*>(ast); + ASymbol* s = dynamic_cast<ASymbol*>(ast); if (s) { AST** val = cenv.code.ref(s); if (val) return *val; @@ -247,15 +247,15 @@ maybeLookup(CEnv& cenv, AST* ast) } CValue -ASTClosure::compile(CEnv& cenv) +AClosure::compile(CEnv& cenv) { return funcs.find(cenv.tenv.type(this)); } void -ASTCall::lift(CEnv& cenv) +ACall::lift(CEnv& cenv) { - ASTClosure* c = dynamic_cast<ASTClosure*>(maybeLookup(cenv, at(0))); + AClosure* c = dynamic_cast<AClosure*>(maybeLookup(cenv, at(0))); // Lift arguments for (size_t i = 1; i < size(); ++i) @@ -271,14 +271,14 @@ ASTCall::lift(CEnv& cenv) throw Error((format("too few arguments to function `%1%'") % at(0)->str()).str(), loc); for (size_t i = 1; i < size(); ++i) - cenv.code.def(checked_cast<ASTSymbol*>(c->prot()->at(i-1)), at(i)); + cenv.code.def(checked_cast<ASymbol*>(c->prot()->at(i-1)), at(i)); c->lift(cenv); // Lift called closure cenv.pop(); // Restore environment } CValue -ASTCall::compile(CEnv& cenv) +ACall::compile(CEnv& cenv) { AST* c = maybeLookup(cenv, at(0)); Function* f = dynamic_cast<Function*>(LLVal(cenv.compile(c))); @@ -292,22 +292,22 @@ ASTCall::compile(CEnv& cenv) } void -ASTDefinition::lift(CEnv& cenv) +ADefinition::lift(CEnv& cenv) { - if (cenv.code.ref(checked_cast<ASTSymbol*>(at(1)))) + if (cenv.code.ref(checked_cast<ASymbol*>(at(1)))) throw Error(string("`") + at(1)->str() + "' redefined", loc); - cenv.code.def((ASTSymbol*)at(1), at(2)); // Define first for recursion + cenv.code.def((ASymbol*)at(1), at(2)); // Define first for recursion at(2)->lift(cenv); } CValue -ASTDefinition::compile(CEnv& cenv) +ADefinition::compile(CEnv& cenv) { return cenv.compile(at(2)); } CValue -ASTIf::compile(CEnv& cenv) +AIf::compile(CEnv& cenv) { typedef vector< pair<Value*, BasicBlock*> > Branches; Function* parent = cenv.engine.builder.GetInsertBlock()->getParent(); @@ -351,12 +351,12 @@ ASTIf::compile(CEnv& cenv) } CValue -ASTPrimitive::compile(CEnv& cenv) +APrimitive::compile(CEnv& cenv) { Value* a = LLVal(cenv.compile(at(1))); Value* b = LLVal(cenv.compile(at(2))); bool isInt = cenv.tenv.type(at(1))->str() == "Int"; - const string n = dynamic_cast<ASTSymbol*>(at(0))->str(); + const string n = dynamic_cast<ASymbol*>(at(0))->str(); // Binary arithmetic operations Instruction::BinaryOps op = (Instruction::BinaryOps)0; @@ -394,24 +394,24 @@ ASTPrimitive::compile(CEnv& cenv) } AType* -ASTConsCall::functionType(CEnv& cenv) +AConsCall::functionType(CEnv& cenv) { - ASTTuple* protTypes = new ASTTuple(loc, cenv.tenv.type(at(1)), cenv.tenv.type(at(2)), 0); + ATuple* protTypes = new ATuple(loc, cenv.tenv.type(at(1)), cenv.tenv.type(at(2)), 0); AType* cellType = new AType(loc, cenv.penv.sym("Pair"), cenv.tenv.type(at(1)), cenv.tenv.type(at(2)), 0); return new AType(at(0)->loc, cenv.penv.sym("Fn"), protTypes, cellType, 0); } void -ASTConsCall::lift(CEnv& cenv) +AConsCall::lift(CEnv& cenv) { AType* funcType = functionType(cenv); if (funcs.find(functionType(cenv))) return; - ASTCall::lift(cenv); + ACall::lift(cenv); - ASTTuple* prot = new ASTTuple(loc, at(1), at(2), 0); + ATuple* prot = new ATuple(loc, at(1), at(2), 0); vector<const Type*> types; size_t sz = 0; @@ -451,7 +451,7 @@ ASTConsCall::lift(CEnv& cenv) } CValue -ASTConsCall::compile(CEnv& cenv) +AConsCall::compile(CEnv& cenv) { vector<Value*> params(size() - 1); for (size_t i = 1; i < size(); ++i) @@ -462,7 +462,7 @@ ASTConsCall::compile(CEnv& cenv) } CValue -ASTCarCall::compile(CEnv& cenv) +ACarCall::compile(CEnv& cenv) { AST* arg = maybeLookup(cenv, at(1)); Value* sP = LLVal(cenv.compile(arg)); @@ -472,7 +472,7 @@ ASTCarCall::compile(CEnv& cenv) } CValue -ASTCdrCall::compile(CEnv& cenv) +ACdrCall::compile(CEnv& cenv) { AST* arg = maybeLookup(cenv, at(1)); Value* sP = LLVal(cenv.compile(arg)); @@ -528,7 +528,7 @@ eval(CEnv& cenv, const string& name, istream& is) if (!ctype) throw Error("body has non-compilable type", cursor); // Create function for top-level of program - Function* f = compileFunction(cenv, "main", ctype, ASTTuple()); + Function* f = compileFunction(cenv, "main", ctype, ATuple()); // Compile all expressions into it Value* val = NULL; @@ -571,7 +571,7 @@ repl(CEnv& cenv) if (lltype(bodyT)) { // Create anonymous function to insert code into - Function* f = compileFunction(cenv, cenv.gensym("_repl"), lltype(bodyT), ASTTuple()); + Function* f = compileFunction(cenv, cenv.gensym("_repl"), lltype(bodyT), ATuple()); try { Value* retVal = LLVal(cenv.compile(body)); cenv.engine.builder.CreateRet(retVal); // Finish function @@ -26,7 +26,7 @@ using namespace std; using boost::format; -Funcs ASTConsCall::funcs; +Funcs AConsCall::funcs; /*************************************************************************** * Lexer * @@ -122,27 +122,27 @@ initLang(PEnv& penv, TEnv& tenv) // Special forms penv.reg(true, "fn", PEnv::Handler(parseFn)); - penv.reg(true, "if", PEnv::Handler(parseCall<ASTIf>)); - penv.reg(true, "def", PEnv::Handler(parseCall<ASTDefinition>)); - penv.reg(true, "cons", PEnv::Handler(parseCall<ASTConsCall>)); - penv.reg(true, "car", PEnv::Handler(parseCall<ASTCarCall>)); - penv.reg(true, "cdr", PEnv::Handler(parseCall<ASTCdrCall>)); + penv.reg(true, "if", PEnv::Handler(parseCall<AIf>)); + penv.reg(true, "def", PEnv::Handler(parseCall<ADefinition>)); + penv.reg(true, "cons", PEnv::Handler(parseCall<AConsCall>)); + penv.reg(true, "car", PEnv::Handler(parseCall<ACarCall>)); + penv.reg(true, "cdr", PEnv::Handler(parseCall<ACdrCall>)); // Numeric primitives - penv.reg(true, "+", PEnv::Handler(parseCall<ASTPrimitive>)); - penv.reg(true, "-", PEnv::Handler(parseCall<ASTPrimitive>)); - penv.reg(true, "*", PEnv::Handler(parseCall<ASTPrimitive>)); - penv.reg(true, "/", PEnv::Handler(parseCall<ASTPrimitive>)); - penv.reg(true, "%", PEnv::Handler(parseCall<ASTPrimitive>)); - penv.reg(true, "and", PEnv::Handler(parseCall<ASTPrimitive>)); - penv.reg(true, "or", PEnv::Handler(parseCall<ASTPrimitive>)); - penv.reg(true, "xor", PEnv::Handler(parseCall<ASTPrimitive>)); - penv.reg(true, "=", PEnv::Handler(parseCall<ASTPrimitive>)); - penv.reg(true, "!=", PEnv::Handler(parseCall<ASTPrimitive>)); - penv.reg(true, ">", PEnv::Handler(parseCall<ASTPrimitive>)); - penv.reg(true, ">=", PEnv::Handler(parseCall<ASTPrimitive>)); - penv.reg(true, "<", PEnv::Handler(parseCall<ASTPrimitive>)); - penv.reg(true, "<=", PEnv::Handler(parseCall<ASTPrimitive>)); + penv.reg(true, "+", PEnv::Handler(parseCall<APrimitive>)); + penv.reg(true, "-", PEnv::Handler(parseCall<APrimitive>)); + penv.reg(true, "*", PEnv::Handler(parseCall<APrimitive>)); + penv.reg(true, "/", PEnv::Handler(parseCall<APrimitive>)); + penv.reg(true, "%", PEnv::Handler(parseCall<APrimitive>)); + penv.reg(true, "and", PEnv::Handler(parseCall<APrimitive>)); + penv.reg(true, "or", PEnv::Handler(parseCall<APrimitive>)); + penv.reg(true, "xor", PEnv::Handler(parseCall<APrimitive>)); + penv.reg(true, "=", PEnv::Handler(parseCall<APrimitive>)); + penv.reg(true, "!=", PEnv::Handler(parseCall<APrimitive>)); + penv.reg(true, ">", PEnv::Handler(parseCall<APrimitive>)); + penv.reg(true, ">=", PEnv::Handler(parseCall<APrimitive>)); + penv.reg(true, "<", PEnv::Handler(parseCall<APrimitive>)); + penv.reg(true, "<=", PEnv::Handler(parseCall<APrimitive>)); } @@ -116,10 +116,10 @@ private: /// Literal value template<typename VT> -struct ASTLiteral : public AST { - ASTLiteral(VT v, Cursor c) : AST(c), val(v) {} +struct ALiteral : public AST { + ALiteral(VT v, Cursor c) : AST(c), val(v) {} bool operator==(const AST& rhs) const { - const ASTLiteral<VT>* r = dynamic_cast<const ASTLiteral<VT>*>(&rhs); + const ALiteral<VT>* r = dynamic_cast<const ALiteral<VT>*>(&rhs); return (r && (val == r->val)); } void constrain(TEnv& tenv) const; @@ -128,22 +128,22 @@ struct ASTLiteral : public AST { }; /// Symbol, e.g. "a" -struct ASTSymbol : public AST { +struct ASymbol : public AST { bool operator==(const AST& rhs) const { return this == &rhs; } void lift(CEnv& cenv); CValue compile(CEnv& cenv); private: friend class PEnv; - ASTSymbol(const string& s, Cursor c) : AST(c), cppstr(s) {} + ASymbol(const string& s, Cursor c) : AST(c), cppstr(s) {} friend ostream& operator<<(ostream&, const AST*); const string cppstr; }; /// Tuple (heterogeneous sequence of fixed length), e.g. "(a b c)" -struct ASTTuple : public AST, public vector<AST*> { - ASTTuple(const vector<AST*>& t=vector<AST*>(), Cursor c=Cursor()) : AST(c), vector<AST*>(t) {} - ASTTuple(size_t size, Cursor c) : AST(c), vector<AST*>(size) {} - ASTTuple(Cursor c, AST* ast, ...) : AST(c) { +struct ATuple : public AST, public vector<AST*> { + ATuple(const vector<AST*>& t=vector<AST*>(), Cursor c=Cursor()) : AST(c), vector<AST*>(t) {} + ATuple(size_t size, Cursor c) : AST(c), vector<AST*>(size) {} + ATuple(Cursor c, AST* ast, ...) : AST(c) { va_list args; va_start(args, ast); push_back(ast); for (AST* a = va_arg(args, AST*); a; a = va_arg(args, AST*)) @@ -151,7 +151,7 @@ struct ASTTuple : public AST, public vector<AST*> { va_end(args); } bool operator==(const AST& rhs) const { - const ASTTuple* rt = dynamic_cast<const ASTTuple*>(&rhs); + const ATuple* rt = dynamic_cast<const ATuple*>(&rhs); if (!rt || rt->size() != size()) return false; const_iterator l = begin(); FOREACH(const_iterator, r, *rt) @@ -175,11 +175,11 @@ struct ASTTuple : public AST, public vector<AST*> { }; /// Type Expression, e.g. "Int", "(Fn (Int Int) Float)" -struct AType : public ASTTuple { - AType(unsigned i, Cursor c=Cursor()) : ASTTuple(0, c), kind(VAR), id(i) {} - AType(ASTSymbol* s) : ASTTuple(0, s->loc), kind(PRIM), id(0) { push_back(s); } - AType(const ASTTuple& t, Cursor c) : ASTTuple(t, c), kind(EXPR), id(0) {} - AType(Cursor c, AST* ast, ...) : ASTTuple(0, c), kind(EXPR), id(0) { +struct AType : public ATuple { + AType(unsigned i, Cursor c=Cursor()) : ATuple(0, c), kind(VAR), id(i) {} + AType(ASymbol* s) : ATuple(0, s->loc), kind(PRIM), id(0) { push_back(s); } + AType(const ATuple& t, Cursor c) : ATuple(t, c), kind(EXPR), id(0) {} + AType(Cursor c, AST* ast, ...) : ATuple(0, c), kind(EXPR), id(0) { va_list args; va_start(args, ast); push_back(ast); for (AST* a = va_arg(args, AST*); a; a = va_arg(args, AST*)) @@ -210,7 +210,7 @@ struct AType : public ASTTuple { switch (kind) { case VAR: return id == rt->id; case PRIM: return at(0)->str() == rt->at(0)->str(); - case EXPR: return ASTTuple::operator==(rhs); + case EXPR: return ATuple::operator==(rhs); } return false; // never reached } @@ -229,52 +229,52 @@ struct Funcs : public list< pair<AType*, CFunction> > { }; /// Closure (first-class function with captured lexical bindings) -struct ASTClosure : public ASTTuple { - ASTClosure(Cursor c, ASTSymbol* fn, ASTTuple* p, AST* b, const string& n="") - : ASTTuple(c, fn, p, b, NULL), name(n) {} +struct AClosure : public ATuple { + AClosure(Cursor c, ASymbol* fn, ATuple* p, AST* b, const string& n="") + : ATuple(c, fn, p, b, NULL), name(n) {} bool operator==(const AST& rhs) const { return this == &rhs; } void constrain(TEnv& tenv) const; void lift(CEnv& cenv); CValue compile(CEnv& cenv); - ASTTuple* prot() const { return dynamic_cast<ASTTuple*>(at(1)); } + ATuple* prot() const { return dynamic_cast<ATuple*>(at(1)); } private: Funcs funcs; string name; }; /// Function call/application, e.g. "(func arg1 arg2)" -struct ASTCall : public ASTTuple { - ASTCall(const SExp& e, const ASTTuple& t) : ASTTuple(t, e.loc) {} +struct ACall : public ATuple { + ACall(const SExp& e, const ATuple& t) : ATuple(t, e.loc) {} void constrain(TEnv& tenv) const; void lift(CEnv& cenv); CValue compile(CEnv& cenv); }; /// Definition special form, e.g. "(def x 2)" -struct ASTDefinition : public ASTCall { - ASTDefinition(const SExp& e, const ASTTuple& t) : ASTCall(e, t) {} +struct ADefinition : public ACall { + ADefinition(const SExp& e, const ATuple& t) : ACall(e, t) {} void constrain(TEnv& tenv) const; void lift(CEnv& cenv); CValue compile(CEnv& cenv); }; /// Conditional special form, e.g. "(if cond thenexp elseexp)" -struct ASTIf : public ASTCall { - ASTIf(const SExp& e, const ASTTuple& t) : ASTCall(e, t) {} +struct AIf : public ACall { + AIf(const SExp& e, const ATuple& t) : ACall(e, t) {} void constrain(TEnv& tenv) const; CValue compile(CEnv& cenv); }; /// Primitive (builtin arithmetic function), e.g. "(+ 2 3)" -struct ASTPrimitive : public ASTCall { - ASTPrimitive(const SExp& e, const ASTTuple& t) : ASTCall(e, t) {} +struct APrimitive : public ACall { + APrimitive(const SExp& e, const ATuple& t) : ACall(e, t) {} void constrain(TEnv& tenv) const; CValue compile(CEnv& cenv); }; /// Cons special form, e.g. "(cons 1 2)" -struct ASTConsCall : public ASTCall { - ASTConsCall(const SExp& e, const ASTTuple& t) : ASTCall(e, t) {} +struct AConsCall : public ACall { + AConsCall(const SExp& e, const ATuple& t) : ACall(e, t) {} AType* functionType(CEnv& cenv); void constrain(TEnv& tenv) const; void lift(CEnv& cenv); @@ -283,15 +283,15 @@ struct ASTConsCall : public ASTCall { }; /// Car special form, e.g. "(car p)" -struct ASTCarCall : public ASTCall { - ASTCarCall(const SExp& e, const ASTTuple& t) : ASTCall(e, t) {} +struct ACarCall : public ACall { + ACarCall(const SExp& e, const ATuple& t) : ACall(e, t) {} void constrain(TEnv& tenv) const; CValue compile(CEnv& cenv); }; /// Cdr special form, e.g. "(cdr p)" -struct ASTCdrCall : public ASTCall { - ASTCdrCall(const SExp& e, const ASTTuple& t) : ASTCall(e, t) {} +struct ACdrCall : public ACall { + ACdrCall(const SExp& e, const ATuple& t) : ACall(e, t) {} void constrain(TEnv& tenv) const; CValue compile(CEnv& cenv); }; @@ -302,7 +302,7 @@ struct ASTCdrCall : public ASTCall { ***************************************************************************/ /// Parse Time Environment (symbol table) -struct PEnv : private map<const string, ASTSymbol*> { +struct PEnv : private map<const string, ASymbol*> { typedef AST* (*PF)(PEnv&, const SExp&, void*); // Parse Function struct Handler { Handler(PF f, void* a=0) : func(f), arg(a) {} PF func; void* arg; }; map<const string, Handler> aHandlers; ///< Atom parse functions @@ -315,22 +315,22 @@ struct PEnv : private map<const string, ASTSymbol*> { map<string, Handler>::const_iterator i = handlers.find(s); return (i != handlers.end()) ? &i->second : NULL; } - ASTSymbol* sym(const string& s, Cursor c=Cursor()) { + ASymbol* sym(const string& s, Cursor c=Cursor()) { const const_iterator i = find(s); return ((i != end()) ? i->second - : insert(make_pair(s, new ASTSymbol(s, c))).first->second); + : insert(make_pair(s, new ASymbol(s, c))).first->second); } }; /// The fundamental parser method static AST* parseExpression(PEnv& penv, const SExp& exp); -static ASTTuple +static ATuple pmap(PEnv& penv, const SExp& e) { assert(e.type == SExp::LIST); - ASTTuple ret(e.list.size(), e.loc); + ATuple ret(e.list.size(), e.loc); size_t n = 0; FOREACH(SExp::List::const_iterator, i, e.list) ret[n++] = parseExpression(penv, *i); @@ -347,12 +347,12 @@ parseExpression(PEnv& penv, const SExp& exp) if (handler) // Dispatch to list parse function return handler->func(penv, exp, handler->arg); } - return new ASTCall(exp, pmap(penv, exp)); // Parse as regular call + return new ACall(exp, pmap(penv, exp)); // Parse as regular call } else if (isdigit(exp.atom[0])) { if (exp.atom.find('.') == string::npos) - return new ASTLiteral<int32_t>(strtol(exp.atom.c_str(), NULL, 10), exp.loc); + return new ALiteral<int32_t>(strtol(exp.atom.c_str(), NULL, 10), exp.loc); else - return new ASTLiteral<float>(strtod(exp.atom.c_str(), NULL), exp.loc); + return new ALiteral<float>(strtod(exp.atom.c_str(), NULL), exp.loc); } else { const PEnv::Handler* handler = penv.handler(false, exp.atom); if (handler) // Dispatch to atom parse function @@ -372,15 +372,15 @@ template<typename T> inline AST* parseLiteral(PEnv& penv, const SExp& exp, void* arg) { - return new ASTLiteral<T>(*reinterpret_cast<T*>(arg), exp.loc); + return new ALiteral<T>(*reinterpret_cast<T*>(arg), exp.loc); } inline AST* parseFn(PEnv& penv, const SExp& exp, void* arg) { SExp::List::const_iterator a = exp.list.begin(); ++a; - return new ASTClosure(exp.loc, penv.sym("fn"), - new ASTTuple(pmap(penv, *a++)), + return new AClosure(exp.loc, penv.sym("fn"), + new ATuple(pmap(penv, *a++)), parseExpression(penv, *a++)); } @@ -460,7 +460,7 @@ struct CEnv { CEnv(PEnv& p, TEnv& t, CEngine& e, ostream& os=std::cout, ostream& es=std::cerr); ~CEnv(); - typedef Env<const ASTSymbol*, AST*> Code; + typedef Env<const ASymbol*, AST*> Code; typedef Env<const AST*, CValue> Vals; string gensym(const char* s="_") { return (format("%s%d") % s % symID++).str(); } @@ -22,9 +22,9 @@ ***************************************************************************/ void -ASTTuple::constrain(TEnv& tenv) const +ATuple::constrain(TEnv& tenv) const { - AType* t = new AType(ASTTuple(), loc); + AType* t = new AType(ATuple(), loc); FOREACH(const_iterator, p, *this) { (*p)->constrain(tenv); t->push_back(tenv.type(*p)); @@ -33,7 +33,7 @@ ASTTuple::constrain(TEnv& tenv) const } void -ASTClosure::constrain(TEnv& tenv) const +AClosure::constrain(TEnv& tenv) const { at(1)->constrain(tenv); at(2)->constrain(tenv); @@ -43,22 +43,22 @@ ASTClosure::constrain(TEnv& tenv) const } void -ASTCall::constrain(TEnv& tenv) const +ACall::constrain(TEnv& tenv) const { FOREACH(const_iterator, p, *this) (*p)->constrain(tenv); AType* retT = tenv.type(this); - AType* argsT = new AType(ASTTuple(), loc); + AType* argsT = new AType(ATuple(), loc); for (size_t i = 1; i < size(); ++i) argsT->push_back(tenv.type(at(i))); tenv.constrain(at(0), new AType(at(0)->loc, tenv.penv.sym("Fn"), argsT, retT, 0)); } void -ASTDefinition::constrain(TEnv& tenv) const +ADefinition::constrain(TEnv& tenv) const { if (size() != 3) throw Error("`def' requires exactly 2 arguments", loc); - if (!dynamic_cast<const ASTSymbol*>(at(1))) + if (!dynamic_cast<const ASymbol*>(at(1))) throw Error("`def' name is not a symbol", loc); FOREACH(const_iterator, p, *this) (*p)->constrain(tenv); @@ -68,7 +68,7 @@ ASTDefinition::constrain(TEnv& tenv) const } void -ASTIf::constrain(TEnv& tenv) const +AIf::constrain(TEnv& tenv) const { if (size() < 3) throw Error("`if' requires exactly 3 arguments", loc); if (size() % 2 != 0) throw Error("`if' missing final else clause", loc); @@ -86,9 +86,9 @@ ASTIf::constrain(TEnv& tenv) const } void -ASTPrimitive::constrain(TEnv& tenv) const +APrimitive::constrain(TEnv& tenv) const { - const string n = dynamic_cast<ASTSymbol*>(at(0))->str(); + const string n = dynamic_cast<ASymbol*>(at(0))->str(); enum { ARITHMETIC, BINARY, BITWISE, COMPARISON } type; if (n == "+" || n == "-" || n == "*" || n == "/") type = ARITHMETIC; @@ -136,7 +136,7 @@ ASTPrimitive::constrain(TEnv& tenv) const } void -ASTConsCall::constrain(TEnv& tenv) const +AConsCall::constrain(TEnv& tenv) const { if (size() != 3) throw Error("`cons' requires exactly 2 arguments", loc); AType* t = new AType(loc, tenv.penv.sym("Pair"), 0); @@ -148,7 +148,7 @@ ASTConsCall::constrain(TEnv& tenv) const } void -ASTCarCall::constrain(TEnv& tenv) const +ACarCall::constrain(TEnv& tenv) const { if (size() != 2) throw Error("`car' requires exactly 1 argument", loc); at(1)->constrain(tenv); @@ -159,7 +159,7 @@ ASTCarCall::constrain(TEnv& tenv) const } void -ASTCdrCall::constrain(TEnv& tenv) const +ACdrCall::constrain(TEnv& tenv) const { if (size() != 2) throw Error("`cdr' requires exactly 1 argument", loc); at(1)->constrain(tenv); @@ -175,14 +175,14 @@ ASTCdrCall::constrain(TEnv& tenv) const ***************************************************************************/ static void -substitute(ASTTuple* tup, AST* from, AST* to) +substitute(ATuple* tup, AST* from, AST* to) { if (!tup) return; for (size_t i = 0; i < tup->size(); ++i) if (*tup->at(i) == *from) tup->at(i) = to; else - substitute(dynamic_cast<ASTTuple*>(tup->at(i)), from, to); + substitute(dynamic_cast<ATuple*>(tup->at(i)), from, to); } TSubst @@ -20,19 +20,19 @@ ostream& operator<<(ostream& out, const AST* ast) { - const ASTLiteral<float>* flit = dynamic_cast<const ASTLiteral<float>*>(ast); + const ALiteral<float>* flit = dynamic_cast<const ALiteral<float>*>(ast); if (flit) return out << showpoint << flit->val; - const ASTLiteral<int32_t>* ilit = dynamic_cast<const ASTLiteral<int32_t>*>(ast); + const ALiteral<int32_t>* ilit = dynamic_cast<const ALiteral<int32_t>*>(ast); if (ilit) return out << ilit->val; - const ASTLiteral<bool>* blit = dynamic_cast<const ASTLiteral<bool>*>(ast); + const ALiteral<bool>* blit = dynamic_cast<const ALiteral<bool>*>(ast); if (blit) return out << (blit->val ? "#t" : "#f"); - const ASTSymbol* sym = dynamic_cast<const ASTSymbol*>(ast); + const ASymbol* sym = dynamic_cast<const ASymbol*>(ast); if (sym) return out << sym->cppstr; @@ -45,7 +45,7 @@ operator<<(ostream& out, const AST* ast) } } - const ASTTuple* tup = dynamic_cast<const ASTTuple*>(ast); + const ATuple* tup = dynamic_cast<const ATuple*>(ast); if (tup) { out << "("; for (size_t i = 0; i != tup->size(); ++i) |