- Codegen.h/cpp:帧寄存器(0 起声明序)、常量表、函数表、小端映像拼装 - 切片 1 范围:PROGRAM 标量 + 字面量 LOADK + 变量 MOVE + RET;其余构造报 codegen error - codegen_test:23 断言(用例 01 空 MAIN 出 RET、02 LOADK r0/r1 + 常量表),ctest 9/9
27 lines
872 B
CMake
27 lines
872 B
CMake
# CMake最低版本
|
|
cmake_minimum_required(VERSION 3.21)
|
|
|
|
# 工程名、版本号、工程描述
|
|
project(Compiler
|
|
VERSION 0.1
|
|
DESCRIPTION "ST / toml 编译器")
|
|
|
|
# 词法、语法、符号表、类型检查、codegen、链接都留在 compiler 一个库里
|
|
add_library(compiler STATIC
|
|
./src/Lexer.cpp
|
|
./src/Project.cpp
|
|
./src/Parser.cpp
|
|
./src/Linker.cpp
|
|
./src/Typecheck.cpp
|
|
./src/Codegen.cpp)
|
|
|
|
target_include_directories(compiler PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
|
target_include_directories(compiler PRIVATE ${CMAKE_SOURCE_DIR}/third_party/tomlplusplus/include)
|
|
target_link_libraries(compiler PUBLIC isa)
|
|
|
|
# 可执行入口:STCompiler <project.toml> -o <name>.stb
|
|
add_executable(STCompiler
|
|
./src/main.cpp)
|
|
|
|
target_link_libraries(STCompiler PRIVATE compiler)
|