mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
some update
This commit is contained in:
parent
ded75de379
commit
d53cd8e956
@ -11,6 +11,7 @@ using namespace pkpy;
|
|||||||
|
|
||||||
class MyVM: public VM{
|
class MyVM: public VM{
|
||||||
public:
|
public:
|
||||||
|
// use atomic to protect the flag
|
||||||
std::atomic<bool> _flag = false;
|
std::atomic<bool> _flag = false;
|
||||||
|
|
||||||
MyVM(): VM(){
|
MyVM(): VM(){
|
||||||
@ -43,12 +44,15 @@ int main(){
|
|||||||
std::cout << (need_more_lines ? "... " : ">>> ");
|
std::cout << (need_more_lines ? "... " : ">>> ");
|
||||||
std::string line;
|
std::string line;
|
||||||
std::getline(std::cin, line);
|
std::getline(std::cin, line);
|
||||||
|
|
||||||
vm->_flag = false; // reset the flag before each input
|
vm->_flag = false; // reset the flag before each input
|
||||||
|
|
||||||
// here I use linux signal to interrupt the vm
|
// here I use linux signal to interrupt the vm
|
||||||
// you can run this line in a thread for more flexibility
|
// you can run this line in a thread for more flexibility
|
||||||
need_more_lines = repl->input(line);
|
need_more_lines = repl->input(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete repl;
|
||||||
delete vm;
|
delete vm;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,11 @@
|
|||||||
/*************** feature settings ***************/
|
/*************** feature settings ***************/
|
||||||
|
|
||||||
// Whether to compile os-related modules or not
|
// Whether to compile os-related modules or not
|
||||||
#ifndef PK_ENABLE_OS // can be overrided by cmake
|
|
||||||
#define PK_ENABLE_OS 1
|
#define PK_ENABLE_OS 1
|
||||||
#endif
|
|
||||||
|
|
||||||
// Enable this if you are working with multi-threading (experimental)
|
// Enable this if you are working with multi-threading (experimental)
|
||||||
// This triggers necessary locks to make the VM thread-safe
|
// This triggers necessary locks to make the VM thread-safe
|
||||||
#ifndef PK_ENABLE_THREAD // can be overrided by cmake
|
#define PK_ENABLE_THREAD 1
|
||||||
#define PK_ENABLE_THREAD 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Enable this for `vm->_ceval_on_step`
|
// Enable this for `vm->_ceval_on_step`
|
||||||
#define PK_ENABLE_CEVAL_CALLBACK 1
|
#define PK_ENABLE_CEVAL_CALLBACK 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user