#include <tasm-file.h>
Inheritance diagram for VM::AssemblerFile_Plaintext:
Public Member Functions | |
AssemblerFile_Plaintext () | |
Create "empty" file; use ParseFile() to read content. | |
~AssemblerFile_Plaintext () | |
Destroy all the content. | |
int | ParseFile (const TLString &fname, SError &error, uint32 file_num) |
Read in a file; see base class. [overriding virtual]. | |
int | WriteFile (const TLString &fname, SError &error) |
Write file; see base class. [overriding virtual]. | |
int | WriteFunctionProgram (FILE *fp, ProgramStorage::Function *pfunc) |
ONLY for debugging:. | |
Protected Member Functions | |
void | _LexNextToken () |
Get next token and store it in the lookahead token *tok. | |
TextAsmScanner::TokID | _CurrTokID () |
Return current token ID, properly casted. | |
void | _ExpectError (const char *str) |
Report parse error (expected something else). Use location in *tok. | |
void | _AlreadySetError () |
Report error because current property is already set. | |
void | _LocFirstDefError (const SCLocation &loc) |
Report "this is the location of the first definition" error. | |
VarType | _ParseVarType (const TextAsmScanner::Token::Type *t) |
Parse a TextAsmScanner::Token::Type into a VarType. | |
FuncType | _ParseFuncType (char ftype) |
Parse a function type ID (func/meth/vmeth). | |
void | _SkipUntilPop (uint32 num, TextAsmScanner::TokID skip_a, TextAsmScanner::TokID skip_b=TextAsmScanner::T_EOF) |
NamespaceInfo * | _CheckNspcNameKnown (NamespaceInfo *parent, const TLString &name) |
Check if passed name is already known as child of *parent. | |
void | _ParseInfoSection () |
Parse the "info:" section. | |
void | _ParseSymbolSection () |
Parse the "symbols:" section. | |
void | _ParseLocationSection () |
Parse the "locations:" section. | |
void | _ParseProgramSection () |
Parse the "program:" instructions section. | |
void | _ParseSymbols_Namespace (NamespaceInfo *parent) |
Parse namespace block in symbols section. | |
void | _ParseSymbols_Class (NamespaceInfo *parent) |
Parse class block in symbols section. | |
void | _ParseSymbols_Symbols (NamespaceInfo *parent) |
Parse symbol (function provide) block in symbols section. | |
void | _ParseSymbols_Global () |
Parse {p,v}global block in symbols section. | |
void | _ParseSymbols_Class_Base (ClassInfo *parent) |
Parse "base" block in class spec in symbols section. | |
void | _ParseSymbols_Class_VTable (ClassInfo *parent) |
Parse "vtable" block in class spec in symbols section. | |
void | _ParseSymbols_Class_Size (ClassInfo *parent) |
Parse size block (member var entries) of class in symbols section. | |
void | _ParseProgram_Label () |
Parse {m,s}label in program section. | |
void | _ParseProgram_FinishFunction () |
Finish a function if there is one. | |
int | _WriteFunctionProgram (FILE *fp, ProgramStorage::Function *pfunc) |
Write program instructions of a function. | |
int | _WriteSymbolSectionContent (FILE *fp) |
Write symbol section content recursively. | |
int | _WriteSymbols_Recursive (StringTreeDump &out, NamespaceInfo *ni) |
Internally used by _WriteSymbolSectionContent():. | |
int | _WriteSymbols_Global (StringTreeDump &out, _GlobVars *gvar, char which) |
Internally used by _WriteSymbolSectionContent():. | |
int | _MustDumpNamespace (NamespaceInfo *ni) |
Protected Attributes | |
TextAsmScanner | scan |
Scanner used for lexical analysis. | |
int | n_errors |
Number of parsing errors. | |
IDMapTable< CodeMark, PrgAdr > | codemark2prgadr |
This is the CodeMark -> PrgAdr map used to resolve relative jumps. | |
TLArrayHeap< RJumpEntry, RJumpEntry_Operators > * | prgadr2codemark |
This is the reverse "table" used to write assembly with jumps. | |
TextAsmScanner::Token * | tok |
Lookahead token. | |
Private Member Functions | |
AssemblerFile_Plaintext (const AssemblerFile_Plaintext &) | |
Do not use:. | |
void | operator= (const AssemblerFile_Plaintext &) |
Do not use:. |
This class is NOT C++-safe.
Definition at line 52 of file tasm-file.h.
|
Do not use:.
|
|
Create "empty" file; use ParseFile() to read content.
Definition at line 454 of file tasm-file.cc. |
|
Destroy all the content.
Definition at line 465 of file tasm-file.cc. References DELETE(), and prgadr2codemark. |
|
Report error because current property is already set.
Definition at line 39 of file parser.cc. References _CurrTokID(), Assert, Error(), n_errors, scan, tok, and TextAsmScanner::TokID2String(). Referenced by _ParseSymbols_Class(), _ParseSymbols_Class_Base(), _ParseSymbols_Class_Size(), and _ParseSymbols_Class_VTable(). |
|
Check if passed name is already known as child of *parent.
Definition at line 198 of file parser.cc. References _LocFirstDefError(), Error(), VM::NamespaceInfo::map_name2child, TLBTree< NamespaceInfo *, PtrListOperators< NamespaceInfo > >::search(), and tok. Referenced by _ParseSymbols_Class(), and _ParseSymbols_Namespace(). |
|
Return current token ID, properly casted.
Definition at line 103 of file tasm-file.h. References tok. Referenced by _AlreadySetError(), _ExpectError(), _ParseInfoSection(), _ParseProgram_Label(), _ParseProgramSection(), _ParseSymbols_Class(), _ParseSymbols_Class_Base(), _ParseSymbols_Class_Size(), _ParseSymbols_Class_VTable(), _ParseSymbols_Global(), _ParseSymbols_Namespace(), _ParseSymbols_Symbols(), _ParseSymbolSection(), _SkipUntilPop(), and ParseFile(). |
|
Report parse error (expected something else). Use location in *tok.
Definition at line 26 of file parser.cc. References _CurrTokID(), Error(), n_errors, scan, tok, and TextAsmScanner::TokID2String(). Referenced by _ParseInfoSection(), _ParseProgramSection(), _ParseSymbols_Class(), _ParseSymbols_Class_Base(), _ParseSymbols_Class_Size(), _ParseSymbols_Class_VTable(), _ParseSymbols_Global(), _ParseSymbols_Namespace(), _ParseSymbols_Symbols(), _ParseSymbolSection(), and ParseFile(). |
|
Get next token and store it in the lookahead token *tok.
Definition at line 95 of file tasm-file.h. References scan, TextAsmScanner::Token::str_val, and tok. Referenced by _ParseInfoSection(), _ParseProgram_Label(), _ParseProgramSection(), _ParseSymbols_Class(), _ParseSymbols_Class_Base(), _ParseSymbols_Class_Size(), _ParseSymbols_Class_VTable(), _ParseSymbols_Global(), _ParseSymbols_Namespace(), _ParseSymbols_Symbols(), _ParseSymbolSection(), _SkipUntilPop(), and ParseFile(). |
|
Report "this is the location of the first definition" error.
Definition at line 47 of file parser.cc. References Error(), and n_errors. Referenced by _CheckNspcNameKnown(), _ParseProgram_Label(), and _ParseSymbols_Class(). |
|
Decide whether we need to emit the passed namespace. Definition at line 155 of file tasm-file.cc. References Assert, VM::NamespaceInfo::down, LinkedList< NamespaceInfo >::first(), VM::ClassInfo::need_cast, VM::ClassInfo::need_construct, LinkedListBase< NamespaceInfo >::next, and VM::NamespaceInfo::nstype. Referenced by _WriteSymbols_Recursive(). |
|
Parse a function type ID (func/meth/vmeth).
Definition at line 81 of file parser.cc. References Assert. Referenced by _ParseSymbols_Symbols(). |
|
Parse the "info:" section.
Definition at line 738 of file parser.cc. References _CurrTokID(), _ExpectError(), _LexNextToken(), TextAsmScanner::Token::str_val, and tok. Referenced by ParseFile(). |
|
Parse the "locations:" section.
Definition at line 812 of file parser.cc. References CritAssert. Referenced by ParseFile(). |
|
Finish a function if there is one.
Definition at line 125 of file parser.cc. References VM::ProgramStorage::AddFunction(), IDMapTable< CodeMark, PrgAdr >::clear(), VM::CodeMark, codemark2prgadr, VM::INST::DescEntry::codemark_off, Error(), VM::InstructionStorage::index(), TextAsmScanner::insn_storage, VM::InstructionStorage::InstructionAt(), int32, VM::InstructionStorage::length(), VM::ProgramStorage::Function::loc, IDMapTable< CodeMark, PrgAdr >::lookup(), n_errors, VM::PrgAdr, scan, VM::INST::DescEntry::size, VM::ProgramStorage::Function::symref, VM::InstructionStorage::TightenSize(), uint, and Warning(). Referenced by _ParseProgram_Label(), and _ParseProgramSection(). |
|
Parse {m,s}label in program section.
Definition at line 819 of file parser.cc. References _CurrTokID(), _LexNextToken(), _LocFirstDefError(), _ParseProgram_FinishFunction(), IDMapTable< CodeMark, PrgAdr >::AddNode(), Assert, TextAsmScanner::Token::codemark, codemark2prgadr, DELETE(), Error(), TextAsmScanner::insn_storage, VM::InstructionStorage::length(), VM::ProgramStorage::Function::loc, VM::NamespaceInfo::map_name2symbol, n_errors, VM::NamespaceInfo::name, scan, TLBTree< SymbolEntryE *, PtrListOperators< SymbolEntryE > >::search(), TLString::sprintf(), TextAsmScanner::Token::str_val, TextAsmScanner::Token::symref, tok, and uint. Referenced by _ParseProgramSection(). |
|
Parse the "program:" instructions section.
Definition at line 960 of file parser.cc. References _CurrTokID(), _ExpectError(), _LexNextToken(), _ParseProgram_FinishFunction(), _ParseProgram_Label(), and tok. Referenced by ParseFile(). |
|
Parse class block in symbols section.
Definition at line 651 of file parser.cc. References _AlreadySetError(), _CheckNspcNameKnown(), _CurrTokID(), _ExpectError(), _LexNextToken(), _LocFirstDefError(), _ParseSymbols_Class_Base(), _ParseSymbols_Class_Size(), _ParseSymbols_Class_VTable(), _ParseSymbols_Symbols(), ImplicitMapTable< ClassInfo, TypeID, ImplicitMapOperators< ClassInfo, TypeID, ORD_TypeID > >::AddNode(), VM::NamespaceInfo::asm_loc, Assert, DELETE(), Error(), n_errors, TextAsmScanner::Token::num, VM::ClassInfo::nvirtuals, TextAsmScanner::Token::str_val, TextAsmScanner::Token::tid, and tok. Referenced by _ParseSymbols_Namespace(), and _ParseSymbolSection(). |
|
Parse "base" block in class spec in symbols section.
Definition at line 213 of file parser.cc. References _AlreadySetError(), _CurrTokID(), _ExpectError(), _LexNextToken(), _SkipUntilPop(), VM::NonResizeableArray< BaseEntry, uint32 >::alloc(), VM::ClassInfo::base, Error(), VM::NonResizeableArray< BaseEntry, uint32 >::n(), n_errors, TextAsmScanner::Token::num, TextAsmScanner::Token::off, TextAsmScanner::Token::tid, tok, and uint32. Referenced by _ParseSymbols_Class(). |
|
Parse size block (member var entries) of class in symbols section.
Definition at line 333 of file parser.cc. References _AlreadySetError(), _CurrTokID(), _ExpectError(), _LexNextToken(), _ParseVarType(), _SkipUntilPop(), VM::NonResizeableArray< MemberVarEntry, uint32 >::alloc(), Error(), VM::VarType::IsPointerType(), VM::ClassInfo::membvar, VM::NonResizeableArray< MemberVarEntry, uint32 >::n(), n_errors, TextAsmScanner::Token::num_p, TextAsmScanner::Token::num_v, TextAsmScanner::Token::off, TextAsmScanner::Token::size, VM::ClassInfo::size, TextAsmScanner::Token::str_val, TextAsmScanner::Token::t, tok, and uint32. Referenced by _ParseSymbols_Class(). |
|
Parse "vtable" block in class spec in symbols section.
Definition at line 273 of file parser.cc. References _AlreadySetError(), _CurrTokID(), _ExpectError(), _LexNextToken(), _SkipUntilPop(), VM::NonResizeableArray< VTableEntry, uint32 >::alloc(), Error(), VM::NonResizeableArray< VTableEntry, uint32 >::n(), n_errors, TextAsmScanner::Token::num, TextAsmScanner::Token::symref, tok, uint32, and VM::ClassInfo::vtable. Referenced by _ParseSymbols_Class(). |
|
Parse {p,v}global block in symbols section.
Definition at line 536 of file parser.cc. References _CurrTokID(), _ExpectError(), _LexNextToken(), _ParseVarType(), IDMapTable< SymRef, GlobalVarEntry * >::AddNode(), Assert, Error(), n_errors, TextAsmScanner::Token::off, TextAsmScanner::Token::size, TextAsmScanner::Token::str_val, TextAsmScanner::Token::symref, TextAsmScanner::Token::t, and tok. Referenced by _ParseSymbolSection(). |
|
Parse namespace block in symbols section.
Definition at line 601 of file parser.cc. References _CheckNspcNameKnown(), _CurrTokID(), _ExpectError(), _LexNextToken(), _ParseSymbols_Class(), _ParseSymbols_Symbols(), VM::NamespaceInfo::asm_loc, TextAsmScanner::Token::str_val, and tok. Referenced by _ParseSymbolSection(). |
|
|
Parse the "symbols:" section.
Definition at line 766 of file parser.cc. References _CurrTokID(), _ExpectError(), _LexNextToken(), _ParseSymbols_Class(), _ParseSymbols_Global(), _ParseSymbols_Namespace(), _ParseSymbols_Symbols(), VM::NamespaceInfo::asm_loc, and tok. Referenced by ParseFile(). |
|
Parse a TextAsmScanner::Token::Type into a VarType.
Definition at line 54 of file parser.cc. References VM::VarType::array, Assert, VM::VarType::id, and TextAsmScanner::Token::Type::tchar. Referenced by _ParseSymbols_Class_Size(), _ParseSymbols_Global(), and _ParseSymbols_Symbols(). |
|
Skip (num) tokens skip_a, skip_b until a TS_pop is found. The number (num) is currently ignored. Definition at line 99 of file parser.cc. References _CurrTokID(), _LexNextToken(), and uint32. Referenced by _ParseSymbols_Class_Base(), _ParseSymbols_Class_Size(), and _ParseSymbols_Class_VTable(). |
|
|
Internally used by _WriteSymbolSectionContent():.
Definition at line 359 of file tasm-file.cc. References StringTreeDump::AddIndent(), TLString::sprintf(), StringTreeDump::SubIndent(), and uint. Referenced by _WriteSymbolSectionContent(). |
|
|
Write symbol section content recursively.
Definition at line 389 of file tasm-file.cc. References _WriteSymbols_Global(), _WriteSymbols_Recursive(), StringTreeDump::AddIndent(), StringTreeDump::SubIndent(), and StringTreeDump::write(). Referenced by WriteFile(). |
|
Do not use:.
|
|
Read in a file; see base class. [overriding virtual].
Reimplemented from VM::AssemblerFile. Definition at line 991 of file parser.cc. References _CurrTokID(), _ExpectError(), _LexNextToken(), _ParseInfoSection(), _ParseLocationSection(), _ParseProgramSection(), _ParseSymbolSection(), Assert, n_errors, TextAsmScanner::NErrors(), SCLocation::pos, scan, tok, and uint32. Referenced by _DoParseFile(). |
|
Write file; see base class. [overriding virtual].
Reimplemented from VM::AssemblerFile. Definition at line 409 of file tasm-file.cc. References _WriteFunctionProgram(), _WriteSymbolSectionContent(), DELETE(), VM::ProgramStorage::FirstFunction(), LinkedListBase< Function >::next, prgadr2codemark, and TLString::str(). |
|
ONLY for debugging:.
Definition at line 190 of file tasm-file.h. References _WriteFunctionProgram(). |
|
This is the CodeMark -> PrgAdr map used to resolve relative jumps.
Definition at line 86 of file tasm-file.h. Referenced by _ParseProgram_FinishFunction(), and _ParseProgram_Label(). |
|
Number of parsing errors.
Definition at line 83 of file tasm-file.h. Referenced by _AlreadySetError(), _ExpectError(), _LocFirstDefError(), _ParseProgram_FinishFunction(), _ParseProgram_Label(), _ParseSymbols_Class(), _ParseSymbols_Class_Base(), _ParseSymbols_Class_Size(), _ParseSymbols_Class_VTable(), _ParseSymbols_Global(), _ParseSymbols_Symbols(), and ParseFile(). |
|
This is the reverse "table" used to write assembly with jumps.
Definition at line 89 of file tasm-file.h. Referenced by _WriteFunctionProgram(), WriteFile(), and ~AssemblerFile_Plaintext(). |
|
Scanner used for lexical analysis.
Definition at line 81 of file tasm-file.h. Referenced by _AlreadySetError(), _ExpectError(), _LexNextToken(), _ParseProgram_FinishFunction(), _ParseProgram_Label(), and ParseFile(). |
|
Lookahead token.
Definition at line 92 of file tasm-file.h. Referenced by _AlreadySetError(), _CheckNspcNameKnown(), _CurrTokID(), _ExpectError(), _LexNextToken(), _ParseInfoSection(), _ParseProgram_Label(), _ParseProgramSection(), _ParseSymbols_Class(), _ParseSymbols_Class_Base(), _ParseSymbols_Class_Size(), _ParseSymbols_Class_VTable(), _ParseSymbols_Global(), _ParseSymbols_Namespace(), _ParseSymbols_Symbols(), _ParseSymbolSection(), and ParseFile(). |