mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 20:10:17 +00:00
...
This commit is contained in:
parent
73fbb98712
commit
0befc0139f
13
src/ceval.h
13
src/ceval.h
@ -490,7 +490,18 @@ __NEXT_STEP:;
|
||||
auto it = _lazy_modules.find(name);
|
||||
if(it == _lazy_modules.end()){
|
||||
Bytes b = _read_file_cwd(fmt(name, ".py"));
|
||||
if(!b) _error("ImportError", fmt("module ", name.escape(), " not found"));
|
||||
if(!b) {
|
||||
for(Str path: _path){
|
||||
#ifdef _WIN32
|
||||
const char* sep = "\\";
|
||||
#else
|
||||
const char* sep = "/";
|
||||
#endif
|
||||
b = _read_file_cwd(fmt(path, sep, name, ".py"));
|
||||
if(b) break;
|
||||
}
|
||||
if(!b) _error("ImportError", fmt("module ", name.escape(), " not found"));
|
||||
}
|
||||
source = Str(b.str());
|
||||
}else{
|
||||
source = it->second;
|
||||
|
10
src/common.h
10
src/common.h
@ -42,6 +42,7 @@
|
||||
#define DEBUG_NO_AUTO_GC 0
|
||||
#define DEBUG_GC_STATS 0
|
||||
|
||||
// config macros
|
||||
#ifndef PK_ENABLE_OS
|
||||
|
||||
#ifdef __ANDROID__
|
||||
@ -59,6 +60,14 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if PK_ENABLE_THREAD
|
||||
#define THREAD_LOCAL thread_local
|
||||
#else
|
||||
#define THREAD_LOCAL
|
||||
#endif
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
// This is the maximum number of arguments in a function declaration
|
||||
// including positional arguments, keyword-only arguments, and varargs
|
||||
#define PK_MAX_CO_VARNAMES 255
|
||||
@ -128,7 +137,6 @@ struct Type {
|
||||
operator int() const noexcept { return this->index; }
|
||||
};
|
||||
|
||||
#define THREAD_LOCAL // thread_local
|
||||
#define CPP_LAMBDA(x) ([](VM* vm, ArgsView args) { return x; })
|
||||
|
||||
#ifdef POCKETPY_H
|
||||
|
5
src/vm.h
5
src/vm.h
@ -113,8 +113,9 @@ public:
|
||||
std::vector<PyTypeInfo> _all_types;
|
||||
void (*_gc_marker_ex)(VM*) = nullptr;
|
||||
|
||||
NameDict _modules; // loaded modules
|
||||
std::map<StrName, Str> _lazy_modules; // lazy loaded modules
|
||||
NameDict _modules; // loaded modules
|
||||
std::map<StrName, Str> _lazy_modules; // lazy loaded modules
|
||||
std::vector<Str> _path; // search path
|
||||
|
||||
PyObject* None;
|
||||
PyObject* True;
|
||||
|
Loading…
x
Reference in New Issue
Block a user