mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
change _Func to &
This commit is contained in:
parent
4547f61bed
commit
7ecb8476f9
22
src/main.cpp
22
src/main.cpp
@ -4,6 +4,7 @@
|
||||
#include "pocketpy.h"
|
||||
|
||||
//#define PK_DEBUG_TIME
|
||||
//#define PK_DEBUG_STACK
|
||||
|
||||
struct Timer{
|
||||
const char* title;
|
||||
@ -49,7 +50,28 @@ extern "C" {
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#ifdef PK_DEBUG_STACK
|
||||
#include <sys/resource.h>
|
||||
|
||||
void setStackSize(_Float mb){
|
||||
const rlim_t kStackSize = (_Int)(mb * 1024 * 1024);
|
||||
struct rlimit rl;
|
||||
int result;
|
||||
result = getrlimit(RLIMIT_STACK, &rl);
|
||||
rl.rlim_cur = kStackSize;
|
||||
result = setrlimit(RLIMIT_STACK, &rl);
|
||||
if (result != 0){
|
||||
std::cerr << "setrlimit returned result = " << result << std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv){
|
||||
#ifdef PK_DEBUG_STACK
|
||||
setStackSize(1);
|
||||
#endif
|
||||
|
||||
if(argc == 1){
|
||||
REPL repl(newVM());
|
||||
while(true){
|
||||
|
2
src/vm.h
2
src/vm.h
@ -366,7 +366,7 @@ public:
|
||||
auto f = std::get<_CppFunc>(callable->_native);
|
||||
return f(this, args);
|
||||
} else if(callable->isType(_tp_function)){
|
||||
_Func fn = PyFunction_AS_C(callable);
|
||||
const _Func& fn = PyFunction_AS_C(callable);
|
||||
PyVarDict locals;
|
||||
int i = 0;
|
||||
for(const auto& name : fn.args){
|
||||
|
Loading…
x
Reference in New Issue
Block a user