From 65f6026e64fbbc44661b4af63e43dd5717780784 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 9 Nov 2022 23:16:20 +0800 Subject: [PATCH] some fix --- src/compiler.h | 23 ++++++++++------------- src/pocketpy.h | 5 ++++- src/vm.h | 5 ----- 3 files changed, 14 insertions(+), 19 deletions(-) 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){