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

📄 symtbl.h

📁 < 虚拟机设计与实现> 的source code, linux版本
💻 H
字号:
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+                                                                   +
+ symtbl.h - the symbol table and associated functions            +
+                                                                   +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

/*
	SymTbl---+---GlobalVariable
			 |
			 +---Procedure-----+--StackFrame ( ret, arg, local )
						       |
						       +--Label

	Pass1 - uses directives to fill out GlobVar, Proc entries
	Pass2 - uses above to generate bytecode
*/

#ifndef _SYMTBL_H
#define _SYMTBL_H

#include "globvar.h"
#include "linux.h"
#include "proc.h"

#define GLOB_INIT	10		/* _INIT = initial array size */
#define GLOB_INC	5		/* _INC = increment size when expand array */

#define PROC_INIT	10
#define PROC_INC	5

#define ARG_INIT	5	
#define ARG_INC		5	

#define LOC_INIT	5
#define LOC_INC		5

#define LBL_INIT	10
#define LBL_INC		10

#define SYM_DEBUG		1

#ifdef	SYM_DEBUG
#define	SYM_DEBUG0(arg);			printf(arg);
#define SYM_DEBUG1(arg1,arg2);		printf(arg1,arg2);
#define SYM_DEBUG2(arg1,arg2,arg3);	printf(arg1,arg2,arg3);
#else
#define	SYM_DEBUG0(arg);
#define SYM_DEBUG1(arg1,arg2);
#define SYM_DEBUG2(arg1,arg2,arg3);
#endif

struct GlobalVariable * globVar;
U4 nGlobVar;
U4 iGlobVar;

struct Procedure * proc;
U4 nProc;
U4 iProc;

int SymbolTable_init();
void SymbolTable_free();

int addGlobVar(struct GlobalVariable * add);
int addProc(struct Procedure * add);

/*set elements of current procedure*/
int setProcRetHL(struct StackFrame * add);
int addProcArgHL(struct StackFrame * add); 
int addProcLocHL(struct StackFrame * add); 
int addProcLblHL(struct Label * add); 

void printSymTbl();

void test_SymbolTable();

#endif

⌨️ 快捷键说明

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