您的位置:首页 > 其它

编译原理——赋值语句和简单表达式(十九)

2012-03-31 09:30 218 查看
临时变量表。

TemporaryTable.java:

package per.eyuan.util;

public class TemporaryTable {
Temporary table[]=new Temporary[20];
int count=0;
public TemporaryTable() {
super();
init();
}
public void init(){
for(int i=0;i<table.length;i++)
table[i]=new Temporary();
}
public int getCount(){
return count;
}
public Temporary getTemp(int index){
//获取Temporary表中指定索引的Temporary实例
return table[index];
}

//新增临时变量
public void addTemp(String val){
table[count].index=count;
table[count].value=val;
count++;
}
public void addTemp(){
table[count].index=count;
count++;
}
public Temporary[] getAllTemporary(){
Temporary atemp[]=new Temporary[count];
for(int i=0;i<count;i++)
atemp[i]=table[i];
return atemp;
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: