Exemplo n.º 1
0
        public override void Init(AstContext context, ParseTreeNode parseNode)
        {
            // ___("ldc.i4.s")
            var ldci4sChildren = AstChildren.Empty()
                                 .Add("ldc.i4.s");

            if (ldci4sChildren.PopulateWith(parseNode))
            {
                Instruction = new LoadConstI4ShortInstruction();

                return;
            }

            // ___("ldc.i4")
            var ldci4Children = AstChildren.Empty()
                                .Add("ldc.i4");

            if (ldci4Children.PopulateWith(parseNode))
            {
                Instruction = new LoadConstI4Instruction();

                return;
            }

            throw new NotImplementedException();
        }
Exemplo n.º 2
0
 public void VisitInstructionI(CilInstructionI instruction)
 {
     if (instruction is LoadConstI4ShortInstruction loadConstI4ShortInstruction)
     {
         VisitLoadConstI4ShortInstruction(loadConstI4ShortInstruction);
     }
     else if (instruction is LoadConstI4Instruction loadConstI4Instruction)
     {
         VisitLoadConstI4Instruction(loadConstI4Instruction);
     }
     else
     {
         throw new ArgumentException($"CIL instruction i cannot be recognized: '{instruction.ToString()}'.");
     }
 }