diff --git a/include/pocketpy/pocketpy.h b/include/pocketpy/pocketpy.h index 8d3468d3..fcb3c5da 100644 --- a/include/pocketpy/pocketpy.h +++ b/include/pocketpy/pocketpy.h @@ -130,9 +130,9 @@ PK_API void py_watchdog_begin(py_i64 timeout); PK_API void py_watchdog_end(); /// Bind a compile-time function via "decl-based" style. -PK_API void py_compiletime_bind(const char* sig, py_CFunction f); -/// Find a compile-time function by name. -PK_API py_ItemRef py_compiletime_getfunc(py_Name name); +PK_API void py_macrobind(const char* sig, py_CFunction f); +/// Get a compile-time function by name. +PK_API py_ItemRef py_macroget(py_Name name); /// Get the current source location of the frame. PK_API const char* py_Frame_sourceloc(py_Frame* frame, int* lineno); diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c index 68919618..b3935b80 100644 --- a/src/compiler/compiler.c +++ b/src/compiler/compiler.c @@ -1935,14 +1935,12 @@ static Error* exprCall(Compiler* self) { int line = prev()->line; if(callable->vt->is_name) { NameExpr* ne = (NameExpr*)callable; - if(ne->scope == NAME_GLOBAL) { - py_ItemRef func = py_compiletime_getfunc(ne->name); - if(func != NULL) { - py_StackRef p0 = py_peek(0); - err = exprCompileTimeCall(self, func, line); - if(err != NULL) py_clearexc(p0); - return err; - } + py_ItemRef func = py_macroget(ne->name); + if(func != NULL) { + py_StackRef p0 = py_peek(0); + err = exprCompileTimeCall(self, func, line); + if(err != NULL) py_clearexc(p0); + return err; } } diff --git a/src/public/values.c b/src/public/values.c index 38ac4038..590a29ac 100644 --- a/src/public/values.c +++ b/src/public/values.c @@ -95,14 +95,14 @@ void py_bind(py_Ref obj, const char* sig, py_CFunction f) { py_pop(); } -void py_compiletime_bind(const char* sig, py_CFunction f) { +void py_macrobind(const char* sig, py_CFunction f) { py_Ref tmp = py_pushtmp(); py_Name name = py_newfunction(tmp, sig, f, NULL, 0); NameDict__set(&pk_current_vm->compile_time_funcs, name, tmp); py_pop(); } -PK_API py_ItemRef py_compiletime_getfunc(py_Name name) { +py_ItemRef py_macroget(py_Name name) { NameDict* d = &pk_current_vm->compile_time_funcs; if(d->length == 0) return NULL; return NameDict__try_get(d, name);