Example #1
0
 public void VisitInstructionField(CilInstructionField instruction)
 {
     if (instruction is LoadStaticFieldInstruction loadStaticFieldInstruction)
     {
         VisitLoadStaticFieldInstruction(loadStaticFieldInstruction);
     }
     else if (instruction is StoreStaticFieldInstruction storeStaticFieldInstruction)
     {
         VisitStoreStaticFieldInstruction(storeStaticFieldInstruction);
     }
     else if (instruction is StoreFieldInstruction storeFieldInstruction)
     {
         VisitStoreFieldInstruction(storeFieldInstruction);
     }
     else if (instruction is LoadFieldInstruction loadFieldInstruction)
     {
         VisitLoadFieldInstruction(loadFieldInstruction);
     }
     else if (instruction is LoadFieldAddressInstruction loadFieldAddressInstruction)
     {
         VisitLoadFieldAddressInstruction(loadFieldAddressInstruction);
     }
     else
     {
         throw new ArgumentException($"CIL instruction field cannot be recognized: '{instruction.ToString()}'.");
     }
 }
Example #2
0
        public override void Init(AstContext context, ParseTreeNode parseNode)
        {
            // _("stsfld")
            var stsfldChildren = AstChildren.Empty()
                                 .Add("stsfld");

            if (stsfldChildren.PopulateWith(parseNode))
            {
                Instruction = new StoreStaticFieldInstruction();

                return;
            }

            // _("ldsfld")
            var ldsfldChildren = AstChildren.Empty()
                                 .Add("ldsfld");

            if (ldsfldChildren.PopulateWith(parseNode))
            {
                Instruction = new LoadStaticFieldInstruction();

                return;
            }

            // _("stfld")
            var stfldChildren = AstChildren.Empty()
                                .Add("stfld");

            if (stfldChildren.PopulateWith(parseNode))
            {
                Instruction = new StoreFieldInstruction();

                return;
            }

            // _("ldfld")
            var ldfldChildren = AstChildren.Empty()
                                .Add("ldfld");

            if (ldfldChildren.PopulateWith(parseNode))
            {
                Instruction = new LoadFieldInstruction();

                return;
            }

            // _("ldflda")
            var ldfldaChildren = AstChildren.Empty()
                                 .Add("ldflda");

            if (ldfldaChildren.PopulateWith(parseNode))
            {
                Instruction = new LoadFieldAddressInstruction();

                return;
            }

            throw new NotImplementedException();
        }