aboutsummaryrefslogtreecommitdiffstats
path: root/tuplr.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'tuplr.hpp')
-rw-r--r--tuplr.hpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/tuplr.hpp b/tuplr.hpp
index 130307e..506742a 100644
--- a/tuplr.hpp
+++ b/tuplr.hpp
@@ -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) {