void ASTDrawer::appendNumberInfo_(const wchar_t format[], uint32_t number) { if (number != UINT32_MAX) { appendTreeLine_(); append_(format, number); append_(L"\n"); } }
const file_header* reader_writer::append(io::reader& ar, const file_path& name, compress_method method /* = cm_deflate */){ file_header h; h.method = method; h.name = name; h.flags = 0x800; h.external_attrs = 0; return append_(ar, h, ft_raw, m_imp.get()); }
void ASTDrawer::appendExpressionInfo_(const AST::Expression& node) { if (node.registerOffset != UINT32_MAX) { appendTreeLine_(); append_(L"Register : %d\n", node.registerOffset); } if (node.lvalue1 != UINT32_MAX) { appendTreeLine_(); if (node.flag & AST::FLAG_TABLE) { append_(L"Table key : %d\n", node.lvalue1); } else if (node.flag & AST::FLAG_GLOBAL) { append_(L"Global key : %d\n", node.lvalue1); } else if (node.flag & AST::FLAG_UPVALUE) { append_(L"Function level : %d\n", node.lvalue1); } } if (node.lvalue2 != UINT32_MAX) { appendTreeLine_(); if (node.flag & AST::FLAG_TABLE) { append_(L"Table value : %d\n", node.lvalue2); } else if (node.flag & AST::FLAG_UPVALUE) { append_(L"Register : %d\n", node.lvalue2); } } }
template<typename... Args> void append(const Args&... args) { append_({ args... }); }
void ASTDrawer::appendNewline_() { appendTreeLine_(); append_(L"\n"); }
void ASTDrawer::appendNewline_(const wchar_t string[]) { appendTreeLine_(); append_(string); append_(L"\n"); }
void ASTDrawer::appendStringInfo_(const wchar_t format[], const wchar_t string[]) { appendTreeLine_(); append_(format, string); append_(L"\n"); }
void ASTDrawer::appendBaseInfo_(const wchar_t nodeName[], const AST::Base& node) { appendTreeLine_(); append_(L"%s\n", nodeName); appendFlagInfo_(node); }
void ASTDrawer::appendFlagInfo_(const AST::Base& node) { if (node.flag == 0) { return; } appendTreeLine_(); append_(L"FLAG : "); if (node.flag & AST::FLAG_ERROR) { append_(L"ERROR "); } if (node.flag & AST::FLAG_LVALUE) { append_(L"LVALUE "); } if (node.flag & AST::FLAG_STORE) { append_(L"STORE "); } if (node.flag & AST::FLAG_NOLOAD) { append_(L"NOLOAD "); } if (node.flag & AST::FLAG_TABLE) { append_(L"TABLE "); } if (node.flag & AST::FLAG_GLOBAL) { append_(L"GLOBAL "); } if (node.flag & AST::FLAG_UPVALUE) { append_(L"UPVALUE "); } if (node.flag & AST::FLAG_INTVALUE) { append_(L"INTVALUE "); } if (node.flag & AST::FLAG_ARRAY) { append_(L"ARRAY "); } if (node.flag & AST::FLAG_TEMP) { append_(L"TEMP "); } if (node.flag & AST::FLAG_TEMPTABLE) { append_(L"TEMPTABLE "); } append_(L"\n"); }
template<typename T, typename... Args> void append(T& arg, Args&&... args) { append_(arg); append(args...); }
const file_header* reader_writer::append(io::read_map& ar, const file_header& h, file_type type /* = ft_raw */){ return append_(ar, h, type, m_imp.get()); }
const file_header* reader_writer::append(io::reader& ar, const file_header& h_, file_type type){ return append_(ar, h_, type, m_imp.get()); }