diff options
author | David Robillard <d@drobilla.net> | 2019-02-15 22:24:54 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-02-15 22:24:54 +0100 |
commit | b321fb5d3d6b3c2855c2fcc049c6f3b8fb13a7a8 (patch) | |
tree | 2347b5b8d8eac8647267fb33ed35cd0f8dfabdf8 /src/constrain.cpp | |
parent | 80801dc725dbb08c67ddee92fc742093f8c2bc7c (diff) | |
download | resp-llvm7.tar.gz resp-llvm7.tar.bz2 resp-llvm7.zip |
WIP: Port to LLVM7llvm7
Diffstat (limited to 'src/constrain.cpp')
-rw-r--r-- | src/constrain.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/constrain.cpp b/src/constrain.cpp index 8b0558f..6531ac2 100644 --- a/src/constrain.cpp +++ b/src/constrain.cpp @@ -25,7 +25,7 @@ #include "resp.hpp" static void -constrain_symbol(TEnv& tenv, Constraints& c, const ASymbol* sym) throw(Error) +constrain_symbol(TEnv& tenv, Constraints& c, const ASymbol* sym) { const AST** ref = tenv.ref(sym); THROW_IF(!ref, sym->loc, (format("undefined symbol `%1%'") % sym->sym()).str()); @@ -33,7 +33,7 @@ constrain_symbol(TEnv& tenv, Constraints& c, const ASymbol* sym) throw(Error) } static void -constrain_cons(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) +constrain_cons(TEnv& tenv, Constraints& c, const ATuple* call) { const ASymbol* name = (*call->begin())->as_symbol(); @@ -89,7 +89,7 @@ constrain_cons(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) } static void -constrain_dot(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) +constrain_dot(TEnv& tenv, Constraints& c, const ATuple* call) { THROW_IF(call->list_len() != 3, call->loc, "`.' requires exactly 2 arguments"); ATuple::const_iterator i = call->begin(); @@ -111,7 +111,7 @@ constrain_dot(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) } static void -constrain_def(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) +constrain_def(TEnv& tenv, Constraints& c, const ATuple* call) { THROW_IF(call->list_len() != 3, call->loc, "`define' requires exactly 2 arguments"); THROW_IF(!call->frst()->to_symbol(), call->frst()->loc, "`define' name is not a symbol"); @@ -127,7 +127,7 @@ constrain_def(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) } static void -constrain_def_type(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) +constrain_def_type(TEnv& tenv, Constraints& c, const ATuple* call) { THROW_IF(call->list_len() < 3, call->loc, "`define-type' requires at least 2 arguments"); ATuple::const_iterator i = call->iter_at(1); @@ -147,7 +147,7 @@ constrain_def_type(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) } static void -constrain_fn(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) +constrain_fn(TEnv& tenv, Constraints& c, const ATuple* call) { set<const ASymbol*> defs; TEnv::Frame frame; @@ -205,7 +205,7 @@ constrain_fn(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) } static void -constrain_if(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) +constrain_if(TEnv& tenv, Constraints& c, const ATuple* call) { THROW_IF(call->list_len() < 4, call->loc, "`if' requires at least 3 arguments"); THROW_IF(call->list_len() % 2 != 0, call->loc, "`if' missing final else clause"); @@ -227,7 +227,7 @@ constrain_if(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) } static void -constrain_match(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) +constrain_match(TEnv& tenv, Constraints& c, const ATuple* call) { THROW_IF(call->list_len() < 5, call->loc, "`match' requires at least 4 arguments"); const AST* matchee = call->list_ref(1); @@ -275,7 +275,7 @@ constrain_match(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) } static void -resp_constrain_quoted(TEnv& tenv, Constraints& c, const AST* ast) throw(Error) +resp_constrain_quoted(TEnv& tenv, Constraints& c, const AST* ast) { if (ast->tag() == T_SYMBOL) { c.constrain(tenv, ast, tenv.named("Symbol")); @@ -296,7 +296,7 @@ resp_constrain_quoted(TEnv& tenv, Constraints& c, const AST* ast) throw(Error) } static void -constrain_quote(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) +constrain_quote(TEnv& tenv, Constraints& c, const ATuple* call) { THROW_IF(call->list_len() != 2, call->loc, "`quote' requires exactly 1 argument"); resp_constrain_quoted(tenv, c, call->frst()); @@ -305,7 +305,7 @@ constrain_quote(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) } static void -constrain_call(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) +constrain_call(TEnv& tenv, Constraints& c, const ATuple* call) { const AST* const head = call->fst(); @@ -315,7 +315,7 @@ constrain_call(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) const AST* fnType = tenv.var(head); if (!AType::is_var(fnType)) { if (!is_form(fnType, "Fn")) - throw Error(call->loc, (format("call to non-function `%1%'") % head->str()).str()); + throw RespError(call->loc, (format("call to non-function `%1%'") % head->str()).str()); size_t numArgs = fnType->as_tuple()->prot()->list_len(); THROW_IF(numArgs != call->list_len() - 1, call->loc, @@ -335,7 +335,7 @@ constrain_call(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) } static void -constrain_primitive(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) +constrain_primitive(TEnv& tenv, Constraints& c, const ATuple* call) { const string n = call->fst()->to_symbol()->str(); enum { ARITHMETIC, BINARY, LOGICAL, COMPARISON } type; @@ -348,7 +348,7 @@ constrain_primitive(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) else if (n == "=" || n == "!=" || n == ">" || n == ">=" || n == "<" || n == "<=") type = COMPARISON; else - throw Error(call->loc, (format("unknown primitive `%1%'") % n).str()); + throw RespError(call->loc, (format("unknown primitive `%1%'") % n).str()); ATuple::const_iterator i = call->begin(); @@ -361,37 +361,37 @@ constrain_primitive(TEnv& tenv, Constraints& c, const ATuple* call) throw(Error) switch (type) { case ARITHMETIC: if (call->list_len() < 3) - throw Error(call->loc, (format("`%1%' requires at least 2 arguments") % n).str()); + throw RespError(call->loc, (format("`%1%' requires at least 2 arguments") % n).str()); for (++i; i != call->end(); ++i) c.constrain(tenv, *i, tenv.var(call)); break; case BINARY: if (call->list_len() != 3) - throw Error(call->loc, (format("`%1%' requires exactly 2 arguments") % n).str()); + throw RespError(call->loc, (format("`%1%' requires exactly 2 arguments") % n).str()); c.constrain(tenv, *++i, tenv.var(call)); c.constrain(tenv, *++i, tenv.var(call)); break; case LOGICAL: if (call->list_len() != 3) - throw Error(call->loc, (format("`%1%' requires exactly 2 arguments") % n).str()); + throw RespError(call->loc, (format("`%1%' requires exactly 2 arguments") % n).str()); c.constrain(tenv, call, tenv.named("Bool")); c.constrain(tenv, *++i, tenv.named("Bool")); c.constrain(tenv, *++i, tenv.named("Bool")); break; case COMPARISON: if (call->list_len() != 3) - throw Error(call->loc, (format("`%1%' requires exactly 2 arguments") % n).str()); + throw RespError(call->loc, (format("`%1%' requires exactly 2 arguments") % n).str()); var = tenv.var(*++i); c.constrain(tenv, call, tenv.named("Bool")); c.constrain(tenv, *++i, var); break; default: - throw Error(call->loc, (format("unknown primitive `%1%'") % n).str()); + throw RespError(call->loc, (format("unknown primitive `%1%'") % n).str()); } } static void -constrain_list(TEnv& tenv, Constraints& c, const ATuple* tup) throw(Error) +constrain_list(TEnv& tenv, Constraints& c, const ATuple* tup) { const ASymbol* const sym = tup->fst()->to_symbol(); if (!sym) { @@ -423,7 +423,7 @@ constrain_list(TEnv& tenv, Constraints& c, const ATuple* tup) throw(Error) } void -resp_constrain(TEnv& tenv, Constraints& c, const AST* ast) throw(Error) +resp_constrain(TEnv& tenv, Constraints& c, const AST* ast) { switch (ast->tag()) { case T_UNKNOWN: @@ -449,6 +449,6 @@ resp_constrain(TEnv& tenv, Constraints& c, const AST* ast) throw(Error) constrain_list(tenv, c, ast->as_tuple()); break; case T_ELLIPSIS: - throw Error(ast->loc, "ellipsis present after expand stage"); + throw RespError(ast->loc, "ellipsis present after expand stage"); } } |