Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

/ray/src/vm/input/tasm/tasm-file.h

Go to the documentation of this file.
00001 /*
00002  * vm/input/tasm/tasm-file.h
00003  * 
00004  * VM plaintext assembly input file. 
00005  * 
00006  * Copyright (c) 2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 
00007  * 
00008  * This file may be distributed and/or modified under the terms of the 
00009  * GNU General Public License version 2 as published by the Free Software 
00010  * Foundation. (See COPYING.GPL for details.)
00011  * 
00012  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014  * 
00015  */
00016 
00017 #ifndef _VM_INPUT_TASM_TASM_FILE_H_
00018 #define _VM_INPUT_TASM_TASM_FILE_H_ 1
00019 
00027 #include <vm/vmconfig.h>    /* MUST be first */
00028 #include <vm/input/asmfile.h>
00029 #include <vm/input/tasm/tasm-scanner.h>
00030 #include <lib/tl/tlarrayheap.h>
00031 
00032 // See lib/lex/strtreedump.h. 
00033 class StringTreeDump;
00034 
00035 
00036 namespace VM
00037 {
00038 
00039 // See <vm/input/classinfo.h>: 
00040 class ClassInfo;
00041 
00042 
00052 class AssemblerFile_Plaintext : public AssemblerFile
00053 {
00054     public:
00055         struct RJumpEntry
00056         {
00057             PrgAdr adr;      
00058             CodeMark cmark;  
00059             
00061             static inline PrgAdr ord(const RJumpEntry &e)
00062                 {  return(e.adr);  }
00063             
00064             inline RJumpEntry() {}
00065             inline RJumpEntry(PrgAdr _adr,CodeMark _cmark) : adr(_adr),
00066                 cmark(_cmark)  {}
00067             inline ~RJumpEntry() {}
00068         };
00069         
00070         struct RJumpEntry_Operators : 
00071             TLDefaultOperators_OrdRel2_Rev<RJumpEntry,RJumpEntry,RJumpEntry,
00072                 RJumpEntry>,
00073             TLDefaultOperators_Construct_CDT<RJumpEntry>,
00074             TLDefaultOperators_Index<RJumpEntry>,
00075             TLDefaultOperators_Allocation
00076         {
00077         };
00078         
00079     protected:
00081         TextAsmScanner scan;
00083         int n_errors;
00084         
00086         IDMapTable<CodeMark,PrgAdr> codemark2prgadr;
00087         
00089         TLArrayHeap<RJumpEntry,RJumpEntry_Operators> *prgadr2codemark;
00090         
00092         TextAsmScanner::Token *tok;
00093         
00095         inline void _LexNextToken()
00096         {
00097             // Mark old token as used. 
00098             if(tok && tok->str_val)  *tok->str_val='\0';
00099             tok=(TextAsmScanner::Token*)scan.LexNextToken();
00100         }
00101         
00103         inline TextAsmScanner::TokID _CurrTokID()
00104             {  return((TextAsmScanner::TokID)
00105                 (tok ? tok->token : TextAsmScanner::T_EOF));  }
00106         
00108         void _ExpectError(const char *str);
00110         void _AlreadySetError();
00112         void _LocFirstDefError(const SCLocation &loc);
00113         
00115         VarType _ParseVarType(const TextAsmScanner::Token::Type *t);
00117         FuncType _ParseFuncType(char ftype);
00118         
00121         void _SkipUntilPop(uint32 num,TextAsmScanner::TokID skip_a,
00122             TextAsmScanner::TokID skip_b=TextAsmScanner::T_EOF);
00123         
00125         NamespaceInfo *_CheckNspcNameKnown(NamespaceInfo *parent,
00126             const TLString &name);
00127         
00129         void _ParseInfoSection();
00131         void _ParseSymbolSection();
00133         void _ParseLocationSection();
00135         void _ParseProgramSection();
00136         
00138         void _ParseSymbols_Namespace(NamespaceInfo *parent);
00140         void _ParseSymbols_Class(NamespaceInfo *parent);
00142         void _ParseSymbols_Symbols(NamespaceInfo *parent);
00144         void _ParseSymbols_Global();
00146         void _ParseSymbols_Class_Base(ClassInfo *parent);
00148         void _ParseSymbols_Class_VTable(ClassInfo *parent);
00150         void _ParseSymbols_Class_Size(ClassInfo *parent);
00151         
00153         void _ParseProgram_Label();
00154         
00156         void _ParseProgram_FinishFunction();
00157         
00159         int _WriteFunctionProgram(FILE *fp,ProgramStorage::Function *pfunc);
00161         int _WriteSymbolSectionContent(FILE *fp);
00163         int _WriteSymbols_Recursive(StringTreeDump &out,NamespaceInfo *ni);
00165         int _WriteSymbols_Global(StringTreeDump &out,_GlobVars *gvar,
00166             char which);
00167             
00170         int _MustDumpNamespace(NamespaceInfo *ni);
00171         
00172     private:
00174         AssemblerFile_Plaintext(const AssemblerFile_Plaintext &);
00176         void operator=(const AssemblerFile_Plaintext &);
00177     public:
00179         AssemblerFile_Plaintext();
00181         ~AssemblerFile_Plaintext();
00182         
00184         int ParseFile(const TLString &fname,SError &error,uint32 file_num);
00185         
00187         int WriteFile(const TLString &fname,SError &error);
00188         
00190         int WriteFunctionProgram(FILE *fp,ProgramStorage::Function *pfunc)
00191             {  return(_WriteFunctionProgram(fp,pfunc));  }
00192 };
00193 
00194 }  // end of namespace VM
00195 
00196 #endif  /* _VM_INPUT_TASM_TASM_FILE_H_ */

Generated on Sat Feb 19 22:33:47 2005 for Ray by doxygen 1.3.5