diff options
Diffstat (limited to 'src/resp.cpp')
-rw-r--r-- | src/resp.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/resp.cpp b/src/resp.cpp index 96df3b7..c1684e2 100644 --- a/src/resp.cpp +++ b/src/resp.cpp @@ -28,6 +28,38 @@ using namespace std; GC Object::pool(8 * 1024 * 1024); +bool +is_form(const AST* ast, const std::string& form) +{ + const AFn* fn = ast->to<const AFn*>(); + if (fn) + return form == "fn"; + + const ACall* call = ast->to<const ACall*>(); + if (!call) + return false; + + const ASymbol* const sym = call->head()->to<const ASymbol*>(); + if (!sym) + return false; + + return sym->cppstr == form; +} + +bool +is_primitive(const PEnv& penv, const AST* ast) +{ + const ACall* call = ast->to<const ACall*>(); + if (!call) + return false; + + const ASymbol* const sym = call->head()->to<const ASymbol*>(); + if (!sym) + return false; + + return penv.primitives.find(sym->cppstr) != penv.primitives.end(); +} + int print_usage(char* name, bool error) { |