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


C# Ast.Expression類代碼示例

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


Expression類屬於Microsoft.PythonTools.Parsing.Ast命名空間,在下文中一共展示了Expression類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DefineExpr

 private void DefineExpr(Expression lhs) {
     if (lhs is NameExpression) {
         lhs.Walk(Define);
     } else {
         // fob.oar = 42, fob[oar] = 42, we don't actually define any variables
         lhs.Walk(this);
     }
 }
開發者ID:jsschultz,項目名稱:PTVS,代碼行數:8,代碼來源:AssignmentWalker.cs

示例2: BinaryExpression

        public BinaryExpression(PythonOperator op, Expression left, Expression right) {
            Contract.Assert(left != null);
            Contract.Assert(right != null);
            if (op == PythonOperator.None) throw new ArgumentException("bad operator");

            _op = op;
            _left = left;
            _right = right;
            StartIndex = left.StartIndex;
            EndIndex = right.EndIndex;
        }
開發者ID:RussBaz,項目名稱:PTVS,代碼行數:11,代碼來源:BinaryExpression.cs

示例3: AppendCodeString

        internal void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format, string start, string end, Expression item) {
            if (!String.IsNullOrEmpty(start)) {
                format.ReflowComment(res, this.GetProceedingWhiteSpace(ast));
                res.Append(start);
            }

            item.AppendCodeString(res, ast, format);

            for (int i = 0; i < Iterators.Count; i++) {
                Iterators[i].AppendCodeString(res, ast, format);
            }

            if (!String.IsNullOrEmpty(end)) {
                res.Append(this.GetSecondWhiteSpace(ast));
                res.Append(end);
            }
        }
開發者ID:omnimark,項目名稱:PTVS,代碼行數:17,代碼來源:Comprehension.cs

示例4: GetValueFromExpression

        private IMember GetValueFromExpression(Expression expr, Dictionary<string, IMember> scope) {
            var ne = expr as NameExpression;
            if (ne != null) {
                IMember existing = null;
                if (scope != null && scope.TryGetValue(ne.Name, out existing) && existing != null) {
                    return existing;
                }
                if (_members != null && _members.TryGetValue(ne.Name, out existing) && existing != null) {
                    return existing;
                }
            }

            var type = GetTypeFromExpression(expr);
            if (type != null) {
                return new AstPythonConstant(type, GetLoc(expr));
            }

            return null;
        }
開發者ID:jsschultz,項目名稱:PTVS,代碼行數:19,代碼來源:AstAnalysisWalker.cs

示例5: GetFirstNameExpression

        private static NameExpression GetFirstNameExpression(Expression expr) {
            NameExpression nameExpr;
            CallExpression callExpr;
            MemberExpression membExpr;

            if ((nameExpr = expr as NameExpression) != null) {
                return nameExpr;
            }
            if ((callExpr = expr as CallExpression) != null) {
                return GetFirstNameExpression(callExpr.Target);
            }
            if ((membExpr = expr as MemberExpression) != null) {
                return GetFirstNameExpression(membExpr.Target);
            }

            return null;
        }
開發者ID:omnimark,項目名稱:PTVS,代碼行數:17,代碼來源:ProjectAnalyzer.cs

示例6: AssertStatement

 public AssertStatement(Expression test, Expression message) {
     _test = test;
     _message = message;
 }
開發者ID:omnimark,項目名稱:PTVS,代碼行數:4,代碼來源:AssertStatement.cs

示例7: ForceExplicitSign

        private static Expression ForceExplicitSign(Expression expr, out int sign) {
            var constExpr = expr as ConstantExpression;
            if (constExpr != null && (constExpr.Value is int || constExpr.Value is double || constExpr.Value is BigInteger || constExpr.Value is Complex)) {
                sign = 1;
                return new UnaryExpression(PythonOperator.Pos, constExpr);
            }

            var unaryExpr = expr as UnaryExpression;
            if (unaryExpr != null) {
                switch (unaryExpr.Op) {
                    case PythonOperator.Pos:
                        sign = 1;
                        return unaryExpr;
                    case PythonOperator.Negate:
                        sign = -1;
                        return unaryExpr;
                }
            }

            sign = 0;
            return expr;
        }
開發者ID:omnimark,項目名稱:PTVS,代碼行數:22,代碼來源:ExpressionEvaluator.cs

示例8: IfStatementTest

 public IfStatementTest(Expression test, Statement body) {
     _test = test;
     _body = body;
 }
