summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2021-04-01 16:11:51 +0800
committerLi Jin <dragon-fly@qq.com>2021-04-01 16:11:51 +0800
commit1ed40360d664d397e1178eb60cf8d3fbe0881edc (patch)
tree4af0f539b5c9c211d62ebc128da3fbbd4b98613f
parent98debe328b443078aee6994af61d4ed05ac434d6 (diff)
downloadyuescript-1ed40360d664d397e1178eb60cf8d3fbe0881edc.tar.gz
yuescript-1ed40360d664d397e1178eb60cf8d3fbe0881edc.tar.bz2
yuescript-1ed40360d664d397e1178eb60cf8d3fbe0881edc.zip
fix export assignment statement not working with local statement.
-rw-r--r--spec/inputs/export.yue7
-rw-r--r--src/lua/makefile2
-rw-r--r--src/yuescript/yue_compiler.cpp13
3 files changed, 19 insertions, 3 deletions
diff --git a/spec/inputs/export.yue b/spec/inputs/export.yue
index 085510e..9113508 100644
--- a/spec/inputs/export.yue
+++ b/spec/inputs/export.yue
@@ -77,3 +77,10 @@ _ = "#{with a
77_ = "#{a?.b}" 77_ = "#{a?.b}"
78_ = "#{a\b}" 78_ = "#{a\b}"
79_ = "#{class A}" 79_ = "#{class A}"
80
81local *
82v1 = 1
83export v2 = 2
84export v3 = class v4
85v5 = 5
86
diff --git a/src/lua/makefile b/src/lua/makefile
index 8e11fa3..ccd5315 100644
--- a/src/lua/makefile
+++ b/src/lua/makefile
@@ -61,7 +61,7 @@ else
61endif 61endif
62 62
63CC= gcc 63CC= gcc
64CFLAGS= -Wall -O2 $(MYCFLAGS) -fno-stack-protector -fno-common -march=native 64CFLAGS= -Wall -O2 $(MYCFLAGS) -fno-stack-protector -fno-common
65AR= ar rc 65AR= ar rc
66RANLIB= ranlib 66RANLIB= ranlib
67RM= rm -f 67RM= rm -f
diff --git a/src/yuescript/yue_compiler.cpp b/src/yuescript/yue_compiler.cpp
index f27a810..38456cc 100644
--- a/src/yuescript/yue_compiler.cpp
+++ b/src/yuescript/yue_compiler.cpp
@@ -59,7 +59,7 @@ inline std::string s(std::string_view sv) {
59 return std::string(sv); 59 return std::string(sv);
60} 60}
61 61
62const std::string_view version = "0.7.3"sv; 62const std::string_view version = "0.7.4"sv;
63const std::string_view extension = "yue"sv; 63const std::string_view extension = "yue"sv;
64 64
65class YueCompilerImpl { 65class YueCompilerImpl {
@@ -2343,7 +2343,16 @@ private:
2343 } 2343 }
2344 } else if (mode != LocalMode::None) { 2344 } else if (mode != LocalMode::None) {
2345 ClassDecl_t* classDecl = nullptr; 2345 ClassDecl_t* classDecl = nullptr;
2346 if (auto assignment = assignmentFrom(stmt)) { 2346 ast_ptr<false, ExpListAssign_t> assignment;
2347 if (auto exportNode = stmt->content.as<Export_t>()) {
2348 if (exportNode->assign) {
2349 assignment = stmt->new_ptr<ExpListAssign_t>();
2350 assignment->expList.set(exportNode->target);
2351 assignment->action.set(exportNode->assign);
2352 }
2353 }
2354 if (!assignment) assignment = assignmentFrom(stmt);
2355 if (assignment) {
2347 auto vars = getAssignVars(assignment); 2356 auto vars = getAssignVars(assignment);
2348 for (const auto& var : vars) { 2357 for (const auto& var : vars) {
2349 if (var.empty()) continue; 2358 if (var.empty()) continue;