public BasicBlock(ControlFlowGraph cfg, int nBlock, int at_instruction, EHInfo copy_ehState_from) { ControlFlowGraph = cfg; InputBlockNum = nBlock; FromInstruction = at_instruction; ToInstruction = at_instruction; Instructions = new List<FlatStatement>(); if (at_instruction>=0) Instructions.Add(ControlFlowGraph.InputInstructions[at_instruction]); if (copy_ehState_from != null) { EHInfo = new LS2IL.EHInfo(copy_ehState_from); } ResetRegisterScan(); }
/// <summary> /// Adds a BasicBlock HEAD instruction to the graph (always a new BasicBlock) /// </summary> /// <param name="nInstruction"></param> /// <param name="ehinfo"></param> void HeadInstruction(int nInstruction, EHInfo ehinfo) { CurrentBasicBlock = new BasicBlock(this, BasicBlocks.Count, nInstruction, ehinfo); BasicBlocks.Add(CurrentBasicBlock); }
public EHInfo(EHInfo oldState,int numTryInstruction, FlatOperand catchesLabel, string ehendLabel) { CatchesLabel = catchesLabel.ImmediateValue.ValueText; ehEndLabel = ehendLabel; PreviousState = oldState; EHPart = EHPart.Try; NumTryInstruction = numTryInstruction; }
public EHInfo(EHInfo oldState,int numTryInstruction, FlatOperand catchesLabel, FlatOperand finallyLabel) { CatchesLabel = catchesLabel.ImmediateValue.ValueText; FinallyLabel = finallyLabel.ImmediateValue.ValueText; PreviousState = oldState; NumTryInstruction = numTryInstruction; EHPart = EHPart.Try; }
public EHInfo(EHInfo copyfrom) { if (copyfrom == null) { EHPart = LS2IL.EHPart.None; NumTryInstruction = -1; return; } EHPart = copyfrom.EHPart; CatchesLabel = copyfrom.CatchesLabel; ehEndLabel = copyfrom.ehEndLabel; FinallyLabel = copyfrom.FinallyLabel; PreviousState = copyfrom.PreviousState; NumTryInstruction = copyfrom.NumTryInstruction; }
/// <summary> /// Adds a BasicBlock TAIL instruction to the graph (terminates the current BasicBlock after adding this instruction) /// </summary> /// <param name="nInstruction"></param> /// <param name="ehinfo"></param> void TailInstruction(int nInstruction, EHInfo ehinfo) { NormalInstruction(nInstruction, ehinfo); CurrentBasicBlock = null; }
/// <summary> /// When hitting a new TRY instruction, this provides stacking behavior with the current exception handling /// </summary> /// <param name="nInstruction"></param> /// <param name="tryInstruction"></param> void PushFinallyState(int nInstruction, FlatStatement tryInstruction) { EHInfo CurrentState = EHState; if (tryInstruction.Operands.Count == 1) { EHState = new EHInfo(CurrentState, nInstruction,tryInstruction.Operands[0], tryInstruction.Comment); } else EHState = new EHInfo(CurrentState, nInstruction, tryInstruction.Operands[0], tryInstruction.Operands[1]); }
/// <summary> /// This closes out an exception handler on the stack /// </summary> void PopFinallyState() { EHState = EHState.PreviousState; }
/// <summary> /// Adds a normal instruction to the graph (new BasicBlock only if we're not already in one) /// </summary> /// <param name="nInstruction"></param> /// <param name="ehinfo"></param> void NormalInstruction(int nInstruction, EHInfo ehinfo) { if (CurrentBasicBlock == null) { HeadInstruction(nInstruction, ehinfo); } else CurrentBasicBlock.Touch(nInstruction); }