mddecl.java

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

JAVA
46
字号
package CatDecaf.IR; // Java Package generated by the BNF Converter.
import parser.*;
import CatDecaf.Utilities.Debugger.*;

public class MdDecl  implements CatDecaf.Utilities.Visitable
{
  public Typ typ_;
  public Identifier identifier_;
  public MdParaList mdParaList_;
  public Block block_;
  public int localSize_;
  public int paramSize_;  

  
/*
  public MdDecl(Typ p1, Identifier p2, MdParaList p3, Block p4) 
  	{ typ_ = p1; identifier_ = p2; mdParaList_ = p3; block_ = p4;}
*/
    public MdDecl(Typ p1, Identifier p2, MdParaList p3, Block p4, int p5, int p6) 
  	{ typ_ = p1; identifier_ = p2; mdParaList_ = p3; block_ = p4;
	  localSize_ = p5;
	  paramSize_ = p6;
    	}

    public int getReserveSize(){
    	int spaceForAutomaticVars = localSize_;
    	int spaceForParamPastSixth = 0 ; //(paramSize_/4>6 ? paramSize_/4-6 :0)*4;
    	int spaceForCalleeRegister = 6*4;
    	int spaceForHiddenParam = 1*4;
    	int spaceFor16Register = 16*4;

    	int totalSize 	= spaceForAutomaticVars 
    		 		+ spaceForParamPastSixth 
    		 		+ spaceForCalleeRegister
    		 		+ spaceForHiddenParam
    		 		+ spaceFor16Register+4;

	if ((totalSize % 8)!=0) totalSize +=4;
    	
    	
	return totalSize;
    }

  public void accept(CatDecaf.Utilities.Visitor v) { v.visit(this); }
}

⌨️ 快捷键说明

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