• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Statements.BlockStatement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Telerik.JustDecompiler.Ast.Statements.BlockStatement的典型用法代码示例。如果您正苦于以下问题:C# BlockStatement类的具体用法?C# BlockStatement怎么用?C# BlockStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BlockStatement类属于Telerik.JustDecompiler.Ast.Statements命名空间,在下文中一共展示了BlockStatement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ProcessBlock

		void ProcessBlock (BlockStatement node)
		{
			for (int i = 0; i < node.Statements.Count - 1; i++)
			{
				var matcher = new UsingMatcher(node.Statements[i], node.Statements[i + 1]);
				if (!matcher.Match ())
					continue;

                if (matcher.VariableReference != null)
                {
                    context.MethodContext.RemoveVariable(matcher.VariableReference);
                }
				if (matcher.RemoveExpression)
				{
					node.Statements.RemoveAt(i); // declaration
					node.Statements.RemoveAt(i); // try
					node.AddStatementAt(i, matcher.Using);
				}
				else
				{
					int index = i + (matcher.HasExpression ? 1 : 0);
					node.Statements.RemoveAt(index); // try
					node.AddStatementAt(index, matcher.Using);
				}
				ProcessBlock(matcher.Using.Body);
			}
		}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:27,代码来源:RebuildUsingStatements.cs


示例2: TryRemoveConditionVariable

		private void TryRemoveConditionVariable(BlockStatement node, Statement statement, int index)
		{
			if (!(statement is ExpressionStatement))
				return;

			var expressionStatement = (ExpressionStatement) statement;
			if (!(expressionStatement.Expression.CodeNodeType == CodeNodeType.BinaryExpression &&
                (expressionStatement.Expression as BinaryExpression).IsAssignmentExpression))
				return;

			var assingExpression = (BinaryExpression) expressionStatement.Expression;

			if (!(assingExpression.Left is VariableReferenceExpression))
				return;

            if (assingExpression.Right is MethodInvocationExpression)
            {
                var variable = assingExpression.Left as VariableReferenceExpression;

                if (variable.Variable.VariableType.Name != TypeCode.Boolean.ToString())
                    return;
            }

			var variableReferenceExpression = (VariableReferenceExpression) assingExpression.Left;
			if (ContainsKey(variableReferenceExpression.Variable))
			{
				methodContext.RemoveVariable(variableReferenceExpression.Variable);
				node.Statements.RemoveAt(index);
			}
		}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:30,代码来源:RemoveConditionOnlyVariables.cs


示例3: Process

 /// <summary>
 /// The entry point for the step.
 /// </summary>
 /// <param name="context">The decompilation context.</param>
 /// <param name="body">The body of the method.</param>
 /// <returns>Returns the updated body of the method.</returns>
 public BlockStatement Process(DecompilationContext context, BlockStatement body)
 {
     MethodSpecificContext methodContext = context.MethodContext;
     foreach (int key in methodContext.Expressions.BlockExpressions.Keys)
     {
         IList<Expression> expressionList = methodContext.Expressions.BlockExpressions[key];
         Code lastInstructionCode = methodContext.ControlFlowGraph.InstructionToBlockMapping[key].Last.OpCode.Code;
         bool endsWithConditionalJump = lastInstructionCode == Code.Brtrue || lastInstructionCode == Code.Brtrue_S ||
                                        lastInstructionCode == Code.Brfalse || lastInstructionCode == Code.Brfalse_S;
         for (int i = 0; i < expressionList.Count; i++)
         {
             expressionList[i] = (Expression)Visit(expressionList[i]);
         }
         if (endsWithConditionalJump)
         {
             expressionList[expressionList.Count - 1] = (Expression)
                 FixBranchingExpression(expressionList[expressionList.Count - 1], methodContext.ControlFlowGraph.InstructionToBlockMapping[key].Last);
         }
         //if (lastInstructionCode == Code.Switch)
         //{
         //    //the type of this expression is needed if the switch instruction causes IrregularSwitchLC
         //    //so that correct expressions can be produced for case's conditions
         //    //Expression lastExpression = expressionList[expressionList.Count - 1];
         //}
     }
     return body;
 }
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:33,代码来源:FixBinaryExpressionsStep.cs


