예제 #1
0
 private void BuildPhiNodes()
 {
     foreach (KeyValuePair <CILBlock, BlockState> statePair in this.blockStates)
     {
         CILBlock   block = statePair.Key;
         BlockState state = statePair.Value;
         // source count = 0 => eh handlers begin state, having ex object
         if (block.Sources.Count == 0 && state.BeginStack.Length > 0)
         {
             Debug.Assert(state.BeginStack.Length == 1);
             var phi = new ILASTPhi
             {
                 Variable        = state.BeginStack[0],
                 SourceVariables = new[] { state.BeginStack[0] }
             };
             state.ASTTree.Insert(0, phi);
         }
         else if (state.BeginStack.Length > 0)
         {
             for (int varIndex = 0; varIndex < state.BeginStack.Length; varIndex++)
             {
                 var phi = new ILASTPhi {
                     Variable = state.BeginStack[varIndex]
                 };
                 phi.SourceVariables = new ILASTVariable[block.Sources.Count];
                 for (int i = 0; i < phi.SourceVariables.Length; i++)
                 {
                     phi.SourceVariables[i] = this.blockStates[block.Sources[i]].ASTTree.StackRemains[varIndex];
                 }
                 // reverse phi nodes => pop in correct order
                 state.ASTTree.Insert(0, phi);
             }
         }
     }
 }
 private void ProcessPhiNode(ILASTPhi phi) =>
 // TODO: Check all source variables having same type?
 phi.Variable.Type = phi.SourceVariables[0].Type;