59 lines
1.3 KiB
Plaintext
59 lines
1.3 KiB
Plaintext
# @TEST-GROUP: no-jit
|
|
# @TEST-EXEC: ${HILTIC} -g -P "" -o Foo.h %INPUT
|
|
# @TEST-EXEC: ${HILTIC} -g -c -D compiler -o foo.cc %INPUT
|
|
# @TEST-EXEC: ${HILTIC} -g -l -D compiler -o linker.cc foo.cc
|
|
# @TEST-EXEC: cxx-compile -c -o foo.o foo.cc
|
|
# @TEST-EXEC: cxx-compile -c -o linker.o linker.cc
|
|
# @TEST-EXEC: cxx-compile -c -o driver.o driver.cc
|
|
# @TEST-EXEC: cxx-link -o a.out foo.o linker.o driver.o
|
|
# @TEST-EXEC: ./a.out >output
|
|
# @TEST-EXEC: btest-diff output
|
|
|
|
module Foo {
|
|
|
|
import hilti;
|
|
|
|
type MyException = exception;
|
|
|
|
function extern void test() {
|
|
hilti::print("HILTI - Begin");
|
|
throw MyException("test exception");
|
|
hilti::print("HILTI - End - Not reached");
|
|
}
|
|
|
|
}
|
|
|
|
@TEST-START-FILE driver.cc
|
|
|
|
#include <hilti/rt/libhilti.h>
|
|
|
|
#include "Foo.h"
|
|
|
|
extern "C" int HILTI_EXPORT hilti_main() { // Point of entry for JIT
|
|
try {
|
|
auto r = hlt::Foo::test();
|
|
|
|
while ( ! r ) {
|
|
std::cout << "suspended, resuming" << std::endl;
|
|
r.resume();
|
|
}
|
|
|
|
std::cout << "Done, but shouldn't get here" << std::endl;
|
|
}
|
|
|
|
catch ( const hilti::rt::Exception& e ) {
|
|
std::cout << "Caught exception: " << e.what() << std::endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
hilti::rt::init();
|
|
hilti_main();
|
|
hilti::rt::done();
|
|
return 0;
|
|
}
|
|
|
|
@TEST-END-FILE
|