示例4: Process

		public BlockStatement Process(DecompilationContext context, BlockStatement body)
		{
			MethodDefinition method = context.MethodContext.Method;
			if (method.Name == "Finalize" && method.IsVirtual)
			{
				if (body.Statements.Count == 1 && body.Statements[0] is TryStatement)
				{
					TryStatement tryFinally = body.Statements[0] as TryStatement;

					if (tryFinally.Finally != null && tryFinally.Finally.Body.Statements.Count == 1 && tryFinally.Finally.Body.Statements[0] is ExpressionStatement)
					{
						ExpressionStatement finallyStatementExpressionStatement = tryFinally.Finally.Body.Statements[0] as ExpressionStatement;

						if (finallyStatementExpressionStatement.Expression is MethodInvocationExpression)
						{
							MethodDefinition baseDestructor = (finallyStatementExpressionStatement.Expression as MethodInvocationExpression).MethodExpression.MethodDefinition;

							if (baseDestructor != null)
							{
								if (baseDestructor.Name == "Finalize" && baseDestructor.DeclaringType.FullName == method.DeclaringType.BaseType.FullName)
								{
									context.MethodContext.IsDestructor = true;
									context.MethodContext.DestructorStatements = new BlockStatement() { Statements = tryFinally.Try.Statements };
								}
							}
						}
					}

				}
			}

			return body;
		}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:33,代码来源:DetermineDestructorStep.cs


示例5: ProcessBlock

		void ProcessBlock (BlockStatement node)
		{
			for (int i = 0; i < node.Statements.Count - 1; i++)
			{
				ForeachArrayMatcher matcher = new ForeachArrayMatcher(node.Statements[i], node.Statements[i + 1], this.context.MethodContext);
				if (!matcher.Match())
				{
					continue;
				}

				if (CheckForIndexUsages(matcher))
				{
					continue;
				}

				context.MethodContext.RemoveVariable(matcher.Incrementor);
				if (matcher.CurrentVariable != null)
				{
					context.MethodContext.RemoveVariable(matcher.CurrentVariable);
				}

				node.Statements.RemoveAt(i);
				node.Statements.RemoveAt(i);
				node.AddStatementAt(i, matcher.Foreach);
				ProcessBlock(matcher.Foreach.Body);
			}
		}
开发者ID:besturn,项目名称:JustDecompileEngine,代码行数:27,代码来源:RebuildForeachArrayStatements.cs


示例6: Process

 public BlockStatement Process(DecompilationContext context, BlockStatement body)
 {
     this.context = context;
     this.typeSystem = context.MethodContext.Method.Module.TypeSystem;
     InsertTopLevelParameterAssignments(body);
     return body;
 }
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:7,代码来源:AssignOutParametersStep.cs


示例7: VisitBlockStatement

		public override void VisitBlockStatement (BlockStatement node)
		{
			ProcessBlock (node);

			foreach (var statement in node.Statements)
				Visit (statement);
		}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:7,代码来源:RebuildUsingStatements.cs


示例8: ForStatement

 public ForStatement(Expression initializer, Expression condition, Expression increment, BlockStatement body)
     : base(condition)
 {
     this.Initializer = initializer;
     this.Increment = increment;
     this.Body = body;
 }
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:7,代码来源:ForStatement.cs


示例9: Process

 public BlockStatement Process(DecompilationContext context, BlockStatement body)
 {
     theRebuilder = new AnonymousDelegateRebuilder(context, body);
     VisitBlockStatement(body);
     theRebuilder.CleanUpVariableCopyAssignments();
     return body;
 }
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:7,代码来源:RebuildAnonymousDelegatesStep.cs


