🐛 fix bug that `make test` failed
This commit is contained in:
parent
8293f85c5b
commit
27ceeb517d
36
main.cpp
36
main.cpp
|
@ -12,14 +12,14 @@
|
|||
#include "nasal_dbg.h"
|
||||
#include <unordered_map>
|
||||
|
||||
const u32 VM_LEXINFO =0x01;
|
||||
const u32 VM_ASTINFO =0x02;
|
||||
const u32 VM_CODEINFO=0x04;
|
||||
const u32 VM_EXECTIME=0x08;
|
||||
const u32 VM_EXEC =0x10;
|
||||
const u32 VM_DETAIL =0x20;
|
||||
const u32 VM_DEBUG =0x40;
|
||||
const u32 VM_OPTIMIZE=0x80;
|
||||
const u32 VM_TOKEN =0x01;
|
||||
const u32 VM_AST =0x02;
|
||||
const u32 VM_CODE =0x04;
|
||||
const u32 VM_TIME =0x08;
|
||||
const u32 VM_EXEC =0x10;
|
||||
const u32 VM_DETAIL=0x20;
|
||||
const u32 VM_DEBUG =0x40;
|
||||
const u32 VM_OPT =0x80;
|
||||
|
||||
void help()
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ void execute(const string& file,const std::vector<string>& argv,const u32 cmd)
|
|||
|
||||
// lexer scans file to get tokens
|
||||
lexer.scan(file);
|
||||
if(cmd&VM_LEXINFO)
|
||||
if(cmd&VM_TOKEN)
|
||||
lexer.print();
|
||||
|
||||
// parser gets lexer's token list to compile
|
||||
|
@ -100,20 +100,20 @@ void execute(const string& file,const std::vector<string>& argv,const u32 cmd)
|
|||
// linker gets parser's ast and load import files to this ast
|
||||
linker.link(parse,file,cmd&VM_DETAIL);
|
||||
// optimizer does simple optimization on ast
|
||||
if(cmd&VM_OPTIMIZE)
|
||||
if(cmd&VM_OPT)
|
||||
optimize(parse.ast());
|
||||
if(cmd&VM_ASTINFO)
|
||||
if(cmd&VM_AST)
|
||||
parse.print();
|
||||
|
||||
// code generator gets parser's ast and linker's import file list to generate code
|
||||
gen.compile(parse,linker);
|
||||
if(cmd&VM_CODEINFO)
|
||||
if(cmd&VM_CODE)
|
||||
gen.print();
|
||||
|
||||
// run
|
||||
if(cmd&VM_DEBUG)
|
||||
nasal_dbg(nerr).run(gen,linker,argv);
|
||||
else if(cmd&VM_EXECTIME)
|
||||
else if(cmd&VM_TIME)
|
||||
{
|
||||
auto start=std::chrono::high_resolution_clock::now();
|
||||
vm.run(gen,linker,argv,cmd&VM_DETAIL);
|
||||
|
@ -145,13 +145,13 @@ i32 main(i32 argc,const char* argv[])
|
|||
return 0;
|
||||
}
|
||||
std::unordered_map<string,u32> cmdlst={
|
||||
{"--lex",VM_LEXINFO},{"-l",VM_LEXINFO},
|
||||
{"--ast",VM_ASTINFO},{"-a",VM_ASTINFO},
|
||||
{"--code",VM_CODEINFO},{"-c",VM_CODEINFO},
|
||||
{"--lex",VM_TOKEN},{"-l",VM_TOKEN},
|
||||
{"--ast",VM_AST},{"-a",VM_AST},
|
||||
{"--code",VM_CODE},{"-c",VM_CODE},
|
||||
{"--exec",VM_EXEC},{"-e",VM_EXEC},
|
||||
{"--time",VM_EXECTIME|VM_EXEC},{"-t",VM_EXECTIME|VM_EXEC},
|
||||
{"--time",VM_TIME|VM_EXEC},{"-t",VM_TIME|VM_EXEC},
|
||||
{"--detail",VM_DETAIL|VM_EXEC},{"-d",VM_DETAIL|VM_EXEC},
|
||||
{"--optimize",VM_OPTIMIZE},{"-o",VM_OPTIMIZE},
|
||||
{"--optimize",VM_OPT},{"-o",VM_OPT},
|
||||
{"--debug",VM_DEBUG},{"-dbg",VM_DEBUG}
|
||||
};
|
||||
u32 cmd=0;
|
||||
|
|
94
makefile
94
makefile
|
@ -15,58 +15,58 @@ SRC=\
|
|||
nasal_dbg.h\
|
||||
nasal.h
|
||||
|
||||
CPPSTANDARD=-std=c++11
|
||||
STD=-std=c++11
|
||||
|
||||
nasal:$(SRC)
|
||||
$(CXX) $(CPPSTANDARD) -O3 main.cpp -o nasal -fno-exceptions -ldl -Wshadow -Wall
|
||||
$(CXX) $(STD) -O3 main.cpp -o nasal -fno-exceptions -ldl -Wshadow -Wall
|
||||
nasal.exe:$(SRC)
|
||||
$(CXX) $(CPPSTANDARD) -O3 main.cpp -o nasal.exe -fno-exceptions -Wshadow -Wall -static
|
||||
$(CXX) $(STD) -O3 main.cpp -o nasal.exe -fno-exceptions -Wshadow -Wall -static
|
||||
|
||||
stable-release:$(SRC)
|
||||
$(CXX) $(CPPSTANDARD) -O2 main.cpp -o nasal -fno-exceptions -ldl -Wshadow -Wall
|
||||
$(CXX) $(STD) -O2 main.cpp -o nasal -fno-exceptions -ldl -Wshadow -Wall
|
||||
stable-release-mingw:$(SRC)
|
||||
$(CXX) $(CPPSTANDARD) -O2 main.cpp -o nasal.exe -fno-exceptions -Wshadow -Wall -static
|
||||
$(CXX) $(STD) -O2 main.cpp -o nasal.exe -fno-exceptions -Wshadow -Wall -static
|
||||
|
||||
test:nasal
|
||||
@ ./nasal -op -e test/ascii-art.nas
|
||||
@ ./nasal -op -c test/auto_crash.nas
|
||||
@ ./nasal -op -a -c test/bf.nas
|
||||
@ ./nasal -op -a -c test/bfcolored.nas
|
||||
@ ./nasal -op -a -c test/bfconvertor.nas
|
||||
@ ./nasal -op -e -d test/bfs.nas
|
||||
@ ./nasal -op -t test/bigloop.nas
|
||||
@ ./nasal -op -e test/bp.nas
|
||||
@ ./nasal -op -e -d test/calc.nas
|
||||
@ ./nasal -op -e test/choice.nas
|
||||
@ ./nasal -op -e test/class.nas
|
||||
@ ./nasal -op -d test/coroutine.nas
|
||||
@ ./nasal -op -e test/diff.nas
|
||||
-@ ./nasal -op -d test/exception.nas
|
||||
@ ./nasal -op -t -d test/fib.nas
|
||||
@ ./nasal -op -e test/filesystem.nas
|
||||
@ ./nasal -op -e -d test/hexdump.nas
|
||||
@ ./nasal -op -c test/httptest.nas
|
||||
@ ./nasal -op -e test/json.nas
|
||||
@ ./nasal -op -e test/leetcode1319.nas
|
||||
@ ./nasal -op -e -d test/lexer.nas
|
||||
@ ./nasal -op -e -d test/life.nas
|
||||
@ ./nasal -op -t test/loop.nas
|
||||
@ ./nasal -op -t -d test/mandel.nas
|
||||
@ ./nasal -op -t -d test/mandelbrot.nas
|
||||
@ ./nasal -op -t -d test/md5.nas
|
||||
@ ./nasal -op -t -d test/md5compare.nas
|
||||
-@ ./nasal -op -d test/module_test.nas
|
||||
@ ./nasal -op -e test/nasal_test.nas
|
||||
@ ./nasal -op -c test/occupation.nas
|
||||
@ ./nasal -op -t -d test/pi.nas
|
||||
@ ./nasal -op -c test/ppmgen.nas
|
||||
@ ./nasal -op -t -d test/prime.nas
|
||||
@ ./nasal -op -e test/qrcode.nas
|
||||
@ ./nasal -op -t -d test/quick_sort.nas
|
||||
@ ./nasal -op -e test/scalar.nas hello world
|
||||
-@ ./nasal -op -c -t test/snake.nas
|
||||
@ ./nasal -op -c -e test/trait.nas
|
||||
-@ ./nasal -op -c -t test/tetris.nas
|
||||
@ ./nasal -op -c -t -d test/turingmachine.nas
|
||||
@ ./nasal -op -c -t -d test/ycombinator.nas
|
||||
@ ./nasal -op -d test/wavecollapse.nas
|
||||
@ ./nasal -o -e test/ascii-art.nas
|
||||
@ ./nasal -o -c test/auto_crash.nas
|
||||
@ ./nasal -o -a -c test/bf.nas
|
||||
@ ./nasal -o -a -c test/bfcolored.nas
|
||||
@ ./nasal -o -a -c test/bfconvertor.nas
|
||||
@ ./nasal -o -e -d test/bfs.nas
|
||||
@ ./nasal -o -t test/bigloop.nas
|
||||
@ ./nasal -o -e test/bp.nas
|
||||
@ ./nasal -o -e -d test/calc.nas
|
||||
@ ./nasal -o -e test/choice.nas
|
||||
@ ./nasal -o -e test/class.nas
|
||||
@ ./nasal -o -d test/coroutine.nas
|
||||
@ ./nasal -o -e test/diff.nas
|
||||
-@ ./nasal -o -d test/exception.nas
|
||||
@ ./nasal -o -t -d test/fib.nas
|
||||
@ ./nasal -o -e test/filesystem.nas
|
||||
@ ./nasal -o -e -d test/hexdump.nas
|
||||
@ ./nasal -o -c test/httptest.nas
|
||||
@ ./nasal -o -e test/json.nas
|
||||
@ ./nasal -o -e test/leetcode1319.nas
|
||||
@ ./nasal -o -e -d test/lexer.nas
|
||||
@ ./nasal -o -e -d test/life.nas
|
||||
@ ./nasal -o -t test/loop.nas
|
||||
@ ./nasal -o -t -d test/mandel.nas
|
||||
@ ./nasal -o -t -d test/mandelbrot.nas
|
||||
@ ./nasal -o -t -d test/md5.nas
|
||||
@ ./nasal -o -t -d test/md5compare.nas
|
||||
-@ ./nasal -o -d test/module_test.nas
|
||||
@ ./nasal -o -e test/nasal_test.nas
|
||||
@ ./nasal -o -c test/occupation.nas
|
||||
@ ./nasal -o -t -d test/pi.nas
|
||||
@ ./nasal -o -c test/ppmgen.nas
|
||||
@ ./nasal -o -t -d test/prime.nas
|
||||
@ ./nasal -o -e test/qrcode.nas
|
||||
@ ./nasal -o -t -d test/quick_sort.nas
|
||||
@ ./nasal -o -e test/scalar.nas hello world
|
||||
-@ ./nasal -o -c -t test/snake.nas
|
||||
@ ./nasal -o -c -e test/trait.nas
|
||||
-@ ./nasal -o -c -t test/tetris.nas
|
||||
@ ./nasal -o -c -t -d test/turingmachine.nas
|
||||
@ ./nasal -o -c -t -d test/ycombinator.nas
|
||||
@ ./nasal -o -d test/wavecollapse.nas
|
|
@ -138,8 +138,8 @@ public:
|
|||
|
||||
void nasal_vm::init(
|
||||
const std::vector<string>& strs,
|
||||
const std::vector<f64>& nums,
|
||||
const std::vector<opcode>& code,
|
||||
const std::vector<f64>& nums,
|
||||
const std::vector<opcode>& code,
|
||||
const std::vector<string>& filenames,
|
||||
const std::vector<string>& argv)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue