|
libxr
1.0
Want to be the best embedded framework
|
共享编译期后端,把前端事件整理成最终字节流和参数表。 / Shared compile-time backend that turns frontend events into the final byte stream plus argument table. More...
#include <format_compile.hpp>
Data Structures | |
| struct | ResultData |
| 当前后端实例产出的最终精确尺寸编译格式 / Final exact-size compiled format produced by this backend instance More... | |
| struct | ScratchBuilder |
| 由前端文本/字段事件直接喂给的单遍临时构建器。 / One-pass scratch builder fed directly by frontend text/field events. More... | |
Static Public Member Functions | |
| static consteval auto | Compile () |
| 把一个前端编译成最终字节流、参数表和 writer 摘要。 / Compiles one frontend into the final byte stream, argument table, and writer profile. | |
Private Types | |
| using | Error = typename Frontend::ErrorType |
| template<size_t BlobBytes, size_t ArgCount> | |
| using | Result = ResultData<BlobBytes, ArgCount> |
Static Private Member Functions | |
| static consteval void | EmitByte (auto &data, size_t &out, uint8_t value) |
| 向临时或最终字节缓冲区追加一个原始字节 / Append one raw byte into a scratch or final byte buffer | |
| template<typename T > | |
| static consteval void | EmitNative (auto &data, size_t &out, T value) |
| 向临时或最终字节缓冲区追加一个按本机字节序编码的 POD 值 / Append one native-endian POD value into a scratch or final byte buffer | |
| template<typename T > | |
| static consteval T | ReadNative (const auto &data, size_t &pos) |
| 从临时字节缓冲区读取一个按本机字节序编码的 POD 值 / Read one native-endian POD value from a scratch byte buffer | |
| static consteval auto | Failed (Error error) |
| 构造只携带编译错误的最小失败结果。 / Builds the minimal failed result carrying only the compile error. | |
| static consteval FormatProfile | ProfileForOp (FormatOp op) |
| 指出某个操作码族需要打开哪一个 writer-profile 位。 / Says which writer-profile bit one opcode family needs. | |
| static consteval FormatOp | FastFieldOp (const FormatField &field) |
| 为一个字段选择仍能正确打印它的最小操作码。 / Chooses the smallest opcode that can still print this field correctly. | |
| static consteval bool | IsRawIntegerField (const FormatField &field) |
| 判断字段是否满足裸整数快路径条件。 / Tests whether one field matches the raw integer fast-path gate. | |
| static consteval bool | IsRawTextField (const FormatField &field) |
| 判断字段是否满足裸文本快路径条件。 / Tests whether one field matches the raw text fast-path gate. | |
Static Private Attributes | |
| static constexpr size_t | inline_text_limit = 2 * sizeof(size_t) - 1 |
| 超过该长度后,字面文本会从内嵌模式切换为 TextRef / Maximum inline literal size before the backend spills to TextRef. | |
| static constexpr size_t | max_code_bytes = 3 * Frontend::SourceSize() + 1 |
| static constexpr size_t | max_text_pool_bytes = Frontend::SourceSize() |
| static constexpr size_t | max_arg_count = Frontend::SourceSize() |
| static constexpr uint8_t | unspecified_precision = std::numeric_limits<uint8_t>::max() |
共享编译期后端,把前端事件整理成最终字节流和参数表。 / Shared compile-time backend that turns frontend events into the final byte stream plus argument table.
Frontend contract: The frontend must provide the members using ErrorType, static constexpr const char* SourceData(), static constexpr size_t SourceSize(), and static consteval ErrorType Walk(visitor). 前端协议: 前端必须提供如下成员:using ErrorType、static constexpr const char* SourceData()、static constexpr size_t SourceSize()、以及 static consteval ErrorType Walk(visitor)。
Walk(visitor) must emit source-ordered events through:
The backend only walks the frontend once. During that single walk it collects:
Then it packs those scratch buffers into the final exact-size result. 这个后端只遍历前端一次。那一遍里会同时收集:
最后再把这些临时缓冲收拢成精确尺寸的最终结果。
Definition at line 51 of file format_compile.hpp.
|
private |
Definition at line 58 of file format_compile.hpp.
|
private |
Definition at line 86 of file format_compile.hpp.
|
inlinestaticnodiscardconsteval |
把一个前端编译成最终字节流、参数表和 writer 摘要。 / Compiles one frontend into the final byte stream, argument table, and writer profile.
Definition at line 545 of file format_compile.hpp.
|
inlinestaticconstevalprivate |
向临时或最终字节缓冲区追加一个原始字节 / Append one raw byte into a scratch or final byte buffer
| data | 目标字节缓冲区 / Target byte buffer |
| out | 当前写位置;会前进一个字节 / Current write position; advanced by one byte |
| value | 待追加的字节值 / Byte value to append |
Definition at line 115 of file format_compile.hpp.
|
inlinestaticconstevalprivate |
向临时或最终字节缓冲区追加一个按本机字节序编码的 POD 值 / Append one native-endian POD value into a scratch or final byte buffer
| T | 待编码的 POD 类型 / POD type to encode |
| data | 目标字节缓冲区 / Target byte buffer |
| out | 当前写位置;会前进 sizeof(T) / Current write position; advanced by sizeof(T) |
| value | 待追加的 POD 值 / POD value to append |
Definition at line 130 of file format_compile.hpp.
|
inlinestaticnodiscardconstevalprivate |
构造只携带编译错误的最小失败结果。 / Builds the minimal failed result carrying only the compile error.
| error | Compile-time failure category. / 编译期失败类别。 |
Definition at line 165 of file format_compile.hpp.
|
inlinestaticnodiscardconstevalprivate |
为一个字段选择仍能正确打印它的最小操作码。 / Chooses the smallest opcode that can still print this field correctly.
Definition at line 210 of file format_compile.hpp.
|
inlinestaticnodiscardconstevalprivate |
判断字段是否满足裸整数快路径条件。 / Tests whether one field matches the raw integer fast-path gate.
Definition at line 277 of file format_compile.hpp.
|
inlinestaticnodiscardconstevalprivate |
判断字段是否满足裸文本快路径条件。 / Tests whether one field matches the raw text fast-path gate.
Definition at line 287 of file format_compile.hpp.
|
inlinestaticnodiscardconstevalprivate |
指出某个操作码族需要打开哪一个 writer-profile 位。 / Says which writer-profile bit one opcode family needs.
| op | 待分类的操作码 / Opcode to classify |
None / Required narrow-path profile bit, or None when no narrow path is needed Definition at line 179 of file format_compile.hpp.
|
inlinestaticnodiscardconstevalprivate |
从临时字节缓冲区读取一个按本机字节序编码的 POD 值 / Read one native-endian POD value from a scratch byte buffer
| T | 待读取的 POD 类型 / POD type to decode |
| data | 源字节缓冲区 / Source byte buffer |
| pos | 当前读取位置;会前进 sizeof(T) / Current read position; advanced by sizeof(T) |
Definition at line 149 of file format_compile.hpp.
|
staticconstexprprivate |
超过该长度后,字面文本会从内嵌模式切换为 TextRef / Maximum inline literal size before the backend spills to TextRef.
Definition at line 92 of file format_compile.hpp.
|
staticconstexprprivate |
Definition at line 105 of file format_compile.hpp.
|
staticconstexprprivate |
Definition at line 103 of file format_compile.hpp.
|
staticconstexprprivate |
Definition at line 104 of file format_compile.hpp.
|
staticconstexprprivate |
Definition at line 106 of file format_compile.hpp.