當前位置: 首頁>>代碼示例>>C#>>正文


C# AST類代碼示例

本文整理匯總了C#中AST的典型用法代碼示例。如果您正苦於以下問題:C# AST類的具體用法?C# AST怎麽用?C# AST使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AST類屬於命名空間,在下文中一共展示了AST類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的AST類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。