diff options
Diffstat (limited to 'src/simplify.cpp')
-rw-r--r-- | src/simplify.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/simplify.cpp b/src/simplify.cpp index 715202a..397c2b7 100644 --- a/src/simplify.cpp +++ b/src/simplify.cpp @@ -63,10 +63,10 @@ simplify_match(CEnv& cenv, const ATuple* match) throw() tval.push_back(resp_simplify(cenv, match->list_ref(1))); tval.push_back(new ALiteral<int32_t>(T_INT32, -1, Cursor())); - const ASymbol* tsym = cenv.penv.gensym("_matchT"); + const ASymbol* tsym = cenv.penv.gensym("__tag"); List def(match->loc, cenv.penv.sym("def"), tsym, tval.head, NULL); - cenv.setType(tval.head, cenv.tenv.named("String")); + cenv.setType(tval.head, cenv.tenv.named("Symbol")); List copyIf; copyIf.push_back(cenv.penv.sym("if")); @@ -74,10 +74,16 @@ simplify_match(CEnv& cenv, const ATuple* match) throw() const ATuple* pat = (*i++)->as_tuple(); const AST* body = *i++; + const ASymbol* consTag = cenv.penv.sym(pat->head()->str(), pat->head()->loc); + const_cast<ASymbol*>(consTag)->tag(T_LITSYM); + cenv.setType(consTag, cenv.tenv.named("Symbol")); + List cond; - cond.push_back(cenv.penv.sym("__tag_is")); + cond.push_back(cenv.penv.sym("=")); cond.push_back(tsym); - cond.push_back(pat->head()); + cond.push_back(consTag); + + cenv.setType(cond, cenv.tenv.named("Bool")); copyIf.push_back(cond); copyIf.push_back(resp_simplify(cenv, body)); |