Skip to content

Commit

Permalink
Added option to stop implicit returns on the root. (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
Liga authored Mar 12, 2024
1 parent b1661cc commit 4f399a1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/yue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ using namespace std::chrono_literals;
#include "linenoise.hpp"

#if not(defined YUE_NO_MACRO && defined YUE_COMPILER_ONLY)
#define _DEFER(code, line) std::shared_ptr<void> _defer_##line(nullptr, [&](auto) { code; })
#define _DEFER(code, line) std::shared_ptr<void> _defer_##line(nullptr, [&](auto) { \
code; \
})
#define DEFER(code) _DEFER(code, __LINE__)
extern "C" {
#include "lauxlib.h"
Expand Down Expand Up @@ -292,6 +294,7 @@ int main(int narg, const char** args) {
" -b Dump compile time (doesn't write output)\n"
" -g Dump global variables used in NAME LINE COLUMN\n"
" -l Write line numbers from source codes\n"
" -j Disable implicit return at end of file\n"
" -c Reserve comments before statement from source codes\n"
#ifndef YUE_NO_WATCHER
" -w path Watch changes and compile every file under directory\n"
Expand Down Expand Up @@ -597,6 +600,8 @@ int main(int narg, const char** args) {
config.reserveLineNumber = true;
} else if (arg == "-c"sv) {
config.reserveComment = true;
} else if (arg == "-j"sv) {
config.implicitReturnRoot = false;
} else if (arg == "-p"sv) {
writeToFile = false;
} else if (arg == "-g"sv) {
Expand Down Expand Up @@ -632,7 +637,7 @@ int main(int narg, const char** args) {
#else
std::cout << "Error: -w is not supported\n"sv;
return 1;
#endif // YUE_NO_WATCHER
#endif // YUE_NO_WATCHER
} else if (arg.size() > 2 && arg.substr(0, 2) == "--"sv && arg.substr(2, 1) != "-"sv) {
auto argStr = arg.substr(2);
yue::Utils::trim(argStr);
Expand Down Expand Up @@ -698,7 +703,7 @@ int main(int narg, const char** args) {
#ifndef YUE_COMPILER_ONLY
return compileFile(fs::absolute(file.first), config, fullWorkPath, fullTargetPath, minify, rewrite);
#else
return compileFile(fs::absolute(file.first), config, fullWorkPath, fullTargetPath);
return compileFile(fs::absolute(file.first), config, fullWorkPath, fullTargetPath);
#endif // YUE_COMPILER_ONLY
});
results.push_back(std::move(task));
Expand Down

0 comments on commit 4f399a1

Please sign in to comment.