1.1 --- a/jitcraft/main.cpp Tue Jul 10 02:11:13 2012 -0700
1.2 +++ b/jitcraft/main.cpp Wed Jul 11 01:12:54 2012 -0700
1.3 @@ -30,6 +30,29 @@
1.4
1.5 using namespace ke;
1.6
1.7 +class MessageReporter : public Ke::IMessageReporter
1.8 +{
1.9 + public:
1.10 + void onOutOfMemory() {
1.11 + fprintf(stderr, "Out of memory!\n");
1.12 + }
1.13 + void onUncaughtException(const char *message) {
1.14 + fprintf(stderr, "Uncaught exception: %s\n", message);
1.15 +
1.16 + Ke::IStackFrameIterator *iter = Ke::Keima::NewStackFrameIterator();
1.17 + unsigned index = 0;
1.18 + while (!iter->done()) {
1.19 + fprintf(stderr, "[%d] %s (%s line %d)\n",
1.20 + index,
1.21 + iter->function(),
1.22 + iter->source(),
1.23 + iter->lineNumber());
1.24 + iter->prev();
1.25 + index++;
1.26 + }
1.27 + }
1.28 +} s_Reporter;
1.29 +
1.30 #if 0
1.31 static bool
1.32 Compile(const char *stream, size_t length)
1.33 @@ -80,6 +103,7 @@
1.34
1.35 if (!Ke::Keima::Initialize())
1.36 return 1;
1.37 + Ke::Keima::InstallMessageReporter(&s_Reporter);
1.38 {
1.39 Ke::HandleScope scope;
1.40 Ke::Local<Ke::Module> module = Ke::Compile(argv[1]);