mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
some fix
This commit is contained in:
parent
bcfb6b64f3
commit
ff4776f756
@ -321,8 +321,10 @@ public:
|
||||
void exprLambda() {
|
||||
_Func func;
|
||||
func.name = "<lambda>";
|
||||
__compileFunctionArgs(func);
|
||||
consume(TK(":"));
|
||||
if(!match(TK(":"))){
|
||||
__compileFunctionArgs(func);
|
||||
consume(TK(":"));
|
||||
}
|
||||
func.code = std::make_shared<CodeObject>(parser->src, func.name);
|
||||
this->codes.push(func.code);
|
||||
EXPR_TUPLE();
|
||||
|
@ -497,11 +497,6 @@ void __initializeBuiltinFunctions(VM* _vm) {
|
||||
});
|
||||
}
|
||||
|
||||
void __runCodeBuiltins(VM* vm, const char* src){
|
||||
_Code code = compile(vm, src, "builtins.py");
|
||||
if(code != nullptr) vm->exec(code, vm->builtins);
|
||||
}
|
||||
|
||||
#include "builtins.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
@ -535,11 +530,15 @@ extern "C" {
|
||||
VM* createVM(PrintFn _stdout, PrintFn _stderr){
|
||||
VM* vm = new VM();
|
||||
__initializeBuiltinFunctions(vm);
|
||||
__runCodeBuiltins(vm, __BUILTINS_CODE);
|
||||
__addModuleSys(vm);
|
||||
__addModuleTime(vm);
|
||||
vm->_stdout = _stdout;
|
||||
vm->_stderr = _stderr;
|
||||
|
||||
_Code code = compile(vm, __BUILTINS_CODE, "builtins.py");
|
||||
if(code == nullptr) exit(1);
|
||||
vm->_exec(code, vm->builtins);
|
||||
|
||||
__addModuleSys(vm);
|
||||
__addModuleTime(vm);
|
||||
return vm;
|
||||
}
|
||||
|
||||
|
8
src/vm.h
8
src/vm.h
@ -411,8 +411,7 @@ public:
|
||||
PyVar exec(const _Code& code, PyVar _module=nullptr){
|
||||
if(_module == nullptr) _module = _main;
|
||||
try {
|
||||
PyVarDict locals;
|
||||
return _exec(code, _module, locals);
|
||||
return _exec(code, _module);
|
||||
} catch (const std::exception& e) {
|
||||
if(const _Error* _ = dynamic_cast<const _Error*>(&e)){
|
||||
_stderr(e.what());
|
||||
@ -425,6 +424,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
PyVar _exec(const _Code& code, PyVar _module){
|
||||
PyVarDict locals;
|
||||
return _exec(code, _module, locals);
|
||||
}
|
||||
|
||||
PyVar _exec(const _Code& code, PyVar _module, PyVarDict& locals){
|
||||
if(code == nullptr) UNREACHABLE();
|
||||
Frame* frame = new Frame(
|
||||
|
Loading…
x
Reference in New Issue
Block a user