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

C# ExprContext类代码示例

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

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



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

示例1: FalseLiteralContext

		public FalseLiteralContext(ExprContext context) { CopyFrom(context); }
开发者ID:mpmedia,项目名称:Excess,代码行数:1,代码来源:RParser.cs


示例2: VisitExpression

        public BoundExpression VisitExpression(BoundExpression node, ExprContext context)
        {
            var prevContext = _context;
            int prevStack = StackDepth();
            _context = context;

            // Do not recurse into constant expressions. Their children do not push any values.
            var result = node.ConstantValue == null ?
                node = (BoundExpression)base.Visit(node) :
                node;

            _context = prevContext;
            _counter += 1;

            switch (context)
            {
                case ExprContext.Sideeffects:
                    SetStackDepth(prevStack);
                    break;

                case ExprContext.AssignmentTarget:
                    break;

                case ExprContext.Value:
                case ExprContext.Address:
                case ExprContext.Box:
                    SetStackDepth(prevStack);
                    PushEvalStack(node, context);
                    break;

                default:
                    throw ExceptionUtilities.UnexpectedValue(context);
            }

            return result;
        }
开发者ID:rosslyn-cuongle,项目名称:roslyn,代码行数:36,代码来源:Optimizer.cs


示例3: VisitExpression

        private BoundExpression VisitExpression(BoundExpression node, ExprContext context)
        {
            BoundExpression result;
            _recursionDepth++;

            if (_recursionDepth > 1)
            {
                StackGuard.EnsureSufficientExecutionStack(_recursionDepth);

                result = VisitExpressionCore(node, context);
            }
            else
            {
                result = VisitExpressionCoreWithStackGuard(node, context);
            }

            _recursionDepth--;
            return result;
        }
开发者ID:otawfik-ms,项目名称:roslyn,代码行数:19,代码来源:Optimizer.cs


示例4: PushEvalStack

 private void PushEvalStack(BoundExpression result, ExprContext context)
 {
     Debug.Assert(result != null || context == ExprContext.None);
     _evalStack.Add((result, context));
 }
开发者ID:otawfik-ms,项目名称:roslyn,代码行数:5,代码来源:Optimizer.cs


