four.java

来自「基于c0文法写的生成p-code的编译器」· Java 代码 · 共 97 行

JAVA
97
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. *//** * * @author lilac */public class Four {    public int op;                    //操作符    public String first;                 //第一操作数    public String last;                   //第二操作数    public String result;                 //结果    public Four(int op, String first, String last, String result) {        this.first = first;        this.last = last;        this.op = op;        this.result = result;    }    public Four(Four get) {        this.first = get.first;        this.last = get.last;        this.op = get.op;        this.result = get.result;    }    @Override    public String toString() {        String ss=new String();        String cc=new String();        if (this.op == 1) {            ss = "ADD";            cc=this.first;        } else if (this.op == 2) {            ss = "SUB";            cc=this.first;        } else if (this.op == 3) {            ss = "MUL";            cc=this.first;        } else if (this.op == 4) {            ss = "DIV";            cc=this.first;        } else if (this.op == Compile.CONDITION) {            ss="condition";            if (this.first.equals("24")) {                cc = "G";            } else if (this.first.equals("25")) {                cc = "L";            } else if (this.first.equals("26")) {                cc = "GE";            } else if (this.first.equals("27")) {                cc = "LE";            } else if (this.first.equals("28")) {                cc = "NE";            } else if (this.first.equals("29")) {                cc = "EE";            }        }else if(this.op==5){            ss="MOV";            cc=this.first;        }else if (this.op == 6) {            ss = "STAMP";            cc=this.first;        } else if (this.op == 7) {            ss = "J";            cc=this.first;        } else if (this.op == 8) {            ss = "JFALSE";            cc=this.first;        }        else if(this.op==13){            ss="PRINTF";            cc=this.first;        }else if (this.op == 10) {            ss = "CMP";            cc=this.first;        } else if (this.op == 11) {            ss = "PUSHPARA";            cc=this.first;        } else if (this.op == 12) {            ss = "CALL";            cc=this.first;        }else if (this.op == 14) {            ss = "SCANF";            cc=this.first;        } else if (this.op == 15) {            ss = "RETURN";            cc=this.first;        }        return (ss + "\t" + cc + "\t" + this.last + "\t" + this.result);    }}

⌨️ 快捷键说明

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