📄 iddescriptor.java
字号:
package CatDecaf.SymTable;
public class IDDescriptor extends Descriptor{
boolean isArray, fieldD, paramD, initialized;
int arraySize;
public IDDescriptor(String n, int t){
name = n; type = t; fieldD = false;
}
public IDDescriptor(String n, int t, int s){
name = n; type = t; fieldD = false; paramD = false; initialized = false;
isArray = true; arraySize = s;
if(s <= 0){
System.err.println(parser.parser.infile+":" + parser.Scanner.lineno +
": invalid array declaration; '" + SymbolTable.getTypeName(t) + " " + n + "[" + s + "]'");
ClassProgram.numOfError++;
}
}
public boolean isGlobal(){
return fieldD;
}
public void assertFieldDescriptor(){
this.fieldD = true; initialized = true;
}
public boolean isParam(){
return paramD;
}
public void assertParamDescriptor(){
this.paramD = true; initialized = true;
}
public void assertInitialized(){
initialized = true;
}
public boolean isInitialized(){
return initialized;
}
public void setOffset(int i){
this.offset = i;
}
public boolean isArrayType(){
return isArray;
}
public int getArraySize(){
return arraySize;
}
public void pPrint(){
String stype;
if(type == parser.sym.INT) stype = "int";
else if(type == parser.sym.BOOLEAN) stype = "boolean";
else stype = "Error: unidentified type";
if(isArray)
System.out.print(stype + " " + name + "[" + arraySize + "]" + "(" + offset + ") ");
else System.out.print(stype + " " + name + "(" + offset + ")" + " ");
}
public String toString(){
String stype;
if(type == parser.sym.INT) stype = "int";
else if(type == parser.sym.BOOLEAN) stype = "boolean";
else stype = "Error: unidentified type";
if(isArray)
return stype + " " + name + "[" + arraySize + "]" ;
else return stype + " " + name;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -