🐛 fix mingw make error
This commit is contained in:
parent
ecfb679218
commit
8290b7df9f
6
makefile
6
makefile
|
@ -1,11 +1,13 @@
|
||||||
STD = c++17
|
STD = c++17
|
||||||
OS = $(shell uname)
|
|
||||||
|
ifndef OS
|
||||||
|
OS = $(shell uname)
|
||||||
|
endif
|
||||||
ifeq ($(OS), Darwin)
|
ifeq ($(OS), Darwin)
|
||||||
CXXFLAGS = -std=$(STD) -c -O3 -fno-exceptions -fPIC -mmacosx-version-min=10.15
|
CXXFLAGS = -std=$(STD) -c -O3 -fno-exceptions -fPIC -mmacosx-version-min=10.15
|
||||||
else
|
else
|
||||||
CXXFLAGS = -std=$(STD) -c -O3 -fno-exceptions -fPIC
|
CXXFLAGS = -std=$(STD) -c -O3 -fno-exceptions -fPIC
|
||||||
endif
|
endif
|
||||||
CPPFLAGS = -I .
|
|
||||||
|
|
||||||
NASAL_HEADER=\
|
NASAL_HEADER=\
|
||||||
src/ast_dumper.h\
|
src/ast_dumper.h\
|
||||||
|
|
|
@ -62,7 +62,7 @@ var set_new_ghost(var* args, usize size, gc* ngc) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
f64 num = args[1].num();
|
f64 num = args[1].num();
|
||||||
*((u32*)res.obj().ptr) = static_cast<u32>(num);
|
*((u32*)res.obj().pointer) = static_cast<u32>(num);
|
||||||
std::cout << "set_new_ghost: successfully set ghost = " << num << "\n";
|
std::cout << "set_new_ghost: successfully set ghost = " << num << "\n";
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ var print_new_ghost(var* args, usize size, gc* ngc) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
std::cout << "print_new_ghost: " << res.obj() << " result = "
|
std::cout << "print_new_ghost: " << res.obj() << " result = "
|
||||||
<< *((u32*)res.obj().ptr) << "\n";
|
<< *((u32*)res.obj().pointer) << "\n";
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,10 @@ used_header = ../src/nasal.h ../src/nasal_gc.h
|
||||||
used_object = ../build/nasal_misc.o ../build/nasal_gc.o
|
used_object = ../build/nasal_misc.o ../build/nasal_gc.o
|
||||||
|
|
||||||
STD = c++17
|
STD = c++17
|
||||||
OS = $(shell uname)
|
|
||||||
|
ifndef OS
|
||||||
|
OS = $(shell uname)
|
||||||
|
endif
|
||||||
ifeq ($(OS), Darwin)
|
ifeq ($(OS), Darwin)
|
||||||
CXXFLAGS = -std=$(STD) -c -O3 -fPIC -mmacosx-version-min=10.15
|
CXXFLAGS = -std=$(STD) -c -O3 -fPIC -mmacosx-version-min=10.15
|
||||||
else
|
else
|
||||||
|
|
|
@ -17,10 +17,16 @@ var builtin_cocreate(var* local, gc& ngc) {
|
||||||
// +-------------+
|
// +-------------+
|
||||||
var func = local[1];
|
var func = local[1];
|
||||||
if (func.type!=vm_func) {
|
if (func.type!=vm_func) {
|
||||||
return nas_err("coroutine::create", "must use a function to create coroutine");
|
return nas_err(
|
||||||
|
"coroutine::create",
|
||||||
|
"must use a function to create coroutine"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (ngc.cort) {
|
if (ngc.cort) {
|
||||||
return nas_err("coroutine::create", "cannot create another coroutine in a coroutine");
|
return nas_err(
|
||||||
|
"coroutine::create",
|
||||||
|
"cannot create another coroutine in a coroutine"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
var co = ngc.alloc(vm_co);
|
var co = ngc.alloc(vm_co);
|
||||||
nas_co& cort = co.co();
|
nas_co& cort = co.co();
|
||||||
|
@ -30,13 +36,18 @@ var builtin_cocreate(var* local, gc& ngc) {
|
||||||
cort.ctx.localr = cort.ctx.top+1;
|
cort.ctx.localr = cort.ctx.top+1;
|
||||||
cort.ctx.top = cort.ctx.localr+func.func().local_size;
|
cort.ctx.top = cort.ctx.localr+func.func().local_size;
|
||||||
cort.ctx.localr[0] = func.func().local[0];
|
cort.ctx.localr[0] = func.func().local[0];
|
||||||
cort.ctx.top[0] = nil; // old upvalr
|
// store old upvalr on stack
|
||||||
|
cort.ctx.top[0] = nil;
|
||||||
cort.ctx.top++;
|
cort.ctx.top++;
|
||||||
cort.ctx.top[0] = var::addr((var*)nullptr); // old localr
|
// store old localr on stack
|
||||||
|
cort.ctx.top[0] = var::addr((var*)nullptr);
|
||||||
cort.ctx.top++;
|
cort.ctx.top++;
|
||||||
cort.ctx.top[0] = var::ret(0); // old pc, set to zero to make op_ret recognizing this as coroutine function
|
// store old pc on stack
|
||||||
|
// set to zero to make op_ret recognizing this as coroutine function
|
||||||
|
cort.ctx.top[0] = var::ret(0);
|
||||||
|
|
||||||
cort.ctx.funcr = func; // make sure the coroutine function can use correct upvalues
|
// make sure the coroutine function can use correct upvalues
|
||||||
|
cort.ctx.funcr = func;
|
||||||
cort.status = nas_co::status::suspended;
|
cort.status = nas_co::status::suspended;
|
||||||
|
|
||||||
return co;
|
return co;
|
||||||
|
@ -44,7 +55,10 @@ var builtin_cocreate(var* local, gc& ngc) {
|
||||||
|
|
||||||
var builtin_coresume(var* local, gc& ngc) {
|
var builtin_coresume(var* local, gc& ngc) {
|
||||||
if (ngc.cort) {
|
if (ngc.cort) {
|
||||||
return nas_err("coroutine::resume", "cannot start another coroutine when one is running");
|
return nas_err(
|
||||||
|
"coroutine::resume",
|
||||||
|
"cannot start another coroutine when one is running"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
var co = local[1];
|
var co = local[1];
|
||||||
// return nil if is not a coroutine object
|
// return nil if is not a coroutine object
|
||||||
|
@ -61,9 +75,9 @@ var builtin_coresume(var* local, gc& ngc) {
|
||||||
|
|
||||||
// fetch coroutine's stack top and return
|
// fetch coroutine's stack top and return
|
||||||
// so the coroutine's stack top in fact is not changed
|
// so the coroutine's stack top in fact is not changed
|
||||||
if (ngc.rctx->top[0].type==vm_ret) {
|
if (ngc.running_context->top[0].type==vm_ret) {
|
||||||
// when first calling this coroutine, the stack top must be vm_ret
|
// when first calling this coroutine, the stack top must be vm_ret
|
||||||
return ngc.rctx->top[0];
|
return ngc.running_context->top[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// after first calling the coroutine, each time coroutine.yield triggered
|
// after first calling the coroutine, each time coroutine.yield triggered
|
||||||
|
|
|
@ -42,11 +42,11 @@ var builtin_dlopen(var* local, gc& ngc) {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void* func = (void*)GetProcAddress(
|
void* func = (void*)GetProcAddress(
|
||||||
static_cast<HMODULE>(lib.obj().ptr),
|
static_cast<HMODULE>(lib.obj().pointer),
|
||||||
"get"
|
"get"
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
void* func = dlsym(lib.obj().ptr, "get");
|
void* func = dlsym(lib.obj().pointer, "get");
|
||||||
#endif
|
#endif
|
||||||
if (!func) {
|
if (!func) {
|
||||||
return nas_err("dlopen", "cannot find <get> function");
|
return nas_err("dlopen", "cannot find <get> function");
|
||||||
|
@ -83,7 +83,7 @@ var builtin_dlcallv(var* local, gc& ngc) {
|
||||||
return nas_err("dlcall", "\"ptr\" is not a valid function pointer");
|
return nas_err("dlcall", "\"ptr\" is not a valid function pointer");
|
||||||
}
|
}
|
||||||
auto& vec = args.vec().elems;
|
auto& vec = args.vec().elems;
|
||||||
return reinterpret_cast<module_func>(fp.obj().ptr)(
|
return reinterpret_cast<module_func>(fp.obj().pointer)(
|
||||||
vec.data(),
|
vec.data(),
|
||||||
vec.size(),
|
vec.size(),
|
||||||
&ngc
|
&ngc
|
||||||
|
@ -97,9 +97,9 @@ var builtin_dlcall(var* local, gc& ngc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var* local_frame_start = local+2;
|
var* local_frame_start = local+2;
|
||||||
usize local_frame_size = ngc.rctx->top-local_frame_start;
|
usize local_frame_size = ngc.running_context->top-local_frame_start;
|
||||||
// arguments' stored place begins at local +2
|
// arguments' stored place begins at local +2
|
||||||
return reinterpret_cast<module_func>(fp.obj().ptr)(
|
return reinterpret_cast<module_func>(fp.obj().pointer)(
|
||||||
local_frame_start,
|
local_frame_start,
|
||||||
local_frame_size,
|
local_frame_size,
|
||||||
&ngc
|
&ngc
|
||||||
|
|
|
@ -92,7 +92,7 @@ var builtin_read(var* local, gc& ngc) {
|
||||||
if (!buff) {
|
if (!buff) {
|
||||||
return nas_err("read", "malloc failed");
|
return nas_err("read", "malloc failed");
|
||||||
}
|
}
|
||||||
f64 res = fread(buff, 1, len.num(), static_cast<FILE*>(fd.obj().ptr));
|
f64 res = fread(buff, 1, len.num(), static_cast<FILE*>(fd.obj().pointer));
|
||||||
buf.str() = buff;
|
buf.str() = buff;
|
||||||
buf.val.gcobj->unmut = true;
|
buf.val.gcobj->unmut = true;
|
||||||
delete []buff;
|
delete []buff;
|
||||||
|
@ -112,7 +112,7 @@ var builtin_write(var* local, gc& ngc) {
|
||||||
str.str().c_str(),
|
str.str().c_str(),
|
||||||
1,
|
1,
|
||||||
str.str().length(),
|
str.str().length(),
|
||||||
static_cast<FILE*>(fd.obj().ptr)
|
static_cast<FILE*>(fd.obj().pointer)
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ var builtin_seek(var* local, gc& ngc) {
|
||||||
return nas_err("seek", "not a valid filehandle");
|
return nas_err("seek", "not a valid filehandle");
|
||||||
}
|
}
|
||||||
return var::num(static_cast<f64>(fseek(
|
return var::num(static_cast<f64>(fseek(
|
||||||
static_cast<FILE*>(fd.obj().ptr),
|
static_cast<FILE*>(fd.obj().pointer),
|
||||||
pos.num(),
|
pos.num(),
|
||||||
whence.num()
|
whence.num()
|
||||||
)));
|
)));
|
||||||
|
@ -135,7 +135,9 @@ var builtin_tell(var* local, gc& ngc) {
|
||||||
if (!fd.objchk(file_type_name)) {
|
if (!fd.objchk(file_type_name)) {
|
||||||
return nas_err("tell", "not a valid filehandle");
|
return nas_err("tell", "not a valid filehandle");
|
||||||
}
|
}
|
||||||
return var::num(static_cast<f64>(ftell(static_cast<FILE*>(fd.obj().ptr))));
|
return var::num(static_cast<f64>(
|
||||||
|
ftell(static_cast<FILE*>(fd.obj().pointer))
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
var builtin_readln(var* local, gc& ngc) {
|
var builtin_readln(var* local, gc& ngc) {
|
||||||
|
@ -145,7 +147,7 @@ var builtin_readln(var* local, gc& ngc) {
|
||||||
}
|
}
|
||||||
var str = ngc.alloc(vm_str);
|
var str = ngc.alloc(vm_str);
|
||||||
char c;
|
char c;
|
||||||
while((c = fgetc(static_cast<FILE*>(fd.obj().ptr)))!=EOF) {
|
while((c = fgetc(static_cast<FILE*>(fd.obj().pointer)))!=EOF) {
|
||||||
if (c=='\r') {
|
if (c=='\r') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +193,9 @@ var builtin_eof(var* local, gc& ngc) {
|
||||||
if (!fd.objchk(file_type_name)) {
|
if (!fd.objchk(file_type_name)) {
|
||||||
return nas_err("readln", "not a valid filehandle");
|
return nas_err("readln", "not a valid filehandle");
|
||||||
}
|
}
|
||||||
return var::num(static_cast<f64>(feof(static_cast<FILE*>(fd.obj().ptr))));
|
return var::num(static_cast<f64>(
|
||||||
|
feof(static_cast<FILE*>(fd.obj().pointer))
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
nasal_builtin_table io_lib_native[] = {
|
nasal_builtin_table io_lib_native[] = {
|
||||||
|
|
|
@ -616,7 +616,7 @@ var builtin_ghosttype(var* local, gc& ngc) {
|
||||||
}
|
}
|
||||||
const auto& name = arg.obj().get_ghost_name();
|
const auto& name = arg.obj().get_ghost_name();
|
||||||
if (!name.length()) {
|
if (!name.length()) {
|
||||||
return var::num(reinterpret_cast<u64>(arg.obj().ptr));
|
return var::num(reinterpret_cast<u64>(arg.obj().pointer));
|
||||||
}
|
}
|
||||||
return ngc.newstr(name);
|
return ngc.newstr(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,34 +104,34 @@ void nas_ghost::set(
|
||||||
destructor destructor_pointer,
|
destructor destructor_pointer,
|
||||||
void* ghost_pointer) {
|
void* ghost_pointer) {
|
||||||
type_name = ghost_type_name;
|
type_name = ghost_type_name;
|
||||||
dtor_ptr = destructor_pointer;
|
destructor_function = destructor_pointer;
|
||||||
ptr = ghost_pointer;
|
pointer = ghost_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nas_ghost::clear() {
|
void nas_ghost::clear() {
|
||||||
// do nothing if pointer is null
|
// do nothing if pointer is null
|
||||||
if (!ptr) {
|
if (!pointer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do clear pointer if destructor function pointer is null
|
// do clear pointer if destructor function pointer is null
|
||||||
if (!dtor_ptr) {
|
if (!destructor_function) {
|
||||||
type_name = "";
|
type_name = "";
|
||||||
ptr = nullptr;
|
pointer = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do destruction
|
// do destruction
|
||||||
dtor_ptr(ptr);
|
destructor_function(pointer);
|
||||||
type_name = "";
|
type_name = "";
|
||||||
ptr = nullptr;
|
pointer = nullptr;
|
||||||
dtor_ptr = nullptr;
|
destructor_function = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& out, const nas_ghost& ghost) {
|
std::ostream& operator<<(std::ostream& out, const nas_ghost& ghost) {
|
||||||
out << "<object " << ghost.get_ghost_name();
|
out << "<object " << ghost.get_ghost_name();
|
||||||
out << " at 0x" << std::hex;
|
out << " at 0x" << std::hex;
|
||||||
out << reinterpret_cast<u64>(ghost.ptr) << std::dec << ">";
|
out << reinterpret_cast<u64>(ghost.pointer) << std::dec << ">";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ std::ostream& operator<<(std::ostream& out, var& ref) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool var::objchk(const std::string& name) {
|
bool var::objchk(const std::string& name) {
|
||||||
return type==vm_obj && obj().type_name==name && obj().ptr;
|
return type==vm_obj && obj().type_name==name && obj().pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
var var::none() {
|
var var::none() {
|
||||||
|
@ -418,13 +418,13 @@ void gc::mark_context_root(std::vector<var>& bfs_queue) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// scan now running context, this context maybe related to coroutine or main
|
// scan now running context, this context maybe related to coroutine or main
|
||||||
for(var* i = rctx->stack; i<=rctx->top; ++i) {
|
for(var* i = running_context->stack; i<=running_context->top; ++i) {
|
||||||
if (i->type>vm_num) {
|
if (i->type>vm_num) {
|
||||||
bfs_queue.push_back(*i);
|
bfs_queue.push_back(*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bfs_queue.push_back(rctx->funcr);
|
bfs_queue.push_back(running_context->funcr);
|
||||||
bfs_queue.push_back(rctx->upvalr);
|
bfs_queue.push_back(running_context->upvalr);
|
||||||
bfs_queue.push_back(temp);
|
bfs_queue.push_back(temp);
|
||||||
|
|
||||||
if (!cort) {
|
if (!cort) {
|
||||||
|
@ -432,13 +432,13 @@ void gc::mark_context_root(std::vector<var>& bfs_queue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// coroutine is running, so scan main process stack from mctx
|
// coroutine is running, so scan main process stack from mctx
|
||||||
for(var* i = mctx.stack; i<=mctx.top; ++i) {
|
for(var* i = main_context.stack; i<=main_context.top; ++i) {
|
||||||
if (i->type>vm_num) {
|
if (i->type>vm_num) {
|
||||||
bfs_queue.push_back(*i);
|
bfs_queue.push_back(*i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bfs_queue.push_back(mctx.funcr);
|
bfs_queue.push_back(main_context.funcr);
|
||||||
bfs_queue.push_back(mctx.upvalr);
|
bfs_queue.push_back(main_context.upvalr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gc::mark_var(std::vector<var>& bfs_queue, var& value) {
|
void gc::mark_var(std::vector<var>& bfs_queue, var& value) {
|
||||||
|
@ -696,10 +696,10 @@ var gc::alloc(u8 type) {
|
||||||
|
|
||||||
void gc::ctxchg(nas_co& co) {
|
void gc::ctxchg(nas_co& co) {
|
||||||
// store running state to main context
|
// store running state to main context
|
||||||
mctx = *rctx;
|
main_context = *running_context;
|
||||||
|
|
||||||
// restore coroutine context state
|
// restore coroutine context state
|
||||||
*rctx = co.ctx;
|
*running_context = co.ctx;
|
||||||
|
|
||||||
// set coroutine pointer
|
// set coroutine pointer
|
||||||
cort = &co;
|
cort = &co;
|
||||||
|
@ -710,15 +710,15 @@ void gc::ctxchg(nas_co& co) {
|
||||||
|
|
||||||
void gc::ctxreserve() {
|
void gc::ctxreserve() {
|
||||||
// pc=0 means this coroutine is finished
|
// pc=0 means this coroutine is finished
|
||||||
cort->status = rctx->pc?
|
cort->status = running_context->pc?
|
||||||
nas_co::status::suspended:
|
nas_co::status::suspended:
|
||||||
nas_co::status::dead;
|
nas_co::status::dead;
|
||||||
|
|
||||||
// store running state to coroutine
|
// store running state to coroutine
|
||||||
cort->ctx = *rctx;
|
cort->ctx = *running_context;
|
||||||
|
|
||||||
// restore main context state
|
// restore main context state
|
||||||
*rctx = mctx;
|
*running_context = main_context;
|
||||||
|
|
||||||
// set coroutine pointer to nullptr
|
// set coroutine pointer to nullptr
|
||||||
cort = nullptr;
|
cort = nullptr;
|
||||||
|
|
|
@ -192,11 +192,12 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string type_name;
|
std::string type_name;
|
||||||
destructor dtor_ptr;
|
destructor destructor_function;
|
||||||
void* ptr;
|
void* pointer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
nas_ghost(): type_name(""), dtor_ptr(nullptr), ptr(nullptr) {}
|
nas_ghost():
|
||||||
|
type_name(""), destructor_function(nullptr), pointer(nullptr) {}
|
||||||
~nas_ghost() {clear();}
|
~nas_ghost() {clear();}
|
||||||
void set(const std::string&, destructor, void*);
|
void set(const std::string&, destructor, void*);
|
||||||
void clear();
|
void clear();
|
||||||
|
@ -290,14 +291,14 @@ const var nil = var::nil();
|
||||||
|
|
||||||
struct gc {
|
struct gc {
|
||||||
/* main context temporary storage */
|
/* main context temporary storage */
|
||||||
context mctx;
|
context main_context;
|
||||||
|
|
||||||
/* global storage */
|
/* global storage */
|
||||||
var* main_context_global = nullptr;
|
var* main_context_global = nullptr;
|
||||||
usize main_context_global_size = 0;
|
usize main_context_global_size = 0;
|
||||||
|
|
||||||
/* runtime context */
|
/* runtime context */
|
||||||
context* rctx = nullptr;
|
context* running_context = nullptr;
|
||||||
nas_co* cort = nullptr; // running coroutine
|
nas_co* cort = nullptr; // running coroutine
|
||||||
|
|
||||||
/* temporary space used in native/module functions */
|
/* temporary space used in native/module functions */
|
||||||
|
@ -331,7 +332,7 @@ struct gc {
|
||||||
i64 max_sweep_time = 0;
|
i64 max_sweep_time = 0;
|
||||||
|
|
||||||
void set(context* _ctx, var* _global, usize _size) {
|
void set(context* _ctx, var* _global, usize _size) {
|
||||||
rctx = _ctx;
|
running_context = _ctx;
|
||||||
main_context_global = _global;
|
main_context_global = _global;
|
||||||
main_context_global_size = _size;
|
main_context_global_size = _size;
|
||||||
}
|
}
|
||||||
|
@ -368,13 +369,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
var newstr(const char* buff) {
|
var newstr(const char* buff) {
|
||||||
var s=alloc(vm_str);
|
var s = alloc(vm_str);
|
||||||
s.str() = buff;
|
s.str() = buff;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
var newstr(const std::string& buff) {
|
var newstr(const std::string& buff) {
|
||||||
var s=alloc(vm_str);
|
var s = alloc(vm_str);
|
||||||
s.str() = buff;
|
s.str() = buff;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ void vm::valinfo(var& val) {
|
||||||
<< " val}"; break;
|
<< " val}"; break;
|
||||||
case vm_obj: std::clog << "| obj | <0x" << std::hex << p
|
case vm_obj: std::clog << "| obj | <0x" << std::hex << p
|
||||||
<< "> obj:0x"
|
<< "> obj:0x"
|
||||||
<< reinterpret_cast<u64>(val.obj().ptr)
|
<< reinterpret_cast<u64>(val.obj().pointer)
|
||||||
<< std::dec; break;
|
<< std::dec; break;
|
||||||
case vm_co: std::clog << "| co | <0x" << std::hex << p
|
case vm_co: std::clog << "| co | <0x" << std::hex << p
|
||||||
<< std::dec << "> coroutine"; break;
|
<< std::dec << "> coroutine"; break;
|
||||||
|
|
|
@ -84,12 +84,12 @@ var builtin_readdir(var* local, gc& ngc) {
|
||||||
}
|
}
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
WIN32_FIND_DATAA data;
|
WIN32_FIND_DATAA data;
|
||||||
if (!FindNextFileA(handle.obj().ptr,&data)) {
|
if (!FindNextFileA(handle.obj().pointer, &data)) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
return ngc.newstr(data.cFileName);
|
return ngc.newstr(data.cFileName);
|
||||||
#else
|
#else
|
||||||
dirent* p = readdir(static_cast<DIR*>(handle.obj().ptr));
|
dirent* p = readdir(static_cast<DIR*>(handle.obj().pointer));
|
||||||
return p? ngc.newstr(p->d_name):nil;
|
return p? ngc.newstr(p->d_name):nil;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue