locationarray.java

来自「用Java实现的编译器。把源代码编译成SPARC汇编程序」· Java 代码 · 共 39 行

JAVA
39
字号
package CatDecaf.IR; // Java Package generated by the BNF Converter.
import parser.*;
import CatDecaf.Utilities.Debugger.*;
import java6035.tools.ASM.*;
public class LocationArray extends Location implements CatDecaf.Utilities.Visitable
{
  public Identifier identifier_;
  public Exp exp_;
  public int type;
  public SPARCRegister reg;

  public LocationArray(Identifier p1, Exp p2) 
  	{ identifier_ = p1; exp_=p2;
	   type = identifier_.getType();
	   if(exp_.noError() && exp_.getType()!=sym.INT) 
	   	ErrorLog.log("Integer type expected for Array index");
	   reg = null;
  	}
	public int getType(){return type;}	
	public boolean noError(){return !(type==sym.ERROR_TYPE);}
	public SPARCRegister getReg(){
		return reg;
	}

	public void setReg(SPARCRegister r){
		reg=r;
		reg.status = 1;
	}
	public void releaseReg(){
		reg.status = 0;
		reg= null;
	}	
// a[exp] = 2;
// smul r0, 4, r1
// add fp%, r0, r2
// ld r2, 2
  public void accept(CatDecaf.Utilities.Visitor v) { v.visit(this); }
}

⌨️ 快捷键说明

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