- Linker.h/cpp:收集导出(仅 gvl 文件顶层 VAR_GLOBAL、声明顺序定槽、重复名拒绝) - VAR_EXTERNAL 接同一槽、类型一致;FB 实例必须先声明;字段存在性校验;函数调用图 DFS 环检测 - io.var 必须在 GVL;内建 TON/TOF/CTU 布局冻结;用户 FB 字段 = input/output/var(external 不是字段) - 函数名赋值 = 结果值写入(用例 13 约定);dump_symbols 打印 name kind type address file - linker_test:51 断言(用例 09/10/11/12/16/19 + line1/17 正例),ctest 7/7;20 用例扫描 15 绿 5 按期望拒
25 lines
810 B
CMake
25 lines
810 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)
|
|
|
|
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)
|