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

C# AST类代码示例

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

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



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

示例1: Visit

        public override void Visit(AST.MethodDeclNode node)
        {
            MethodBeingVisited = ClassBeingVisited.Methods.Lookup(node.methodName.name);

            if (node.paramDeclList != null)
                foreach (AST.ParamDeclNode paramDecl in node.paramDeclList)
                    paramDecl.Accept(this);

            if (node.variableDeclList != null)
                foreach (AST.VariableDeclNode variableDecl in node.variableDeclList)
                    variableDecl.Accept(this);

            if (node.statementList != null)
            {
                var reverseList = node.statementList.statementList;
                reverseList.Reverse();

                HashSet<AST.IdentifierNode> afterLiveness = new HashSet<AST.IdentifierNode>();

                foreach (AST.StatementNode statement in reverseList)
                {
                    m_R.Clear();
                    m_W.Clear();
                    statement.Accept(this);
                    afterLiveness.ExceptWith(m_W);
                    afterLiveness.UnionWith(m_R);

                    m_livenessAtNode[statement] = new HashSet<AST.IdentifierNode>(afterLiveness);
                }
            }
        }
开发者ID:ssarangi,项目名称:minijava,代码行数:31,代码来源:LivenessVisitor.cs


示例2: VisitFunctionDecl

        public override bool VisitFunctionDecl(AST.Function function)
        {
            if (!VisitDeclaration(function))
                return false;

            if (function.IsAmbiguous)
                return false;

            var overloads = function.Namespace.GetOverloads(function);

            foreach (var overload in overloads)
            {
                if (function.OperatorKind == CXXOperatorKind.Conversion)
                    continue;
                if (function.OperatorKind == CXXOperatorKind.ExplicitConversion)
                    continue;

                if (overload == function) continue;

                if (!overload.IsGenerated) continue;

                if (CheckConstnessForAmbiguity(function, overload) ||
                    CheckDefaultParametersForAmbiguity(function, overload))
                {
                    function.IsAmbiguous = true;
                    overload.IsAmbiguous = true;
                }
            }

            if (function.IsAmbiguous)
                Driver.Diagnostics.Debug("Found ambiguous overload: {0}",
                    function.QualifiedOriginalName);

            return true;
        }
开发者ID:daxiazh,项目名称:CppSharp,代码行数:35,代码来源:CheckAmbiguousFunctions.cs


示例3: ReportFunctionOverloadError

        /// <summary>
        /// Reports function overload resolution error.
        /// </summary>
        internal static void ReportFunctionOverloadError(AST.MethodExpr functionExpr, EdmFunction functionType, List<TypeUsage> argTypes)
        {
            string strDelim = "";
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append(functionType.Name).Append("(");
            for (int i = 0 ; i < argTypes.Count ; i++)
            {
                sb.Append(strDelim);
                sb.Append(argTypes[i] != null ? argTypes[i].EdmType.FullName : "NULL");
                strDelim = ", ";
            }
            sb.Append(")");

            Func<object, object, object, string> formatString;
            if (TypeSemantics.IsAggregateFunction(functionType))
            {
                formatString = TypeHelpers.IsCanonicalFunction(functionType) ? 
                                            (Func<object, object, object, string>)System.Data.Entity.Strings.NoCanonicalAggrFunctionOverloadMatch :
                                            (Func<object, object, object, string>)System.Data.Entity.Strings.NoAggrFunctionOverloadMatch;
            }
            else
            {
                formatString = TypeHelpers.IsCanonicalFunction(functionType) ?
                                            (Func<object, object, object, string>)System.Data.Entity.Strings.NoCanonicalFunctionOverloadMatch :
                                            (Func<object, object, object, string>)System.Data.Entity.Strings.NoFunctionOverloadMatch;
            }

            throw EntityUtil.EntitySqlError(functionExpr.ErrCtx.CommandText,
                                 formatString(functionType.NamespaceName, functionType.Name, sb.ToString()),
                                 functionExpr.ErrCtx.InputPosition,
                                 System.Data.Entity.Strings.CtxFunction(functionType.Name),
                                 false /* loadContextInfoFromResource */);
        }
