コード例 #1
0
ファイル: Instructions.cs プロジェクト: dbremner/perwapi
 /*-------------------- Constructors ---------------------------------*/
 public BranchInstr(BranchOp inst, CILLabel dst)
     : base((uint)inst)
 {
     dest = dst;
       shortVer = (inst < BranchOp.br) || (inst == BranchOp.leave_s);
       if (shortVer)
     size++;
       else
     size += 4;
 }
コード例 #2
0
ファイル: CodeBlocks.cs プロジェクト: dbremner/perwapi
 /*-------------------- Constructors ---------------------------------*/
 protected HandlerBlock(CILLabel start, CILLabel end)
     : base(start, end)
 {
 }
コード例 #3
0
ファイル: CodeBlocks.cs プロジェクト: dbremner/perwapi
 /*-------------------- Constructors ---------------------------------*/
 /// <summary>
 /// Create a new finally clause
 /// </summary>
 /// <param name="finallyStart">start of finally code</param>
 /// <param name="finallyEnd">end of finally code</param>
 public Finally(CILLabel finallyStart, CILLabel finallyEnd)
     : base(finallyStart, finallyEnd)
 {
 }
コード例 #4
0
ファイル: CodeBlocks.cs プロジェクト: dbremner/perwapi
 /*-------------------- Constructors ---------------------------------*/
 /// <summary>
 /// Create a new filter clause
 /// </summary>
 /// <param name="filterLabel">the label where the filter code starts</param>
 /// <param name="handlerStart">the start of the handler code</param>
 /// <param name="handlerEnd">the end of the handler code</param>
 public Filter(CILLabel filterLabel, CILLabel handlerStart,
     CILLabel handlerEnd)
     : base(handlerStart, handlerEnd)
 {
     this.filterLabel = filterLabel;
 }
コード例 #5
0
ファイル: CodeBlocks.cs プロジェクト: dbremner/perwapi
 /*-------------------- Constructors ---------------------------------*/
 /// <summary>
 /// Create a new fault clause
 /// </summary>
 /// <param name="faultStart">start of the fault code</param>
 /// <param name="faultEnd">end of the fault code</param>
 public Fault(CILLabel faultStart, CILLabel faultEnd)
     : base(faultStart, faultEnd)
 {
 }
コード例 #6
0
ファイル: CodeBlocks.cs プロジェクト: dbremner/perwapi
 /*-------------------- Constructors ---------------------------------*/
 protected CodeBlock(CILLabel start, CILLabel end)
 {
     Contract.Requires(start != null);
     Contract.Requires(end != null);
     this.start = start;
     this.end = end;
 }
コード例 #7
0
ファイル: Instructions.cs プロジェクト: dbremner/perwapi
 public void SetDest(CILLabel lab)
 {
     dest = lab;
 }
コード例 #8
0
ファイル: Instructions.cs プロジェクト: dbremner/perwapi
 internal void MakeTargetLabel(SCG.List<CILLabel> labs)
 {
     uint targetOffset = (uint)(offset + size + target);
       dest = CILInstructions.GetLabel(labs, targetOffset);
 }
コード例 #9
0
ファイル: Instructions.cs プロジェクト: dbremner/perwapi
 /// <summary>
 /// Add a label to the CIL instructions
 /// </summary>
 /// <param name="lab">the label to be added</param>
 public void CodeLabel(CILLabel lab)
 {
     Contract.Requires(lab != null);
     if (lab.Buffer == null) {
     lab.Buffer = this;
       }
       else if (lab.Buffer != this) {
     throw new DescriptorException("Cannot add a label to two different code buffers");
       }
       AddToBuffer(lab);
 }
コード例 #10
0
ファイル: Instructions.cs プロジェクト: dbremner/perwapi
 /// <summary>
 /// Add a branch instruction
 /// </summary>
 /// <param name="inst">the branch instruction</param>
 /// <param name="lab">the label that is the target of the branch</param>
 public void Branch(BranchOp inst, CILLabel lab)
 {
     Contract.Requires(lab != null);
     AddToBuffer(new BranchInstr(inst, lab));
 }
