aboutsummaryrefslogtreecommitdiffstats
path: root/src/resp.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/resp.hpp')
-rw-r--r--src/resp.hpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/resp.hpp b/src/resp.hpp
index 3cccd30..7c88be4 100644
--- a/src/resp.hpp
+++ b/src/resp.hpp
@@ -647,6 +647,8 @@ struct TEnv : public Env<const ASymbol*, const AType*> {
TEnv(PEnv& p)
: penv(p)
, varID(1)
+ , Closure(new AType(penv.sym("Closure"), AType::NAME))
+ , Dots(new AType(Cursor(), AType::DOTS))
, Fn(new AType(penv.sym("Fn"), AType::PRIM))
, Tup(new AType(penv.sym("Tup"), AType::NAME))
, U(new AType(penv.sym("U"), AType::PRIM))
@@ -678,6 +680,8 @@ struct TEnv : public Env<const ASymbol*, const AType*> {
PEnv& penv;
unsigned varID;
+ AType* Closure;
+ AType* Dots;
AType* Fn;
AType* Tup;
AType* U;
@@ -701,9 +705,9 @@ struct Engine {
const std::string& name,
const ATuple* args,
const AType* type) = 0;
-
- virtual void pushFunctionArgs(CEnv& cenv, const ATuple* fn, const AType* type, CFunc f) = 0;
-
+
+ virtual void pushFunctionArgs(CEnv& cenv, const ATuple* prot, const AType* type, CFunc f) = 0;
+
virtual void finishFunction(CEnv& cenv, CFunc f, CVal ret) = 0;
virtual void eraseFunction(CEnv& cenv, CFunc f) = 0;
virtual CVal compileCons(CEnv& cenv, const AType* t, CVal rtti, ValVec& f) = 0;
@@ -742,7 +746,12 @@ struct CEnv {
if (type(ast))
Object::pool.addRoot(type(ast));
}
- const AType* type(const AST* ast, const Subst& subst = Subst()) const {
+ const AType* resolveType(const AType* type) const {
+ if (type->kind == AType::NAME)
+ return tenv.named(type->head()->to_symbol()->cppstr);
+ return type;
+ }
+ const AType* type(const AST* ast, const Subst& subst = Subst(), bool resolve=true) const {
const AType* ret = NULL;
const ASymbol* sym = ast->to_symbol();
if (sym) {
@@ -753,8 +762,10 @@ struct CEnv {
if (!ret)
ret = tenv.vars[ast];
if (ret)
- return tsubst.apply(subst.apply(ret))->to_type();
- return NULL;
+ ret = tsubst.apply(subst.apply(ret))->to_type();
+ if (resolve && ret)
+ ret = this->resolveType(ret);
+ return ret;
}
void def(const ASymbol* sym, const AST* c, const AType* t, CVal v) {
code.def(sym, c);
@@ -766,7 +777,8 @@ struct CEnv {
const AST** rec = code.ref(sym);
return rec ? *rec : ast;
}
- void setType(AST* ast, const AType* type) {
+ void setType(const AST* ast, const AType* type) {
+ assert(!ast->to_symbol());
const AType* tvar = tenv.var();
tenv.vars.insert(make_pair(ast, tvar));
tsubst.add(tvar, type);