⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asmgen.h

📁 C-MINUS编译器
💻 H
字号:
#ifndef MY_ASMGEN_H_
#define MY_ASMGEN_H_

/**:	File: asmGen.h
&
*	This is 80X86 ASM code generator
*
*	author:	lonelyforest
*	data:	2006.4.23
*/
#include "Analyzer.h"

//----------------------------------------------------------------------------
class asmGen {
public:
    //------------------------------------------------------------------------
	asmGen(const string &filename);
	~asmGen();
	
	void codeGen();    // main interface, create syntaxtree, gen asm code
	//-----------------------------------------------------------------------
	void noListFile() {   analyze->noListFile(); }
	void noTreeFile() {   analyze->noTreeFile(); }
	void noSymbolFile(){ analyze->noSymbolFile();}
	void noCodeFile() {	traceCode = false; }
    //-----------------------------------------------------------------------
	bool is_good()const	{ return is_good_ &&  analyze->is_good(); }
	int	errCount()const{ return err+analyze->errCount(); }
	int warnCount()const{ return warn+analyze->warnCount(); }
    //------------------------------------------------------------------------
protected:
    //------------------------------------------------------------------------
	void    x86Gen();
	void	emitComment(const char *eCmt);
	void    emitCode(const char *eCde);
    //------------------------------------------------------------------------
	void	x86GenPre();
	void	x86GenCode();
    //------------------------------------------------------------------------
	void	x86GenData(TreeNode *tree);
	void	x86GenVar(TreeNode *tree);
	void	x86GenFun(TreeNode *tree, bool pre);
    //------------------------------------------------------------------------
	void	x86GenSE(TreeNode *tree);
	void    x86GenStmt(TreeNode *tree);
	void	x86GenExp(TreeNode *tree);
    //------------------------------------------------------------------------
	void    read_int();
	void    write_int();
    //------------------------------------------------------------------------
    bool    isLeft(TreeNode *node);
protected:
	Analyzer *analyze;
	TreeNode *tree_;
    //------------------------------------------------------------------------
	string	 codefile;
	ofstream code_;
    //------------------------------------------------------------------------
	int     err;
	int     warn;
	int		cL;		// current label number;
	
	bool	traceCode;
	bool    is_good_;
	//----------------------------------------------------------------------------
	
};
//----------------------------------------------------------------------------

#endif	// end #ifndef MY_ASMGEN_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -