public void VisitInstructionVar(CilInstructionVar instruction) { if (instruction is StoreLocalShortInstruction storeLocalShortInstruction) { VisitStoreLocalShortInstruction(storeLocalShortInstruction); } else if (instruction is LoadLocalShortInstruction loadLocalShortInstruction) { VisitLoadLocalShortInstruction(loadLocalShortInstruction); } else if (instruction is LoadLocalAddressShortInstruction loadLocalAddressShortInstruction) { VisitLoadLocalAddressShortInstruction(loadLocalAddressShortInstruction); } else if (instruction is LoadArgumentShortInstruction loadArgumentShortInstruction) { VisitLoadArgumentShortInstruction(loadArgumentShortInstruction); } else if (instruction is StoreArgumentShortInstruction storeArgumentShortInstruction) { VisitStoreArgumentShortInstruction(storeArgumentShortInstruction); } else { throw new ArgumentException($"CIL instruction none cannot be recognized: '{instruction.ToString()}'."); } }
public override void Init(AstContext context, ParseTreeNode parseNode) { // ___("stloc.s") var stlocsChildren = AstChildren.Empty() .Add("stloc.s"); if (stlocsChildren.PopulateWith(parseNode)) { Instruction = new StoreLocalShortInstruction(); return; } // ___("ldloc.s") var ldlocsChildren = AstChildren.Empty() .Add("ldloc.s"); if (ldlocsChildren.PopulateWith(parseNode)) { Instruction = new LoadLocalShortInstruction(); return; } // ___("ldloca.s") var ldlocasChildren = AstChildren.Empty() .Add("ldloca.s"); if (ldlocasChildren.PopulateWith(parseNode)) { Instruction = new LoadLocalAddressShortInstruction(); return; } // ___("ldarg.s") var ldargsChildren = AstChildren.Empty() .Add("ldarg.s"); if (ldargsChildren.PopulateWith(parseNode)) { Instruction = new LoadArgumentShortInstruction(); return; } // ___("starg.s") var stargsChildren = AstChildren.Empty() .Add("starg.s"); if (stargsChildren.PopulateWith(parseNode)) { Instruction = new StoreArgumentShortInstruction(); return; } throw new NotImplementedException(); }