开发者ID:uQr,项目名称:referencesource,代码行数:36,代码来源:CqlErrorHelper.cs


示例4: LogEntry

 public LogEntry(AnalysisType procedure,
     string filename,
     AST.Address address,
     string original_value,
     string erroneous_value,
     double output_error_magnitude,
     double num_input_error_magnitude,
     double str_input_error_magnitude,
     bool was_flagged,
     bool was_error,
     double significance,
     double threshold)
 {
     _filename = filename;
     _procedure = procedure;
     _address = address;
     _original_value = original_value;
     _erroneous_value = erroneous_value;
     _output_error_magnitude = output_error_magnitude;
     _num_input_error_magnitude = num_input_error_magnitude;
     _str_input_error_magnitude = str_input_error_magnitude;
     _was_flagged = was_flagged;
     _was_error = was_error;
     _significance = significance;
     _threshold = threshold;
 }
开发者ID:plasma-umass,项目名称:DataDebug,代码行数:26,代码来源:LogEntry.cs


示例5: resetState

		public virtual void resetState()
		{
			traceDepth  = 0;
			returnAST	= null;
			retTree_	= null;
			inputState.reset();
		}
开发者ID:alexed1,项目名称:dtrack,代码行数:7,代码来源:TreeParser.cs


示例6: Emit

        private INode Emit(AST a, IGraph to)
        {
            String text = a.getText();
            int iType = a.Type;
            String type = parserpackage.GetTypeName(iType);
            NodeType currentNodeType = GetNodeType(type, to);
            INode currentNode = to.AddNode(currentNodeType);
            currentNode.SetAttribute("value", text);

            if (a.getNumberOfChildren() > 0)
            {
                List<AST> l = GetChildren(a);
                INode previousChild = null;
                foreach (AST current in l)
                {
                    INode childNode = Emit(current, to);
                    EdgeType childType = GetEdgeType("child", to);
                    to.AddEdge(childType, currentNode, childNode);

                    if (previousChild != null)
                    {
                        EdgeType nextType = GetEdgeType("next", to);
                        to.AddEdge(nextType, previousChild, childNode);
                    }
                    previousChild = childNode;
                }
            }
            return currentNode;
        }
开发者ID:jblomer,项目名称:GrGen.NET,代码行数:29,代码来源:ASTdapter.cs


示例7: FastReplace

        public FunctionOutput<string>[] FastReplace(Excel.Range com, DAG dag, InputSample original, InputSample sample, AST.Address[] outputs, bool replace_original)
        {
            FunctionOutput<string>[] fo_arr;
            if (!_d.TryGetValue(sample, out fo_arr))
            {
                // replace the COM value
                ReplaceExcelRange(com, sample);

                // initialize array
                fo_arr = new FunctionOutput<string>[outputs.Length];

                // grab all outputs
                for (var k = 0; k < outputs.Length; k++)
                {
                    // save the output
                    fo_arr[k] = new FunctionOutput<string>(dag.readCOMValueAtAddress(outputs[k]), sample.GetExcludes());
                }

                // Add function values to cache
                // Don't care about return value
                _d.Add(sample, fo_arr);

                // restore the COM value
                if (replace_original)
                {
                    ReplaceExcelRange(com, original);
                }
            }
            return fo_arr;
        }
开发者ID:plasma-umass,项目名称:DataDebug,代码行数:30,代码来源:BootMemo.cs


示例8: DcgClauseToNormalClause

        private static AST.Clause DcgClauseToNormalClause (AST.DcgClause dcgClause)
        {
            var dcgGoalConverter = new AST.DcgGoalConverter ();

            var body = dcgClause.Body.Select (dcgGoalConverter.DcgGoalToNormalGoal).ToArray ();

            return new AST.Clause 
            {
                Head = new AST.Goal 
                {
                    PredicateName = dcgClause.Head.PredicateName, 
                    Arguments = new []
                                    {
                                        dcgClause.Head.Arguments,
                                        new [] // add 2 extra arguments, L0 and Ln
                                            {
                                                new Variable ("L0"),
                                                new Variable ("L" + dcgGoalConverter.DcgSubgoalCount)
                                            }
                                    }.SelectMany (a => a).ToArray ()
                },

                Body = body
            };
        }
