diff --git a/src/compiler.h b/src/compiler.h index ea73bf3c..e9415f0d 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -26,18 +26,6 @@ struct Loop { Loop(bool forLoop, int start) : forLoop(forLoop), start(start) {} }; -#define ExprCommaSplitArgs(end) \ - int ARGC = 0; \ - do { \ - matchNewLines(); \ - if (peek() == TK(end)) break; \ - EXPR(); \ - ARGC++; \ - matchNewLines(); \ - } while (match(TK(","))); \ - matchNewLines(); \ - consume(TK(end)); - class Compiler { public: std::unique_ptr parser; @@ -501,7 +489,16 @@ __LISTCOMP: } void exprCall() { - ExprCommaSplitArgs(")"); + int ARGC = 0; + do { + matchNewLines(); + if (peek() == TK(")")) break; + EXPR(); + ARGC++; + matchNewLines(); + } while (match(TK(","))); + matchNewLines(); + consume(TK(")")); emitCode(OP_CALL, ARGC); } diff --git a/src/pocketpy.h b/src/pocketpy.h index 36d03468..062b5ad0 100644 --- a/src/pocketpy.h +++ b/src/pocketpy.h @@ -449,6 +449,9 @@ extern "C" { __EXPORT void registerModule(VM* vm, const char* name, const char* source){ _Code code = compile(vm, source, name + _Str(".py")); - vm->registerCompiledModule(name, code); + if(code != nullptr){ + PyVar _m = vm->newModule(name); + vm->exec(code, {}, _m); + } } } \ No newline at end of file diff --git a/src/vm.h b/src/vm.h index f0d6b307..537cc79e 100644 --- a/src/vm.h +++ b/src/vm.h @@ -633,11 +633,6 @@ public: return 0; } - void registerCompiledModule(_Str name, _Code code){ - PyVar _m = newModule(name); - exec(code, {}, _m); - } - /***** Error Reporter *****/ private: void _error(const _Str& name, const _Str& msg){