コード例 #11
0
ファイル: Instructions.cs プロジェクト: dbremner/perwapi
 public void SetDests(CILLabel[] dests)
 {
     cases = dests;
 }
コード例 #12
0
ファイル: Instructions.cs プロジェクト: dbremner/perwapi
 /*-------------------- Constructors ---------------------------------*/
 public SwitchInstr(CILLabel[] dsts)
     : base(0x45)
 {
     cases = dsts;
       if (cases != null) numCases = (uint)cases.Length;
       size += 4 + (numCases * 4);
 }
コード例 #13
0
ファイル: Instructions.cs プロジェクト: dbremner/perwapi
 internal static CILLabel GetLabel(SCG.List<CILLabel> labs, uint targetOffset)
 {
     CILLabel lab;
       int i = 0;
       while ((i < labs.Count) && (((CILLabel)labs[i]).offset < targetOffset)) i++;
       if (i < labs.Count) {
     if (((CILLabel)labs[i]).offset == targetOffset) // existing label
       lab = (CILLabel)labs[i];
     else {
       lab = new CILLabel(targetOffset);
       labs.Insert(i, lab);
     }
       }
       else {
     lab = new CILLabel(targetOffset);
     labs.Add(lab);
       }
       return lab;
 }
コード例 #14
0
ファイル: Instructions.cs プロジェクト: dbremner/perwapi
 /// <summary>
 /// Add a switch instruction
 /// </summary>
 /// <param name="labs">the target labels for the switch</param>
 public void Switch(CILLabel[] labs)
 {
     Contract.Requires(labs != null);
     AddToBuffer(new SwitchInstr(labs));
 }
コード例 #15
0
ファイル: CodeBlocks.cs プロジェクト: dbremner/perwapi
 /*-------------------- Constructors ---------------------------------*/
 /// <summary>
 /// Create a new try block
 /// </summary>
 /// <param name="start">start label for the try block</param>
 /// <param name="end">end label for the try block</param>
 public TryBlock(CILLabel start, CILLabel end)
     : base(start, end)
 {
 }
コード例 #16
0
ファイル: Instructions.cs プロジェクト: dbremner/perwapi
 /// <summary>
 /// Mark this position as the end of the last started block and
 /// make it a filter block.  This filter block is associated with the
 /// specified try block.  The format is:
 /// filterLab:   ...
 ///              ...
 /// filterHandler :  ...
 ///                  ...             
 /// </summary>
 /// <param name="filterLab">the label where the filter code is</param>
 /// <param name="tryBlock">the try block associated with this filter block</param>
 public void EndFilterBlock(CILLabel filterLab, TryBlock tryBlock)
 {
     Filter filBlock = new Filter(filterLab, (CILLabel)blockStack.Pop(), NewCodedLabel());
       tryBlock.AddHandler(filBlock);
 }
コード例 #17
0
ファイル: CodeBlocks.cs プロジェクト: dbremner/perwapi
 /*-------------------- Constructors ---------------------------------*/
 /// <summary>
 /// Create a new catch clause
 /// </summary>
 /// <param name="except">the exception to be caught</param>
 /// <param name="handlerStart">start of the handler code</param>
 /// <param name="handlerEnd">end of the handler code</param>
 public Catch(Class except, CILLabel handlerStart, CILLabel handlerEnd)
     : base(handlerStart, handlerEnd)
 {
     exceptType = except;
 }
コード例 #18
0
ファイル: Instructions.cs プロジェクト: dbremner/perwapi
 /// <summary>
 /// Create a new label at this position in the code buffer
 /// </summary>
 /// <returns>the label at the current position</returns>
 public CILLabel NewCodedLabel()
 {
     CILLabel lab = new CILLabel();
       lab.Buffer = this;
       AddToBuffer(lab);
       return lab;
 }