mips without optimize
This commit is contained in:
51
backend/mips/MipsModule.java
Normal file
51
backend/mips/MipsModule.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package backend.mips;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import backend.mips.instr.MipsAnnotation;
|
||||
import backend.mips.instr.MipsLabel;
|
||||
import backend.mips.instr.MipsInstr;
|
||||
|
||||
public class MipsModule {
|
||||
private ArrayList<MipsInstr> dataList;
|
||||
private ArrayList<MipsInstr> textList;
|
||||
|
||||
public MipsModule() {
|
||||
this.dataList = new ArrayList<MipsInstr>();
|
||||
this.textList = new ArrayList<MipsInstr>();
|
||||
}
|
||||
|
||||
public ArrayList<MipsInstr> getDataList() {
|
||||
return dataList;
|
||||
}
|
||||
|
||||
public ArrayList<MipsInstr> getTextList() {
|
||||
return textList;
|
||||
}
|
||||
|
||||
public void addData(MipsInstr instr) {
|
||||
dataList.add(instr);
|
||||
}
|
||||
|
||||
public void addText(MipsInstr instr) {
|
||||
textList.add(instr);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(".data\n");
|
||||
for (MipsInstr instr : dataList) {
|
||||
sb.append("\t" + instr.toString());
|
||||
}
|
||||
sb.append("\n.text\n");
|
||||
for (MipsInstr instr : textList) {
|
||||
if (instr instanceof MipsLabel || instr instanceof MipsAnnotation) {
|
||||
sb.append(instr.toString());
|
||||
continue;
|
||||
}
|
||||
sb.append("\t" + instr.toString());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user