当前位置: 首页>>代码示例>>C#>>正文


C# Ast.BlockStatement类代码示例

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


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

示例1: VisitBlockStatement

		public override object VisitBlockStatement(BlockStatement blockStatement, object data)
		{
			foreach(INode statement in blockStatement.Children) {
				statement.AcceptVisitor(this, null);
			}
			return null;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:7,代码来源:EvaluateAstVisitor.cs

示例2: VisitBlockStatement

		public override object VisitBlockStatement(BlockStatement blockStatement, object data)
		{
			Push();
			object result = base.VisitBlockStatement(blockStatement, data);
			Pop();
			return result;
		}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:7,代码来源:PrefixFieldsVisitor.cs

示例3: ConvertBlock

		B.Block ConvertBlock(BlockStatement block)
		{
			B.Block b = new B.Block(GetLexicalInfo(block));
			b.EndSourceLocation = GetLocation(block.EndLocation);
			ConvertStatements(block.Children, b);
			return b;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:7,代码来源:ConvertVisitorStatements.cs

示例4: add_Method

        public static MethodDeclaration add_Method(this TypeDeclaration typeDeclaration, string methodName, Dictionary<string, object> invocationParameters, BlockStatement body)
        {
            var newMethod = new MethodDeclaration
            {
                Name = methodName,
                //Modifier = Modifiers.None | Modifiers.Public | Modifiers.Static,
                Modifier = Modifiers.None | Modifiers.Public,
                Body = body
            };
            newMethod.setReturnType();
            if (invocationParameters != null)

                foreach (var invocationParameter in invocationParameters)
                {
                    var parameterType = new TypeReference(
                        (invocationParameter.Value != null && invocationParameter.Key != "returnData")
                        ? invocationParameter.Value.typeFullName()
                        : "System.Object", true);
                    var parameter = new ParameterDeclarationExpression(parameterType, invocationParameter.Key);
                    newMethod.Parameters.Add(parameter);

                }
            typeDeclaration.AddChild(newMethod);
            return newMethod;
        }
开发者ID:pusp,项目名称:o2platform,代码行数:25,代码来源:MethodDeclaration_ExtensionMethods.cs

示例5: CreateMethodBody

        public BlockStatement CreateMethodBody()
        {
            Ast.BlockStatement astBlock = new Ast.BlockStatement();

            if (methodDef.Body == null) return astBlock;

            List<ILNode> body = new ILAstBuilder().Build(methodDef);

            MethodBodyGraph bodyGraph = new MethodBodyGraph(body);
            bodyGraph.Optimize();

            List<string> intNames = new List<string>(new string[] {"i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t"});
            Dictionary<string, int> typeNames = new Dictionary<string, int>();
            foreach(VariableDefinition varDef in methodDef.Body.Variables) {
                if (string.IsNullOrEmpty(varDef.Name)) {
                    if (varDef.VariableType.FullName == Constants.Int32 && intNames.Count > 0) {
                        varDef.Name = intNames[0];
                        intNames.RemoveAt(0);
                    } else {
                        string name;
                        if (varDef.VariableType.IsArray) {
                            name = "array";
                        } else if (!typeNameToVariableNameDict.TryGetValue(varDef.VariableType.FullName, out name)) {
                            name = varDef.VariableType.Name;
                            // remove the 'I' for interfaces
                            if (name.Length >= 3 && name[0] == 'I' && char.IsUpper(name[1]) && char.IsLower(name[2]))
                                name = name.Substring(1);
                            // remove the backtick (generics)
                            int pos = name.IndexOf('`');
                            if (pos >= 0)
                                name = name.Substring(0, pos);
                            if (name.Length == 0)
                                name = "obj";
                            else
                                name = char.ToLower(name[0]) + name.Substring(1);
                        }
                        if (!typeNames.ContainsKey(name)) {
                            typeNames.Add(name, 0);
                        }
                        int count = typeNames[name];
                        if (count > 0) {
                            name += count.ToString();
                        }
                        varDef.Name = name;
                    }
                }
                localVarTypes[varDef.Name] = varDef.VariableType;
                localVarDefined[varDef.Name] = false;

            //				Ast.VariableDeclaration astVar = new Ast.VariableDeclaration(varDef.Name);
            //				Ast.LocalVariableDeclaration astLocalVar = new Ast.LocalVariableDeclaration(astVar);
            //				astLocalVar.TypeReference = new Ast.TypeReference(varDef.VariableType.FullName);
            //				astBlock.Children.Add(astLocalVar);
            }

            astBlock.Children.AddRange(TransformNodes(bodyGraph.Childs));

            return astBlock;
        }
开发者ID:almazik,项目名称:ILSpy,代码行数:59,代码来源:AstMetodBodyBuilder.cs

示例6: TrackedVisitBlockStatement

 public override object TrackedVisitBlockStatement(BlockStatement blockStatement, object data)
 {
     blockStatement.Children.Clear();
     TypeReference notImplmentedException = new TypeReference("System.NotImplementedException");
     ObjectCreateExpression objectCreate = new ObjectCreateExpression(notImplmentedException, new List<Expression>());
     blockStatement.Children.Add(new ThrowStatement(objectCreate));
     return null;
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:8,代码来源:StubTransformer.cs

示例7: VisitBlockStatement

 public override object VisitBlockStatement(BlockStatement blockStatement, object data)
 {
     foreach (Statement st in blockStatement.Children)
     {
         st.Parent = blockStatement;
     }
     return base.VisitBlockStatement(blockStatement, data);
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:8,代码来源:ParentVisitor.cs

示例8: GenerateAstToInsert

		AbstractNode GenerateAstToInsert(string variableName)
		{
			var block = new BlockStatement();
			block.AddChild(new ExpressionStatement(new IdentifierExpression(caretMarker)));
			return new IfElseStatement(
				new BinaryOperatorExpression(new IdentifierExpression(variableName), BinaryOperatorType.InEquality, new PrimitiveExpression(null)),
				block);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:8,代码来源:CheckAssignmentNotNull.cs

示例9: CreateEmptyBlockStatement

        public static BlockStatement CreateEmptyBlockStatement(string returnTypeName)
        {
            var block = new BlockStatement();

            if (!IsVoid(returnTypeName))
                block.AddChildren(new ReturnStatement(new DefaultValueExpression(CreateTypeReference(returnTypeName))));

            return block;
        }
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:9,代码来源:NRefactoryUtility.cs

示例10: VisitBlockStatement

        public override object VisitBlockStatement(BlockStatement blockStatement, object data)
        {
            Contract.Requires(blockStatement != null);

            // Visit children of block statement (E.g. several ExpressionStatement objects)
            blockStatement.AcceptChildren(this, data);

            return null;
        }
开发者ID:chinaniit,项目名称:KnockoutGenerator,代码行数:9,代码来源:AstVisitor.cs

示例11: VisitBlockStatement

 public override object VisitBlockStatement(BlockStatement blockStatement, object data)
 {
     for(int i = 0; i < blockStatement.Children.Count; i++) {
         if (blockStatement.Children[i] is Statement &&
             ((Statement)blockStatement.Children[i]).IsNull)
         {
             blockStatement.Children.RemoveAt(i);
             i--;
         }
     }
     return base.VisitBlockStatement(blockStatement, data);
 }
开发者ID:almazik,项目名称:ILSpy,代码行数:12,代码来源:RemoveEmptyElseBody.cs

示例12: CreateMetodBody

 public static BlockStatement CreateMetodBody(MethodDefinition methodDef)
 {
     AstMetodBodyBuilder builder = new AstMetodBodyBuilder();
     builder.methodDef = methodDef;
     try {
         return builder.CreateMethodBody();
     } catch {
         BlockStatement block = new BlockStatement();
         block.Children.Add(MakeComment("Exception during decompilation"));
         return block;
     }
 }
开发者ID:almazik,项目名称:ILSpy,代码行数:12,代码来源:AstMetodBodyBuilder.cs

示例13: GetModifiedName

 private string GetModifiedName(BlockStatement blockStatement, string identifier)
 {
     int hashCode;
     while (blockStatement != null)
     {
         hashCode = blockStatement.GetHashCode();
         string identifierHash = identifier + "_" + hashCode;
         if (renamedVariables.Contains(identifierHash))
             return (string) renamedVariables[identifierHash];
         else
             blockStatement = (BlockStatement) AstUtil.GetParentOfType(blockStatement, typeof(BlockStatement));
     }
     return null;
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:14,代码来源:RenameRepeatedVariableTransformer.cs

示例14: ast_CSharp_CreateCompilableClass

        public static string ast_CSharp_CreateCompilableClass(this BlockStatement blockStatement, SnippetParser snippetParser, string codeSnippet,
            CSharp_FastCompiler_CompilerOptions   compilerOptions,
            CSharp_FastCompiler_CompilerArtifacts compilerArtifacts,
            CSharp_FastCompiler_ExecutionOptions  executionOptions)
        {
            if (blockStatement.isNull() || compilerOptions.isNull())
                return null;

            var compilationUnit= compilerArtifacts.CompilationUnit = new CompilationUnit();

            compilationUnit.add_Type(compilerOptions.default_TypeName)
                .add_Method(compilerOptions.default_MethodName, executionOptions.InvocationParameters,
                    compilerOptions.ResolveInvocationParametersType, blockStatement);

            // remove comments from parsed code
            var astCSharp = compilerArtifacts.AstCSharp = new Ast_CSharp(compilerArtifacts.CompilationUnit, snippetParser.Specials);

            // add references included in the original source code file
            compilerArtifacts.AstCSharp.mapCodeO2References(compilerOptions);

            astCSharp.mapAstDetails();

            astCSharp.ExtraSpecials.Clear();
            var method     = compilationUnit.method(compilerOptions.default_MethodName);
            var returntype = method.returnType();
            var type       = compilationUnit.type(compilerOptions.default_TypeName);

            type.Children.Clear();
            var tempBlockStatement = new BlockStatement();
            tempBlockStatement.add_Variable("a", 0);
            method.Body = tempBlockStatement;
            var newMethod = type.add_Method(compilerOptions.default_MethodName, executionOptions.InvocationParameters,
                compilerOptions.ResolveInvocationParametersType, tempBlockStatement);
            newMethod.TypeReference = returntype;

            if(blockStatement.returnStatements().size() >1)
                astCSharp.methodDeclarations().first().remove_LastReturnStatement();

            astCSharp.mapAstDetails();

            var codeToReplace = "Int32 a = 0;";
            var csharpCode = astCSharp.AstDetails.CSharpCode
                .replace("\t\t{0}".format(codeToReplace), codeToReplace)    // remove tabs
                .replace("Int32 a = 0;", codeSnippet);                      // put the actual code (this should be done via AST, but it was affectting code complete)
            return csharpCode;
        }
开发者ID:njmube,项目名称:FluentSharp,代码行数:46,代码来源:Ast_CSharp_ExtensionMethods_Code_Generation.cs

示例15: TrackedVisitBlockStatement

 public override object TrackedVisitBlockStatement(BlockStatement blockStatement, object data)
 {
     BlockStatement replaced = blockStatement;
     InsertionBlockData insertionBlockData = new InsertionBlockData();
     base.TrackedVisitBlockStatement(blockStatement, insertionBlockData);
     if (insertionBlockData.Block != null && insertionBlockData.Statements.Count > 0)
     {
         if (blockStatement.GetHashCode() == insertionBlockData.Block.GetHashCode())
         {
             IList<INode> nodes = new List<INode>();
             foreach (Statement node in insertionBlockData.Statements)
                 nodes.Add(node);
             replaced.Children.InsertRange(insertionBlockData.BlockChildIndex, nodes);
             ReplaceCurrentNode(replaced);
         }
     }
     return null;
 }
开发者ID:sourcewarehouse,项目名称:janett,代码行数:18,代码来源:ArrayInitializerTransformer.cs


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