diff options
author | Chris Lattner <sabre@nondot.org> | 2003-05-14 14:21:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-05-14 14:21:30 +0000 |
commit | 4a5bb95729a5335bfdddd401454003ac05ba4316 (patch) | |
tree | 607258b2be0e52186b222f3d3f17b0002b47b3e8 /llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp | |
parent | 2537ca318a65e29e085ed1f8e4f88387b21fdbad (diff) | |
download | llvm-4a5bb95729a5335bfdddd401454003ac05ba4316.zip llvm-4a5bb95729a5335bfdddd401454003ac05ba4316.tar.gz llvm-4a5bb95729a5335bfdddd401454003ac05ba4316.tar.bz2 |
Add support for atexit function, remove support for __main function
llvm-svn: 6194
Diffstat (limited to 'llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp index 4582a6f..3453d831 100644 --- a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp +++ b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.cpp @@ -48,10 +48,21 @@ int Interpreter::run(const std::string &MainFunction, run(); } - // If debug mode, allow the user to interact... also, if the user pressed - // ctrl-c or execution hit an error, enter the event loop... - if (Debug || isStopped()) - handleUserInput(); + do { + // If debug mode, allow the user to interact... also, if the user pressed + // ctrl-c or execution hit an error, enter the event loop... + if (Debug || isStopped()) + handleUserInput(); + + // If the program has exited, run atexit handlers... + if (ECStack.empty() && !AtExitHandlers.empty()) { + callFunction(AtExitHandlers.back(), std::vector<GenericValue>()); + AtExitHandlers.pop_back(); + run(); + } + } while (!ECStack.empty()); + + PerformExitStuff(); return ExitCode; } |