Frederich Munch | 529ce72 | 2018-03-14 16:04:45 +0000 | [diff] [blame] | 1 | //==-- examples/clang-interpreter/Invoke.cpp - Clang C Interpreter Example -==// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "Invoke.h" |
| 11 | |
| 12 | #include <iostream> |
| 13 | #include <stdexcept> |
| 14 | |
| 15 | namespace interpreter { |
| 16 | |
| 17 | int TryIt(llvm::ExecutionEngine *EE, llvm::Function *EntryFn, |
| 18 | const std::vector<std::string> &Args, char *const *EnvP, |
| 19 | Invoker Invoke) { |
| 20 | int Res = -1; |
| 21 | try { |
| 22 | Res = Invoke(EE, EntryFn, Args, EnvP); |
| 23 | } catch (const std::exception &E) { |
| 24 | std::cout << "Caught '" << E.what() << "'\n"; |
| 25 | } catch (...) { |
| 26 | std::cout << "Unknown exception\n"; |
| 27 | } |
| 28 | return Res; |
| 29 | } |
| 30 | |
| 31 | } |