示例5: VisitExpression

        public BoundExpression VisitExpression(BoundExpression node, ExprContext context)
        {
            var prevContext = _context;
            int prevStack = _evalStack;

            _context = context;
            var result = ReuseOrVisit(node, context);
            _counter += 1;

            switch (context)
            {
                case ExprContext.Sideeffects:
                    _evalStack = prevStack;
                    break;

                case ExprContext.Value:
                case ExprContext.Address:
                case ExprContext.Box:
                    _evalStack = prevStack + 1;
                    break;

                case ExprContext.AssignmentTarget:
                    _evalStack = prevStack;
                    if (LhsUsesStackWhenAssignedTo(node, context))
                    {
                        _evalStack = prevStack + 1;
                    }
                    break;

                default:
                    throw ExceptionUtilities.UnexpectedValue(context);
            }

            _context = prevContext;
            return result;
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:36,代码来源:Optimizer.cs


示例6: LhsUsesStackWhenAssignedTo

        // here we have a case of indirect assignment:  *t1 = expr;
        // normally we would need to push t1 and that will cause spilling of t2
        //
        // TODO: an interesting case arises in unused x[i]++  and ++x[i] :
        //       we have trees that look like:
        //
        //  t1 = &(x[0])
        //  t2 = *t1
        //  *t1 = t2 + 1
        //
        //  t1 = &(x[0])
        //  t2 = *t1 + 1
        //  *t1 = t2
        //
        //  in these cases, we could keep t2 on stack (dev10 does).
        //  we are dealing with exactly 2 locals and access them in strict order 
        //  t1, t2, t1, t2  and we are not using t2 after that.
        //  We may consider detecting exactly these cases and pretend that we do not need 
        //  to push either t1 or t2 in this case.
        //
        private bool LhsUsesStackWhenAssignedTo(BoundNode node, ExprContext context)
        {
            Debug.Assert(context == ExprContext.AssignmentTarget);

            switch (node.Kind)
            {
                case BoundKind.Parameter:
                case BoundKind.Local:
                    return false;

                case BoundKind.FieldAccess:
                    return !((BoundFieldAccess)node).FieldSymbol.IsStatic;

                case BoundKind.Sequence:
                    return LhsUsesStackWhenAssignedTo(((BoundSequence)node).Value, context);
            }

            return true;
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:39,代码来源:Optimizer.cs


示例7: IfStatementContext

		public IfStatementContext(ExprContext context) { CopyFrom(context); }
开发者ID:mpmedia,项目名称:Excess,代码行数:1,代码来源:RParser.cs


示例8: SignContext

		public SignContext(ExprContext context) { CopyFrom(context); }
开发者ID:mpmedia,项目名称:Excess,代码行数:1,代码来源:RParser.cs


示例9: TrueLiteralContext

		public TrueLiteralContext(ExprContext context) { CopyFrom(context); }
开发者ID:mpmedia,项目名称:Excess,代码行数:1,代码来源:RParser.cs


示例10: IndexContext

		public IndexContext(ExprContext context) { CopyFrom(context); }
开发者ID:mpmedia,项目名称:Excess,代码行数:1,代码来源:RParser.cs


示例11: InfLiteralContext

		public InfLiteralContext(ExprContext context) { CopyFrom(context); }
开发者ID:mpmedia,项目名称:Excess,代码行数:1,代码来源:RParser.cs


示例12: FunctionCallContext

		public FunctionCallContext(ExprContext context) { CopyFrom(context); }
开发者ID:mpmedia,项目名称:Excess,代码行数:1,代码来源:RParser.cs


示例13: ComplexLiteralContext

		public ComplexLiteralContext(ExprContext context) { CopyFrom(context); }
开发者ID:mpmedia,项目名称:Excess,代码行数:1,代码来源:RParser.cs


示例14: expr

	public ExprContext expr() {
		ExprContext _localctx = new ExprContext(Context, State);
		EnterRule(_localctx, 112, RULE_expr);
		int _la;
		try {
			EnterOuterAlt(_localctx, 1);
			{
			State = 748; xor_expr();
			State = 753;
			ErrorHandler.Sync(this);
			_la = TokenStream.La(1);
			while (_la==OR_OP) {
				{
				{
				State = 749; Match(OR_OP);
				State = 750; xor_expr();
				}
				}
				State = 755;
				ErrorHandler.Sync(this);
				_la = TokenStream.La(1);
			}
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			ExitRule();
		}
		return _localctx;
	}
开发者ID:ashwinjv,项目名称:PythonParser,代码行数:34,代码来源:Python3Parser.cs


示例15: UserOpContext

		public UserOpContext(ExprContext context) { CopyFrom(context); }
开发者ID:mpmedia,项目名称:Excess,代码行数:1,代码来源:RParser.cs


示例16: ReuseOrVisit

        /// <summary>
        /// Recursively rewrites the node or simply replaces it with a dup node
        /// if we have just seen exactly same node.
        /// </summary>
        private BoundExpression ReuseOrVisit(BoundExpression node, ExprContext context)
        {
            if (context == ExprContext.AssignmentTarget || context == ExprContext.Sideeffects)
            {
                return BaseVisitExpression(node);
            }

            // it must be most recent expression
            // it can be a ref when we want a value, but cannot be the other way
            // TODO: we could reuse boxed values, but we would need to make the Dup to know it was boxed
            if (_counter == _lastExpressionCnt + 1 &&
                _lastExprContext != ExprContext.Box &&
                (_lastExprContext == context || _lastExprContext != ExprContext.Value) &&
                CanDup(_lastExpression, node))
            {
                _lastExpressionCnt = _counter;

                // when duping something not created in a Value context, we are actually duping a reference.
                // record that so that codegen could know if it is a value or a reference.
                RefKind dupRefKind = _lastExprContext == ExprContext.Value ?
                                                    RefKind.None :
                                                    RefKind.Ref;

                // change the context to the most recently used. 
                // Why? If we obtained a value from a duped reference, we now have a value on the stack.
                _lastExprContext = context;

                return new BoundDup(node.Syntax, dupRefKind, node.Type);
            }
            else
            {
                BoundExpression result = BaseVisitExpression(node);

                _lastExpressionCnt = _counter;
                _lastExprContext = context;
                _lastExpression = result;

                return result;
            }
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:44,代码来源:Optimizer.cs


示例17: NamespaceContext

		public NamespaceContext(ExprContext context) { CopyFrom(context); }
开发者ID:mpmedia,项目名称:Excess,代码行数:1,代码来源:RParser.cs


示例18: NAContext

		public NAContext(ExprContext context) { CopyFrom(context); }
开发者ID:mpmedia,项目名称:Excess,代码行数:1,代码来源:RParser.cs


示例19: VisitBinaryOperator

        public override BoundNode VisitBinaryOperator(BoundBinaryOperator node)
        {
            BoundExpression child = node.Left;

            if (child.Kind != BoundKind.BinaryOperator || child.ConstantValue != null)
            {
                return VisitBinaryOperatorSimple(node);
            }

            // Do not blow the stack due to a deep recursion on the left.
            var stack = ArrayBuilder<BoundBinaryOperator>.GetInstance();
            stack.Push(node);

            BoundBinaryOperator binary = (BoundBinaryOperator)child;

            while (true)
            {
                stack.Push(binary);
                child = binary.Left;

                if (child.Kind != BoundKind.BinaryOperator || child.ConstantValue != null)
                {
                    break;
                }

                binary = (BoundBinaryOperator)child;
            }

            var prevContext = _context;
            int prevStack = StackDepth();

            var left = (BoundExpression)this.Visit(child);

            while (true)
            {
                binary = stack.Pop();

                var isLogical = (binary.OperatorKind & BinaryOperatorKind.Logical) != 0;

                object cookie = null;
                if (isLogical)
                {
                    cookie = GetStackStateCookie();     // implicit branch here
                    SetStackDepth(prevStack);  // right is evaluated with original stack
                }

                var right = (BoundExpression)this.Visit(binary.Right);

                if (isLogical)
                {
                    EnsureStackState(cookie);   // implicit label here
                }

                var type = this.VisitType(binary.Type);
                left = binary.Update(binary.OperatorKind, left, right, binary.ConstantValueOpt, binary.MethodOpt, binary.ResultKind, type);

                if (stack.Count == 0)
                {
                    break;
                }

                _context = prevContext;
                _counter += 1;
                SetStackDepth(prevStack);
                PushEvalStack(binary, ExprContext.Value);
            }

            Debug.Assert((object)binary == node);
            stack.Free();

            return left;
        }
开发者ID:otawfik-ms,项目名称:roslyn,代码行数:72,代码来源:Optimizer.cs


示例20: NegationContext

		public NegationContext(ExprContext context) { CopyFrom(context); }
开发者ID:mpmedia,项目名称:Excess,代码行数:1,代码来源:RParser.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# ExprList类代码示例发布时间:2022-05-24
下一篇:
C# Expr类代码示例发布时间: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