blob: 90afa0146b1b3869f2883f32ead22dc0f6ee98a3 [file] [log] [blame]
Frederich Munch529ce722018-03-14 16:04:45 +00001//==-- 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
15namespace interpreter {
16
17int 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}