示例10: VisitBlockStatement

        public override void VisitBlockStatement(BlockStatement node)
        {
            for (int i = 0; i < node.Statements.Count; i++)
            {
                if (!Match(node.Statements, i))
                    continue;

                // repalce try with lock
                node.Statements.RemoveAt(i);
                node.AddStatementAt(i, Lock);

                //RemoveFlagVariable(i - 1, node, theFlagVariable);

                if (this.lockType == LockType.Simple)
                {
                    node.Statements.RemoveAt(i + 1); //the try
                    node.Statements.RemoveAt(--i); // the second assign
                    node.Statements.RemoveAt(--i); // the first assign
                }
                else // LockType.WithFlag
                {
                    Lock.Body.Statements.RemoveAt(0); // the first assign
                    Lock.Body.Statements.RemoveAt(0); // the second assign
                    Lock.Body.Statements.RemoveAt(0); // the method invoke
                    if(i > 0)
                    {
                        node.Statements.RemoveAt(--i);
                    }
                }
            }

            Visit(node.Statements);
        }
开发者ID:saravanaram,项目名称:JustDecompileEngine,代码行数:33,代码来源:RebuildLockStatements.cs


示例11: Process

		public BlockStatement Process(DecompilationContext context, BlockStatement block)
		{
            this.typeSystem = context.MethodContext.Method.Module.TypeSystem;
			this.context = context;
            BlockStatement newBlock = (BlockStatement)VisitBlockStatement(block);
            return newBlock;
		}
开发者ID:besturn,项目名称:JustDecompileEngine,代码行数:7,代码来源:RenameEnumValues.cs


示例12: RunInternal

        protected BlockStatement RunInternal(MethodBody body, BlockStatement block, ILanguage language)
        {
            try
            {
                if (body.Instructions.Count != 0 || body.Method.IsJustDecompileGenerated)
                {
                    foreach (IDecompilationStep step in steps)
                    {
                        if (language != null && language.IsStopped)
                        {
                            break;
                        }

                        block = step.Process(Context, block);
                    }
                }
            }
            finally
            {
                if (Context.MethodContext.IsMethodBodyChanged)
                {
                    body.Method.RefreshBody();
                }
            }

            return block;
        }
开发者ID:is00hcw,项目名称:JustDecompileEngine,代码行数:27,代码来源:DecompilationPipeline.cs


示例13: FilterMethodToBeDecompiled

 public FilterMethodToBeDecompiled(MethodDefinition method, CatchClause catchClause, DecompilationContext context, BlockStatement block)
 {
     this.Method = method;
     this.CatchClause = catchClause;
     this.Context = context;
     this.Block = block;
 }
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:7,代码来源:FilterMethodToBeDecompiled.cs


示例14: CheckDictionaryIfBody

		private bool CheckDictionaryIfBody(BlockStatement then)
		{
			/// Check for the pattern
			/// someVariable = new Dictionary<string,int>();
			/// someVariable.Add("SomeString",0);
			/// <moreAdds>
			/// conditionField = someField;
			if (then.Statements.Count < 1)
			{ 
				return false;
			}
			VariableReferenceExpression localDictionaryVariable;
			if (!CheckDictionaryCreation(then.Statements[0], out localDictionaryVariable ))
			{
				return false;
			}
			if (localDictionaryVariable == null)
			{
				// sanity check.
				return false;
			}

			for (int i = 1; i < then.Statements.Count - 1; i++)
			{
				// check push expressions
				if (!CheckDictionaryAdd(then.Statements[i], localDictionaryVariable))
				{
					return false;
				}
			}

			return CheckDictionaryFieldAssignExpression(then.Statements[then.Statements.Count - 1], localDictionaryVariable);
		}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:33,代码来源:SwitchByStringMatcher.cs


示例15: Process

		public BlockStatement Process(DecompilationContext context, BlockStatement body)
		{
			this.typeSystem = context.MethodContext.Method.Module.TypeSystem;
			this.decompiledMethodReturnType = context.MethodContext.Method.ReturnType;
			Visit(body);
			return body;
		}
