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