public void Parse()
        {
            const MachineInstructionOperand DontCare = null;

            CheckParse(
                "GR0,#ABCD,GR1", true,
                RAdrXOperand.MakeForUnitTest(
                    RAdrXOpcode,
                    RegisterOperandTest.GR0,
                    AdrXOperand.MakeForUnitTest(new HexaDecimalConstant(0xABCD), RegisterOperandTest.GR1)),
                "r,adr,x の場合");
            CheckParse(
                "GR0,GR1", true,
                R1R2Operand.MakeForUnitTest(
                    R1R2Opcode, RegisterOperandTest.GR0, RegisterOperandTest.GR1),
                "r1,r2 の場合");

            CheckParse(
                "NoSuchRegister,GR0", false, DontCare,
                "最初のオペランドがレジスタでない場合 => 例外");
            CheckParse(
                "GR0#GR1", false, DontCare,
                "区切りが ',' でない場合 => 例外、'GR#GR1' は項目の区切りまでラベルとして読み込まれる");
            CheckParse(
                "GR1,#CDEF,GR0", false, DontCare,
                "x に GR0 は使えない => 例外");
            CheckParse(
                "GR0,'abc'", false, DontCare,
                "2 つめのオペランドがレジスタでもアドレスでもない場合 => 例外");
        }
Exemplo n.º 2
0
        private void CheckGetXR2(
            MachineInstructionOperand target, UInt16 expected, String message)
        {
            UInt16 actual = target.GetXR2();

            Assert.AreEqual(expected, actual, message);
        }
        private void CheckParse(
            String str, Boolean success, MachineInstructionOperand expected, String message)
        {
            MachineInstructionOperand actual = OperandTest.CheckParse(
                (lexer) => RAdrXOrR1R2Operand.Parse(lexer, RAdrXOpcode, R1R2Opcode), str, success, message);

            if (success)
            {
                MachineInstructionOperandTest.Check(expected, actual, Check, message);
            }
        }
        private static void Check(
            MachineInstructionOperand expected, MachineInstructionOperand actual, String message)
        {
            Type expectedType = expected.GetType();

            if (expectedType == typeof(RAdrXOperand))
            {
                RAdrXOperandTest.Check((RAdrXOperand)expected, (RAdrXOperand)actual, message);
            }
            else if (expectedType == typeof(R1R2Operand))
            {
                R1R2OperandTest.Check((R1R2Operand)expected, (R1R2Operand)actual, message);
            }
            else
            {
                Assert.Fail("チェックするオブジェクトが RAdrXOperand でも R1R2Operand でもありません。");
            }
        }
Exemplo n.º 5
0
 public void TestInitialize()
 {
     m_GR1_GR2      = R1R2Operand.MakeForUnitTest(RegisterOperandTest.GR1, RegisterOperandTest.GR2);
     m_GR3_1111_GR4 = RAdrXOperand.MakeForUnitTest(
         RegisterOperandTest.GR3,
         AdrXOperand.MakeForUnitTest(new DecimalConstant(1111), RegisterOperandTest.GR4));
     m_GR3_Eq1234_GR4 = RAdrXOperand.MakeForUnitTest(
         RegisterOperandTest.GR3,
         AdrXOperand.MakeForUnitTest(
             Literal.MakeForUnitTest(new DecimalConstant(1234)), RegisterOperandTest.GR4));
     m_GR5_2222 = RAdrXOperand.MakeForUnitTest(
         RegisterOperandTest.GR5,
         AdrXOperand.MakeForUnitTest(new DecimalConstant(2222), null));
     m_3333_GR6  = AdrXOperand.MakeForUnitTest(new DecimalConstant(3333), RegisterOperandTest.GR6);
     m_EqSTR_GR6 = AdrXOperand.MakeForUnitTest(
         Literal.MakeForUnitTest(new StringConstant("STR")), RegisterOperandTest.GR6);
     m_4444      = AdrXOperand.MakeForUnitTest(new DecimalConstant(4444), null);
     m_GR7       = RegisterOperandTest.GR7;
     m_NoOperand = NoOperand.MakeForUnitTest();
 }
Exemplo n.º 6
0
 private void CheckGetCodeWordCount(MachineInstructionOperand target, Int32 expected, String message)
 {
     ICodeGeneratorTest.CheckGetCodeWordCount(target, expected, message);
 }
Exemplo n.º 7
0
 private void CheckGenerateLiteralDc(
     MachineInstructionOperand target, String expected, String message)
 {
     ICodeGeneratorTest.CheckGenerateLiteralDc(target, expected, message);
 }