This commit is contained in:
blueloveTH 2023-07-15 15:41:01 +08:00
parent b282630b02
commit 89ec12cada
2 changed files with 10 additions and 0 deletions

View File

@ -4,6 +4,7 @@ namespace pkpy{
VM::VM(bool enable_os) : heap(this), enable_os(enable_os) { VM::VM(bool enable_os) : heap(this), enable_os(enable_os) {
this->vm = this; this->vm = this;
this->_c.error = nullptr;
_stdout = [](VM* vm, const Str& s) { _stdout = [](VM* vm, const Str& s) {
PK_UNUSED(vm); PK_UNUSED(vm);
std::cout << s; std::cout << s;

View File

@ -103,6 +103,15 @@ int main(int argc, char** argv){
std::filesystem::current_path(filepath.parent_path()); std::filesystem::current_path(filepath.parent_path());
bool ok = pkpy_exec_2(vm, src.c_str(), filepath.filename().string().c_str(), 0, NULL); bool ok = pkpy_exec_2(vm, src.c_str(), filepath.filename().string().c_str(), 0, NULL);
if(!ok){
char* err;
if(pkpy_clear_error(vm, &err)){
std::cerr << err << std::endl;
pkpy_free(err);
}else{
std::cerr << "Unknown error" << std::endl;
}
}
pkpy_delete_vm(vm); pkpy_delete_vm(vm);
return ok ? 0 : 1; return ok ? 0 : 1;
} }