开发者ID:carriercomm,项目名称:prolog,代码行数:25,代码来源:Compiler.cs


示例9: VisitFunctionDecl

        public override bool VisitFunctionDecl(AST.Function function)
        {
            if (AlreadyVisited(function))
                return false;

            if (function.IsAmbiguous)
                return false;

            var overloads = function.Namespace.GetFunctionOverloads(function);

            foreach (var overload in overloads)
            {
                if (function.OperatorKind == CXXOperatorKind.Conversion)
                    continue;

                if (overload == function) continue;

                if (overload.Ignore) continue;

                if (!CheckDefaultParameters(function, overload))
                    continue;

                if (!CheckConstness(function, overload))
                    continue;

                function.IsAmbiguous = true;
                overload.IsAmbiguous = true;
            }

            if (function.IsAmbiguous)
                Driver.Diagnostics.EmitWarning("Found ambiguous overload: {0}",
                    function.QualifiedOriginalName);

            return true;
        }
开发者ID:jijamw,项目名称:CppSharp,代码行数:35,代码来源:CheckAmbiguousFunctions.cs


示例10: Compile

        /// <summary>
        /// Compiles AST clauses into an executable program understood by the <see cref="Runtime.Engine"/> .
        /// The input clauses are not required to be in any particular order.
        /// </summary>
        public static Compiled.Program Compile (AST.Program program)
        {
            var allClauses = new []
                                 {
                                     program.DcgClauses.Select (DcgClauseToNormalClause),
                                     program.Clauses
                                 }.SelectMany (a => a);

            var clauseGroups = allClauses.GroupBy (c => Tuple.Create (c.Head.PredicateName, c.Head.Arguments.Length), c => c).ToArray ();

            var prologPredicates = clauseGroups.ToDictionary (p => p.Key, p => new Compiled.PrologPredicate {Name = p.Key.Item1});

            // Dictionary is not covariant so it takes a new dictionary to get a dictionary of base types (Predicate).
            var predicates = prologPredicates.ToDictionary (p => p.Key, CastPrologPredicateToBasePredicate); 

            if (program.ExternalPredicates != null)
            {
                foreach (var externalPredicate in program.ExternalPredicates)
                {
                    predicates.Add (Tuple.Create(externalPredicate.Name, externalPredicate.Arity), new Compiled.ExternalPredicate (externalPredicate.Name));
                }
            }

            foreach (var clauseGroup in clauseGroups)
            {
                var prologPredicate = prologPredicates [clauseGroup.Key];

                prologPredicate.Clauses = clauseGroup.Select (c => new Compiled.Clause {Head = new Compiled.Goal {Predicate = prologPredicate, Arguments = c.Head.Arguments},
                                                                                      Body = Compile (c.Body, predicates)}).ToArray ();
            }

            return new Compiled.Program (predicates);
        }
开发者ID:carriercomm,项目名称:prolog,代码行数:37,代码来源:Compiler.cs


示例11: Accept

 internal override void Accept(AST ast)
 {
     ast.nodes.ForEach(node =>
     {
         node.isResultRequired = false;
         node.Visit(this);
     });
 }
开发者ID:LayeLang,项目名称:Laye,代码行数:8,代码来源:KitCompiler.cs


示例12: CSharpGen

        public CSharpGen(AST.AstNode topNode, string name_space)
        {
            if (!(topNode is AST.GrammarFile))
                throw new Exception("Unable to generate.");

            this.gNamespace = name_space;
            this.grammar = topNode as AST.GrammarFile;
        }
开发者ID:kulibali,项目名称:ironmeta,代码行数:8,代码来源:CSharpGen.cs


