예제 #1
0
 private void GetNodesInBlock(ILBlock block)
 {
     foreach (ILNode child in block.GetChildren())
     {
         GetNodes(child);
     }
 }
예제 #2
0
 protected virtual ILBlock VisitBlock(ILBlock block)
 {
     foreach (var child in block.GetChildren())
     {
         Visit(child);
     }
     return(block);
 }
예제 #3
0
		Ast.BlockStatement TransformBlock(ILBlock block)
		{
			Ast.BlockStatement astBlock = new BlockStatement();
			if (block != null) {
				foreach(ILNode node in block.GetChildren()) {
					astBlock.AddRange(TransformNode(node));
				}
			}
			return astBlock;
		}
예제 #4
0
        void FlattenBasicBlocks(ILNode node)
        {
            ILBlock block = node as ILBlock;

            if (block != null)
            {
                List <ILNode> flatBody = new List <ILNode>();
                foreach (ILNode child in block.GetChildren())
                {
                    FlattenBasicBlocks(child);
                    ILBasicBlock childAsBB = child as ILBasicBlock;
                    if (childAsBB != null)
                    {
                        if (!(childAsBB.Body.FirstOrDefault() is ILLabel))
                        {
                            throw new Exception("Basic block has to start with a label. \n" + childAsBB.ToString());
                        }
                        if (childAsBB.Body.LastOrDefault() is ILExpression && !childAsBB.Body.LastOrDefault().IsUnconditionalControlFlow())
                        {
                            throw new Exception("Basci block has to end with unconditional control flow. \n" + childAsBB.ToString());
                        }
                        flatBody.AddRange(childAsBB.GetChildren());
                    }
                    else
                    {
                        flatBody.Add(child);
                    }
                }
                block.EntryGoto = null;
                block.Body      = flatBody;
            }
            else if (node is ILExpression)
            {
                // Optimization - no need to check expressions
            }
            else if (node != null)
            {
                // Recursively find all ILBlocks
                foreach (ILNode child in node.GetChildren())
                {
                    FlattenBasicBlocks(child);
                }
            }
        }
예제 #5
0
		Ast.BlockStatement TransformBlock(ILBlock block)
		{
			Ast.BlockStatement astBlock = new BlockStatement();
			if (block != null) {
				astBlock.HiddenStart = NRefactoryExtensions.CreateHidden(block.ILRanges, astBlock.HiddenStart);
				astBlock.HiddenEnd = NRefactoryExtensions.CreateHidden(block.EndILRanges, astBlock.HiddenEnd);
				foreach(ILNode node in block.GetChildren()) {
					astBlock.Statements.AddRange(TransformNode(node));
				}
			}
			return astBlock;
		}
예제 #6
0
		Ast.BlockStatement TransformBlock(ILBlock block)
		{
			Ast.BlockStatement astBlock = new BlockStatement();
			if (block != null) {
				astBlock.HiddenStart = NRefactoryExtensions.CreateHidden(!context.CalculateILRanges ? null : ILRange.OrderAndJoin(block.ILRanges), astBlock.HiddenStart);
				astBlock.HiddenEnd = NRefactoryExtensions.CreateHidden(!context.CalculateILRanges ? null : ILRange.OrderAndJoin(block.EndILRanges), astBlock.HiddenEnd);
				foreach(ILNode node in block.GetChildren()) {
					var stmt = TransformNode(node);
					if (stmt != null)
						astBlock.Statements.Add(stmt);
				}
			}
			return astBlock;
		}
예제 #7
0
 protected virtual ILBlock VisitBlock(ILBlock block)
 {
     foreach (var child in block.GetChildren())
         Visit(child);
     return block;
 }