diff options
-rw-r--r-- | llvm.cpp | 11 | ||||
-rw-r--r-- | tuplr.hpp | 10 | ||||
-rw-r--r-- | typing.cpp | 4 |
3 files changed, 5 insertions, 20 deletions
@@ -124,7 +124,6 @@ CEnv::compile(AST* obj) void CEnv::optimise(CFunction f) { - _pimpl->module->dump(); verifyFunction(*static_cast<Function*>(f)); _pimpl->opt.run(*static_cast<Function*>(f)); } @@ -264,10 +263,9 @@ AClosure::liftCall(CEnv& cenv, const vector<AType*>& argsT) argsSubst[dynamic_cast<AType*>(genericProtT->at(i))] = dynamic_cast<AType*>(argsT.at(i)); AType* thisType = new AType(*dynamic_cast<ATuple*>(argsSubst.apply(genericType)), loc); - cenv.err << "THIS TYPE: " << thisType << endl; - //if (!thisType->concrete()) - // throw Error("unable to resolve concrete type for function", loc); + if (!thisType->concrete()) + throw Error("unable to resolve concrete type for function", loc); if (funcs.find(thisType)) return; @@ -601,15 +599,15 @@ eval(CEnv& cenv, const string& name, istream& is) list< pair<SExp, AST*> > exprs; Cursor cursor(name); try { - Constraints c; while (true) { SExp exp = readExpression(cursor, is); if (exp.type == SExp::LIST && exp.list.empty()) break; result = cenv.penv.parse(exp); // Parse input + Constraints c; result->constrain(cenv.tenv, c); // Constrain types - cenv.tsubst = TEnv::unify(c); // Solve type constraints + cenv.tsubst = Subst::compose(cenv.tsubst, TEnv::unify(c)); // Solve type constraints resultType = cenv.type(result); result->lift(cenv); // Lift functions exprs.push_back(make_pair(exp, result)); @@ -650,7 +648,6 @@ repl(CEnv& cenv) Cursor cursor("(stdin)"); Constraints c; try { - SExp exp = readExpression(cursor, std::cin); if (exp.type == SExp::LIST && exp.list.empty()) break; @@ -447,7 +447,6 @@ struct Subst : public map<const AType*,AType*> { Subst copy(*this); iterator i; while ((i = copy.find(in)) != copy.end()) { - cerr << "IN: " << in << endl; in = i->second; copy.erase(i); } @@ -465,10 +464,6 @@ struct TEnv : public Env<const AST*,AType*> { return def(sym, new AType(varID++, LAddr(), sym->loc)); } AType* var(const AST* ast=0) { - /*GenericTypes::iterator g = genericTypes.find(dynamic_casdt<AClosure*>(ast)); - if (g != vars.end()) - return g->second;*/ - const ASymbol* sym = dynamic_cast<const ASymbol*>(ast); if (sym) return deref(lookup(sym)); @@ -525,9 +520,7 @@ struct CEnv { return dynamic_cast<AType*>(tsubst.apply(subst.apply(tenv.vars[ast]))); } void def(ASymbol* sym, AST* c, AType* t, CValue v) { - code.def(sym, c); - tenv.def(sym, t); - vals.def(sym, v); + code.def(sym, c); tenv.def(sym, t); vals.def(sym, v); } ostream& out; @@ -537,7 +530,6 @@ struct CEnv { Code code; Vals vals; - unsigned symID; CFunction alloc; Subst tsubst; @@ -119,15 +119,11 @@ AClosure::constrain(TEnv& tenv, Constraints& c) const } c.constrain(tenv, this, genericType); - //for (Constraints::const_iterator i = cp.begin(); i != cp.end(); ++i) - // c.push_back(*i); } void ACall::constrain(TEnv& tenv, Constraints& c) const { - std::cerr << "CONSTRAIN CALL" << endl; - at(0)->constrain(tenv, c); AType* argsT = new AType(ATuple(), loc); for (size_t i = 1; i < size(); ++i) { |