示例13: match

		protected internal virtual void  match(AST t, int ttype)
		{
			//System.out.println("match("+ttype+"); cursor is "+t);
			if (t == null || t == ASTNULL || t.Type != ttype)
			{
				throw new MismatchedTokenException(getTokenNames(), t, ttype, false);
			}
		}
开发者ID:alexed1,项目名称:dtrack,代码行数:8,代码来源:TreeParser.cs


示例14: LabelEntry

        // Used by a labelstatement
        public LabelEntry(string stName, AST.LabelStatement node)
        {
            Debug.Assert(node != null);
            Debug.Assert(stName != null);

            m_strName = stName;
            m_node = node;
        }
开发者ID:chenzuo,项目名称:blue,代码行数:9,代码来源:Symbol.cs


示例15: Nested_Content_Of_TagNode_As_Raw

 public void Nested_Content_Of_TagNode_As_Raw()
 {
     const string TEMPLATE = @"<c:out>Hello <c:out>${Stranger}</c:out></c:out>";
     var formatter = new Formatter(TEMPLATE).Parse();
     var ast = new AST(formatter.ParsedTemplate, AST.Options.DontTrackContext);
     var raw = (((TagNode)ast.Nodes[0]).Raw);
     Assert.That(raw, Is.EqualTo("Hello <c:out>${Stranger}</c:out>"));
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:8,代码来源:ASTTest.cs


示例16: CallConcat

        private static IEnumerable <Dictionary <string, Runtime.IConcreteValue>> CallConcat (AST.Goal makeGoal)
        {
            var program = Compiler.Compile (new AST.Program {ExternalPredicates = Helper.GetConcatDeclaration ()});

            program.SetExternalPredicateCallbacks (Helper.GetConcat ());

            return Helper.GetSolutions (makeGoal, program);
        }
开发者ID:carriercomm,项目名称:prolog,代码行数:8,代码来源:ConcatTests.cs


示例17: GetExternDecln

 public override Tuple<AST.Env, List<Tuple<AST.Env, AST.ExternDecln>>> GetExternDecln(AST.Env env)
 {
     Tuple<AST.Env, AST.FuncDef> r_def = GetFuncDef(env);
     return new Tuple<AST.Env, List<Tuple<AST.Env, AST.ExternDecln>>>(
         r_def.Item1,
         new List<Tuple<AST.Env, AST.ExternDecln>>() { Tuple.Create(r_def.Item1, (AST.ExternDecln)r_def.Item2) }
     );
 }
开发者ID:JianpingZeng,项目名称:C-Compiler,代码行数:8,代码来源:external_definitions.cs


示例18: AddAccess

        public void AddAccess(AST.Identifier variable)
        {
            if (!this.Accessing.ContainsKey(variable.Name))
            {
                this.Accessing[variable.Name] = new List<AST.Identifier>();
            }

            this.Accessing[variable.Name].Add(variable);
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:9,代码来源:Variables.cs


示例19: makeAddressForA1

 public static AST.Address makeAddressForA1(string col, int row, AST.Env env)
 {
     return AST.Address.fromA1(
         row,
         col,
         env.WorksheetName,
         env.WorkbookName,
         env.Path
     );
 }
开发者ID:etosch,项目名称:parcel,代码行数:10,代码来源:Utility.cs


示例20: Combined_Content_Of_TagNode_As_Raw

 public void Combined_Content_Of_TagNode_As_Raw()
 {
     const string TEMPLATE = @"<c:out>Hello ${Stranger}</c:out>";
     var formatter = new Formatter(TEMPLATE).Parse();
     var ast = new AST(formatter.ParsedTemplate, AST.Options.DontTrackContext);
     var expected = new AST()
         .Add(new TagNode("c", "out").Add(new TextNode("Hello world")));
     var raw = (((TagNode)ast.Nodes[0]).Raw);
     Assert.That(raw, Is.EqualTo("Hello ${Stranger}"));
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:10,代码来源:ASTTest.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ASTContext类代码示例发布时间:2022-05-24
下一篇:
C# ASResult类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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