From cce4f16e87870eae8a1c3f430c9617cefd55fe54 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 27 Dec 2010 22:48:00 +0000 Subject: Remove weird __tag_is form by adding a T_LITSYM type and using = operator. Step towards having first class symbols... git-svn-id: http://svn.drobilla.net/resp/resp@362 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/simplify.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/simplify.cpp') 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(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(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)); -- cgit v1.2.1