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

📄 mipsframe.java

📁 编译原理大作业---tiger编译器 包括semant,translate,mipsframe,regalloc等所有phase 懂的人自会知道
💻 JAVA
字号:
package Mips;import java.util.Hashtable;public class MipsFrame extends Frame.Frame {   public Temp.Temp FP;   public Temp.Temp RV;   int offset_stack; // per l'allocazione delle variabili   int offset_formals; // per l'allocazione dei par. formali   public MipsFrame(String main) {      name = new Temp.Label(main);      funz_ext = new Hashtable();      FP = new Temp.Temp();      RV = new Temp.Temp();   }   public MipsFrame(Temp.Label l) {      name = l;      funz_ext = new Hashtable();      FP = new Temp.Temp();      RV = new Temp.Temp();   }   public Frame.Frame newFrame(Temp.Label l, Util.BoolList formals) {      MipsFrame mf = new MipsFrame(l);      mf.formals = set_formals(formals);      return mf;   }   // la wordsize nell'architettura Mips e' di 4 byte   public int wordSize() { return 4; }   // FRAME POINTER   public Temp.Temp FP() { return FP; }   // RETURN VALUE   public Temp.Temp RV() { return RV; }   // per la gestione delle stringhe (restituisce una stringa   // specifica per l'architettura MIPS)   public String string(Temp.Label label, String value) {      // TODO      return value;   }   // gestisce il prologo della funzione.   public Tree.Stm procEntryExit1(Tree.Stm body) {      return body; // DUMMY IMPLEMENTATION (TODO...)   }   // per le chiamate a funzioni esterne   public Tree.Exp externalCall(String s, Tree.ExpList args) {      return new Tree.CALL(new Tree.NAME(new Temp.Label(s)),args);   }   public Frame.Access allocLocal(boolean escape) {   if (escape) {      InFrame inFr = new InFrame(offset_stack);      offset_stack-=wordSize();      return inFr;   }   else return new InReg();   }   // per l'inserimento nella hashtable delle funzioni di libreria   public void put_lib_f(String stringa, Temp.Label label) {      funz_ext.put(stringa,label);   }   private AccessList set_formals(Util.BoolList ff) {      if (ff==null) return null;      return new AccessList(allocFormals(ff.head), set_formals(ff.tail));   }   public Frame.Access allocFormals(boolean escape) {      if (escape) {         InFrame ret = new InFrame(offset_formals);         offset_formals+=wordSize();         return ret;      }      else {         InReg retr = new InReg();         return retr;      }   }}

⌨️ 快捷键说明

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