开发者ID:besturn,项目名称:JustDecompileEngine,代码行数:7,代码来源:CastEnumsToIntegersStep.cs


示例16: Process

		public BlockStatement Process(DecompilationContext context, BlockStatement block)
		{
			this.context = context;
			fixer = new SwitchByStringFixer(context.MethodContext.Method.Module.TypeSystem);
			Visit(block);
			return block;
		}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:7,代码来源:RebuildSwitchByString.cs


示例17: InsertTopLevelDeclarations

		private void InsertTopLevelDeclarations(BlockStatement block)
		{
			int insertIndex = 0;
			if (context.MethodContext.Method.IsConstructor)
			{
				insertIndex = GetIndexOfCtorCall(block) + 1;
			}
			for (int i = 0; i < methodVariables.Count; i++, insertIndex++)
			{
                AssignmentType assignmentType;
                bool hasAssignmentData = this.context.MethodContext.VariableAssignmentData.TryGetValue(methodVariables[i], out assignmentType);
                if (hasAssignmentData && assignmentType == AssignmentType.NotUsed)
                {
                    --insertIndex;
                    continue;
                }

				bool isFirstUsageAssignment;
				if (variableReferences.TryGetValue(methodVariables[i], out isFirstUsageAssignment))
				{
					if (!isFirstUsageAssignment || hasAssignmentData && assignmentType == AssignmentType.NotAssigned)
					{
						InsertVariableDeclarationAndAssignment(block, insertIndex, i);
						continue;
					}
				}
				InsertVariableDeclaration(block, insertIndex, i);
			}
		}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:29,代码来源:DeclareTopLevelVariables.cs


示例18: Process

		public BlockStatement Process(DecompilationContext context, BlockStatement body)
		{		
			MethodDefinition method = context.MethodContext.Method;
			if (method.IsGetter || method.IsSetter)
			{
				PropertyDefinition property;
				if (!context.TypeContext.MethodToPropertyMap.TryGetValue(method, out property))
				{
					throw new Exception("PropertyDefinition not found in method to property map.");
				}

				if (property.ShouldStaySplit())
				{
					string methodDefinitionNewName = Constants.JustDecompileGenerated + "_" + method.Name;
					context.TypeContext.MethodDefinitionToNameMap.Add(method, methodDefinitionNewName);

					FieldDefinition backingField = Utilities.GetCompileGeneratedBackingField(property);
					if (backingField != null)
					{
						string backingFieldNewName = backingField.Name.Replace("<" + property.Name + ">", Constants.JustDecompileGenerated + "_" + property.Name + "_");
						if (!context.TypeContext.BackingFieldToNameMap.ContainsKey(backingField))
						{
							context.TypeContext.BackingFieldToNameMap.Add(backingField, backingFieldNewName);
						}
					}
				}
			}

			return body;
		}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:30,代码来源:RenameSplitPropertiesMethodsAndBackingFields.cs


示例19: CatchClause

        public CatchClause(BlockStatement body, TypeReference type, VariableDeclarationExpression variable, Statement filter = null)
        {
            this.Body = body;
            this.Type = type;
            this.Variable = variable;
            this.Filter = filter;
		}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:7,代码来源:CatchClause.cs


示例20: Process

        private BlockStatement body;///This is left to make debugging easier

        public BlockStatement Process(DecompilationContext context, BlockStatement body)
        {
            this.methodContext = context.MethodContext;
            this.body = body;
            RemoveGotoStatements();
            return body;
        }
开发者ID:larryhou,项目名称:JustDecompileEngine,代码行数:9,代码来源:GotoCancelation.cs



注:本文中的Telerik.JustDecompiler.Ast.Statements.BlockStatement类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# JustMock.PrivateAccessor类代码示例发布时间:2022-05-26
下一篇:
C# Expressions.MethodInvocationExpression类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap