diff options
Diffstat (limited to 'tuplr.hpp')
-rw-r--r-- | tuplr.hpp | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -153,6 +153,11 @@ struct AST { virtual void constrain(TEnv& tenv, Constraints& c) const {} virtual void lift(CEnv& cenv) {} string str() const { ostringstream ss; ss << this; return ss.str(); } + template<typename T> T as() { + T t = dynamic_cast<T>(this); + if (!t) throw Error("internal error: bad cast", loc); + return t; + } Cursor loc; private: friend class CEnv; @@ -448,7 +453,7 @@ struct Subst : public map<const AType*,AType*> { }; /// Type-Time Environment -struct TEnv : public Env<const AST*,AType*> { +struct TEnv : public Env<const ASymbol*,AType*> { TEnv(PEnv& p) : penv(p), varID(1) {} AType* fresh(const ASymbol* sym) { |