Skip to content

Commit 4f399a1

Browse files
author
Liga
authored
Added option to stop implicit returns on the root. (#164)
1 parent b1661cc commit 4f399a1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/yue.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ using namespace std::chrono_literals;
3131
#include "linenoise.hpp"
3232

3333
#if not(defined YUE_NO_MACRO && defined YUE_COMPILER_ONLY)
34-
#define _DEFER(code, line) std::shared_ptr<void> _defer_##line(nullptr, [&](auto) { code; })
34+
#define _DEFER(code, line) std::shared_ptr<void> _defer_##line(nullptr, [&](auto) { \
35+
code; \
36+
})
3537
#define DEFER(code) _DEFER(code, __LINE__)
3638
extern "C" {
3739
#include "lauxlib.h"
@@ -292,6 +294,7 @@ int main(int narg, const char** args) {
292294
" -b Dump compile time (doesn't write output)\n"
293295
" -g Dump global variables used in NAME LINE COLUMN\n"
294296
" -l Write line numbers from source codes\n"
297+
" -j Disable implicit return at end of file\n"
295298
" -c Reserve comments before statement from source codes\n"
296299
#ifndef YUE_NO_WATCHER
297300
" -w path Watch changes and compile every file under directory\n"
@@ -597,6 +600,8 @@ int main(int narg, const char** args) {
597600
config.reserveLineNumber = true;
598601
} else if (arg == "-c"sv) {
599602
config.reserveComment = true;
603+
} else if (arg == "-j"sv) {
604+
config.implicitReturnRoot = false;
600605
} else if (arg == "-p"sv) {
601606
writeToFile = false;
602607
} else if (arg == "-g"sv) {
@@ -632,7 +637,7 @@ int main(int narg, const char** args) {
632637
#else
633638
std::cout << "Error: -w is not supported\n"sv;
634639
return 1;
635-
#endif // YUE_NO_WATCHER
640+
#endif // YUE_NO_WATCHER
636641
} else if (arg.size() > 2 && arg.substr(0, 2) == "--"sv && arg.substr(2, 1) != "-"sv) {
637642
auto argStr = arg.substr(2);
638643
yue::Utils::trim(argStr);
@@ -698,7 +703,7 @@ int main(int narg, const char** args) {
698703
#ifndef YUE_COMPILER_ONLY
699704
return compileFile(fs::absolute(file.first), config, fullWorkPath, fullTargetPath, minify, rewrite);
700705
#else
701-
return compileFile(fs::absolute(file.first), config, fullWorkPath, fullTargetPath);
706+
return compileFile(fs::absolute(file.first), config, fullWorkPath, fullTargetPath);
702707
#endif // YUE_COMPILER_ONLY
703708
});
704709
results.push_back(std::move(task));

0 commit comments

Comments
 (0)