📄 codegen.java
字号:
/*
* @(#)CodeGen.java 1.0.0 05/13/2007
*
* Copyright 2007 Xuxt@buaa, No.34060520 All rights reserved.
*/
package com.king4solomon.homework.compiler.core;
import java.util.*;
import com.king4solomon.homework.compiler.gui.*;
import com.king4solomon.homework.compiler.pvm.Instruction;
/**
* @author Xuxt@buaa
* @version 1.0.0
*/
public class CodeGen {
public static void gen(int instr, int lv, int a) {
codeBuf.add(new Instruction(instr, lv, a));
px++;
CodePane.clear();
int num = 1;
for (Instruction i : codeBuf) {
CodePane.appand(num++ + " " + instructions[i.instruction]
+ " " + i.level + " " + i.value);
}
}
public static void gen(int instr, int tp, String val) {
codeBuf.add(new Instruction(instr, tp, val));
px++;
CodePane.clear();
int num = 1;
for (Instruction i : codeBuf) {
CodePane.appand(num++ + " " + instructions[i.instruction]
+ " " + i.level + " " + i.value);
}
}
public static void reset(int idx, int instr, int lv, int a) {
codeBuf.set(idx - 1, new Instruction(instr, lv, a));
CodePane.clear();
int num = 1;
for (Instruction i : codeBuf) {
CodePane.appand(num++ + " " + instructions[i.instruction]
+ " " + i.level + " " + i.value);
}
}
public static void init() {
px = 1;
codeBuf = new ArrayList<Instruction>();
}
public static ArrayList<Instruction> getCode() {
return codeBuf;
}
public static int px;
private static ArrayList<Instruction> codeBuf = new ArrayList<Instruction>();
public static String[] instructions = { "JMP", "JPC", "RED", "WRT", "STO",
"LOD", "OPR", "LIT", "INT", "CAL", "RET", "STR", "", "STC", "LDR",
"", "LDC", "HLT", "LST", "CRJ", "CRC", "TPC"};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -