📄 mipsframe.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 + -