mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-13 13:30:40 +00:00
Small follow code cleanup for Repl.cpp
This commit is contained in:
parent
3ba0bdf708
commit
f3468be92b
1 changed files with 13 additions and 13 deletions
26
CLI/Repl.cpp
26
CLI/Repl.cpp
|
@ -14,8 +14,8 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum class CompileFormat
|
enum class CompileFormat
|
||||||
|
@ -404,12 +404,7 @@ static bool compileFile(const char* name, CompileFormat format)
|
||||||
printf("%s", bcb.dumpEverything().c_str());
|
printf("%s", bcb.dumpEverything().c_str());
|
||||||
break;
|
break;
|
||||||
case CompileFormat::Binary:
|
case CompileFormat::Binary:
|
||||||
#ifdef _WIN32
|
fwrite(bcb.getBytecode().data(), 1, bcb.getBytecode().size(), stdout);
|
||||||
_setmode(_fileno(stdout), _O_BINARY);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string Bytecode = bcb.getBytecode();
|
|
||||||
fwrite(Bytecode.c_str(), 1, Bytecode.size(), stdout);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,13 +465,16 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
|
|
||||||
if (argc >= 2 && strncmp(argv[1], "--compile", strlen("--compile")) == 0)
|
if (argc >= 2 && strncmp(argv[1], "--compile", strlen("--compile")) == 0)
|
||||||
{
|
{
|
||||||
CompileFormat format = CompileFormat::Default;
|
CompileFormat format = CompileFormat::Default;
|
||||||
|
|
||||||
if (strcmp(argv[1], "--compile=binary") == 0)
|
if (strcmp(argv[1], "--compile=binary") == 0)
|
||||||
{
|
|
||||||
format = CompileFormat::Binary;
|
format = CompileFormat::Binary;
|
||||||
}
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (format == CompileFormat::Binary)
|
||||||
|
_setmode(_fileno(stdout), _O_BINARY);
|
||||||
|
#endif
|
||||||
|
|
||||||
int failed = 0;
|
int failed = 0;
|
||||||
|
|
||||||
|
@ -488,7 +486,9 @@ int main(int argc, char** argv)
|
||||||
if (isDirectory(argv[i]))
|
if (isDirectory(argv[i]))
|
||||||
{
|
{
|
||||||
traverseDirectory(argv[i], [&](const std::string& name) {
|
traverseDirectory(argv[i], [&](const std::string& name) {
|
||||||
if (name.length() > 4 && name.rfind(".lua") == name.length() - 4)
|
if (name.length() > 5 && name.rfind(".luau") == name.length() - 5)
|
||||||
|
failed += !compileFile(name.c_str(), format);
|
||||||
|
else if (name.length() > 4 && name.rfind(".lua") == name.length() - 4)
|
||||||
failed += !compileFile(name.c_str(), format);
|
failed += !compileFile(name.c_str(), format);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue