package com.ninty.cmd;

/**
 * Created by ninty on 2017/7/16.
 */
public class CmdComparisons {
}

@@ -21,78 +21,2161 @@
 d;%0A%0A
-/**%0A * Created by ninty on 2017/7/16.%0A */%0Apublic class CmdComparisons %7B
+import com.ninty.cmd.base.BranchCmd;%0Aimport com.ninty.cmd.base.NoOperandCmd;%0Aimport com.ninty.runtime.NiFrame;%0Aimport com.ninty.runtime.OperandStack;%0A%0A/**%0A * Created by ninty on 2017/7/16.%0A */%0Apublic class CmdComparisons %7B%0A%0A    static void fcmp(NiFrame frame, int ifNaN) %7B%0A        OperandStack stack = frame.getOperandStack();%0A        float num1 = stack.popFloat();%0A        float num2 = stack.popFloat();%0A        if (Float.isNaN(num1) %7C%7C Float.isNaN(num2)) %7B%0A            stack.pushInt(ifNaN);%0A        %7D else %7B%0A            stack.pushInt(num1 %3E num2 ? 1 : (num1 == num2 ? 0 : -1));%0A        %7D%0A    %7D%0A%0A    static void dcmp(NiFrame frame, int ifNaN) %7B%0A        OperandStack stack = frame.getOperandStack();%0A        double num1 = stack.popDouble();%0A        double num2 = stack.popDouble();%0A        if (Double.isNaN(num1) %7C%7C Double.isNaN(num2)) %7B%0A            stack.pushInt(ifNaN);%0A        %7D else %7B%0A            stack.pushInt(num1 %3E num2 ? 1 : (num1 == num2 ? 0 : -1));%0A        %7D%0A    %7D%0A%0A    static class LCMP extends NoOperandCmd %7B%0A        @Override%0A        public void exec(NiFrame frame) %7B%0A            OperandStack stack = frame.getOperandStack();%0A            long num1 = stack.popLong();%0A            long num2 = stack.popLong();%0A            stack.pushInt(num1 %3E num2 ? 1 : (num1 == num2 ? 0 : -1));%0A        %7D%0A    %7D%0A%0A    static class FCMPL extends NoOperandCmd %7B%0A        @Override%0A        public void exec(NiFrame frame) %7B%0A            fcmp(frame, -1);%0A        %7D%0A    %7D%0A%0A    static class FCMPG extends NoOperandCmd %7B%0A        @Override%0A        public void exec(NiFrame frame) %7B%0A            fcmp(frame, 1);%0A        %7D%0A    %7D%0A%0A    static class DCMPL extends NoOperandCmd %7B%0A        @Override%0A        public void exec(NiFrame frame) %7B%0A            fcmp(frame, -1);%0A        %7D%0A    %7D%0A%0A    static class DCMPG extends NoOperandCmd %7B%0A        @Override%0A        public void exec(NiFrame frame) %7B%0A            fcmp(frame, 1);%0A        %7D%0A    %7D%0A%0A    static class IFEQ extends BranchCmd %7B%0A        @Override%0A        public void exec(NiFrame frame) %7B%0A            OperandStack stack = frame.getOperandStack();%0A            int val = stack.popInt();%0A            // TODO branch%0A        %7D%0A    %7D
 %0A%7D%0A

complete base cmp