Exemplo n.º 1
0
        protected override Expression VisitGoto(GotoExpression node)
        {
            BranchLabel label;

            var target = node.Target;
            var value  = Visit(node.Value);

            // TODO: Is it possible for an inner reducible node of the loop to rely on nodes produced by reducing outer reducible nodes?

            // Unknown label => must be within the loop:
            if (!_labelMapping.TryGetValue(target, out label))
            {
                return(node.Update(target, value));
            }

            // Known label within the loop:
            if (label.TargetIndex >= _loopStartInstructionIndex && label.TargetIndex < _loopEndInstructionIndex)
            {
                return(node.Update(target, value));
            }

            return(Expression.Return(_returnLabel,
                                     (value != null && value.Type != typeof(void)) ?
                                     Expression.Call(_frameVar, InterpretedFrame.GotoMethod, Expression.Constant(label.LabelIndex), AstUtils.Box(value)) :
                                     Expression.Call(_frameVar, InterpretedFrame.VoidGotoMethod, Expression.Constant(label.LabelIndex)),
                                     node.Type
                                     ));
        }
Exemplo n.º 2
0
        internal bool TryGetLabelInfo(LabelTarget target, out LabelInfo info)
        {
            if (_labels == null)
            {
                info = null;
                return(false);
            }

            return(_labels.TryGetValue(target, out info));
        }