diff options
Diffstat (limited to 'src/constrain.cpp')
-rw-r--r-- | src/constrain.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/constrain.cpp b/src/constrain.cpp index 4bd6c08..f65ad8f 100644 --- a/src/constrain.cpp +++ b/src/constrain.cpp @@ -260,6 +260,17 @@ constrain_match(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) } static void +constrain_quote(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) +{ + THROW_IF(call->list_len() != 2, call->loc, "`quote' requires exactly 1 argument"); + switch (call->list_ref(1)->tag()) { + case T_TUPLE: c.constrain(tenv, call, tenv.named("List")); return; + case T_SYMBOL: c.constrain(tenv, call, tenv.named("Symbol")); return; + default: return; + } +} + +static void constrain_call(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) { const AST* const head = call->head(); @@ -370,6 +381,8 @@ constrain_list(TEnv& tenv, Constraints& c, const ATuple* tup) throw(Error) constrain_let(tenv, c, tup); else if (form == "match") constrain_match(tenv, c, tup); + else if (form == "quote") + constrain_quote(tenv, c, tup); else constrain_call(tenv, c, tup); } |