当前位置: 首页>>代码示例>>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;未经允许,请勿转载。