www.pudn.com > pl0_compiler_c.rar > code.h


// code.h: interface for the code class. 
////////////////////////////////////////////////////////////////////// 
#ifndef __CODE_H 
#define __CODE_H 
#include "yufa.h" 
#define CODE_SIZE	200               //可容纳代码行数 
#define RUN_STACK_SIZE	500	          //runtime stack size 
enum fct {lit,opr,lod,sto,cal,intint,jmp,jpc}; 
 
struct instruction 
{ 
	fct f;	                          //fuction code 
	int l;	                          //level 
	int a;	                          //displacement addr 
}; 
class Ccode 
{ 
friend class CYufa; 
public: 
	Ccode(){cx=0;} 
	void Gen(fct f,int l,int a); 
	void ListCode(); 
	void Interpret(); 
 
private: 
	instruction code[CODE_SIZE]; 
	int cx;                           //指令数组的索引值 
	int b;	                          //堆栈基址 
	int s[RUN_STACK_SIZE];	          //数据存储 
private: 
	int base(int l); 
}; 
 
#endif