開發者ID:wenh123,項目名稱:PTVS,代碼行數:4,代碼來源:IfStatementTest.cs

示例9: WalkCollection

 private bool WalkCollection(Expression node, IEnumerable<Expression> items) {
     CanComplete = HasCaret(node);
     int count = 0;
     Expression last = null;
     foreach (var e in items) {
         count += 1;
         last = e;
     }
     if (count == 0) {
         CommitByDefault = false;
     } else if (count == 1) {
         last.Walk(this);
         CommitByDefault = false;
     } else {
         CommitByDefault = true;
         last.Walk(this);
     }
     return false;
 }
開發者ID:smallwave,項目名稱:PTVS,代碼行數:19,代碼來源:IntellisenseController.cs

示例10: FinishSetComp

 // comp_iter '}'
 private SetComprehension FinishSetComp(Expression item, out bool ateTerminator) {
     ComprehensionIterator[] iters = ParseCompIter();
     ateTerminator = Eat(TokenKind.RightBrace);
     return new SetComprehension(item, iters);
 }
開發者ID:omnimark,項目名稱:PTVS,代碼行數:6,代碼來源:Parser.cs

示例11: ParseGeneratorExpression

        //  genexpr_for  ::= "for" target_list "in" or_test [comp_iter]
        //
        //  "for" has NOT been eaten before entering this method
        private Expression ParseGeneratorExpression(Expression expr, string rightParenWhiteSpace = null) {
            ComprehensionIterator[] iters = ParseCompIter();

            GeneratorExpression ret = new GeneratorExpression(expr, iters);

            ret.SetLoc(expr.StartIndex, GetEnd());
            return ret;
        }
開發者ID:omnimark,項目名稱:PTVS,代碼行數:11,代碼來源:Parser.cs

示例12: FinishExpressionListAsExpr

        private Expression FinishExpressionListAsExpr(Expression expr) {
            var start = GetStart();
            bool trailingComma = true;
            List<Expression> l = new List<Expression>();
            List<string> itemWhiteSpace = MakeWhiteSpaceList();
            if (itemWhiteSpace != null) {
                itemWhiteSpace.Add(_tokenWhiteSpace);
            }
            l.Add(expr);

            while (true) {
                if (NeverTestToken(PeekToken())) break;
                expr = ParseExpression();
                l.Add(expr);
                if (!MaybeEat(TokenKind.Comma)) {
                    trailingComma = false;
                    break;
                }
                if (itemWhiteSpace != null) {
                    itemWhiteSpace.Add(_tokenWhiteSpace);
                }
                trailingComma = true;
            }

            Expression ret = MakeTupleOrExpr(l, itemWhiteSpace, trailingComma);
            ret.SetLoc(start, GetEnd());
            return ret;
        }
開發者ID:omnimark,項目名稱:PTVS,代碼行數:28,代碼來源:Parser.cs

示例13: ParseTestListAsExpr

        private List<Expression> ParseTestListAsExpr(Expression expr, out List<string> itemWhiteSpace, out bool trailingComma) {
            var l = new List<Expression>();
            itemWhiteSpace = MakeWhiteSpaceList();
            if (expr != null) {
                l.Add(expr);
                if (itemWhiteSpace != null) {
                    Debug.Assert(_token.Token.Kind == TokenKind.Comma);
                    itemWhiteSpace.Add(_tokenWhiteSpace);
                }
            }

            trailingComma = true;
            while (true) {
                if (NeverTestToken(PeekToken())) break;
                l.Add(ParseExpression());

                if (!MaybeEat(TokenKind.Comma)) {
                    trailingComma = false;
                    break;
                }
                if (itemWhiteSpace != null) {
                    itemWhiteSpace.Add(_tokenWhiteSpace);
                }
            }
            return l;
        }
開發者ID:omnimark,項目名稱:PTVS,代碼行數:26,代碼來源:Parser.cs

示例14: DecoratorStatement

 public DecoratorStatement(Expression[] decorators) {
     _decorators = decorators;
 }
開發者ID:RussBaz,項目名稱:PTVS,代碼行數:3,代碼來源:DecoratorStatement.cs

示例15: IsActualExpression

 private static bool IsActualExpression(Expression node) {
     return node != null && !(node is ErrorExpression);
 }
開發者ID:smallwave,項目名稱:PTVS,代碼行數:3,代碼來源:IntellisenseController.cs


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