コード例 #1
0
 public RescueScope(MSA.Expression /*!*/ retryingVariable, MSA.LabelTarget /*!*/ breakLabel, MSA.LabelTarget /*!*/ continueLabel)
 {
     Assert.NotNull(retryingVariable, breakLabel, continueLabel);
     _retryingVariable = retryingVariable;
     _breakLabel       = breakLabel;
     _continueLabel    = continueLabel;
 }
コード例 #2
0
 public BlockScope(ScopeBuilder /*!*/ builder, MSA.Expression /*!*/ selfVariable, MSA.Expression /*!*/ runtimeScopeVariable,
                   MSA.Expression /*!*/ bfcVariable, MSA.LabelTarget /*!*/ redoLabel)
     : base(builder, selfVariable, runtimeScopeVariable)
 {
     Assert.NotNull(bfcVariable, redoLabel);
     _bfcVariable = bfcVariable;
     _redoLabel   = redoLabel;
 }
コード例 #3
0
 public LoopScope(MSA.Expression /*!*/ redoVariable, MSA.Expression /*!*/ resultVariable, MSA.LabelTarget /*!*/ breakLabel, MSA.LabelTarget /*!*/ continueLabel)
 {
     Assert.NotNull(redoVariable, resultVariable, breakLabel, continueLabel);
     _redoVariable   = redoVariable;
     _resultVariable = resultVariable;
     _breakLabel     = breakLabel;
     _continueLabel  = continueLabel;
 }
コード例 #4
0
        public void EnterRescueClause(MSA.Expression /*!*/ retryingVariable, MSA.LabelTarget /*!*/ breakLabel, MSA.LabelTarget /*!*/ continueLabel)
        {
            Assert.NotNull(retryingVariable, breakLabel, continueLabel);

            RescueScope body = new RescueScope(retryingVariable, breakLabel, continueLabel);

            body.Parent       = _currentElement;
            body.ParentRescue = _currentRescue;

            _currentElement = _currentRescue = body;
        }
コード例 #5
0
 internal MSA.Expression /*!*/ AddReturnTarget(MSA.Expression /*!*/ expression)
 {
     if (expression.Type != typeof(object))
     {
         expression = AstFactory.Box(expression);
     }
     if (_returnLabel != null)
     {
         expression   = Ast.Label(_returnLabel, expression);
         _returnLabel = null;
     }
     return(expression);
 }
コード例 #6
0
 internal MSA.Expression /*!*/ Return(MSA.Expression /*!*/ expression)
 {
     MSA.LabelTarget returnLabel = ReturnLabel;
     if (returnLabel.Type != typeof(void) && expression.Type == typeof(void))
     {
         expression = Ast.Block(expression, Ast.Constant(null, typeof(object)));
     }
     else if (returnLabel.Type != expression.Type)
     {
         if (!CanAssign(returnLabel.Type, expression.Type))
         {
             // Add conversion step to the AST
             expression = Ast.Convert(expression, returnLabel.Type);
         }
     }
     return(Ast.Return(returnLabel, expression));
 }
コード例 #7
0
ファイル: MethodCall.cs プロジェクト: gaybro8777/ironruby
        internal static MSA.Expression /*!*/ MakeCallWithBlockRetryable(AstGenerator /*!*/ gen, MSA.Expression /*!*/ invoke,
                                                                        MSA.Expression blockArgVariable, MSA.Expression transformedBlock, bool isBlockDefinition)
        {
            Assert.NotNull(invoke);
            Debug.Assert((blockArgVariable == null) == (transformedBlock == null));

            // see Ruby Language.doc/Control Flow Implementation/Method Call With a Block
            MSA.Expression          resultVariable = gen.CurrentScope.DefineHiddenVariable("#method-result", typeof(object));
            MSA.ParameterExpression evalUnwinder   = gen.CurrentScope.DefineHiddenVariable("#unwinder", typeof(EvalUnwinder));

            MSA.LabelTarget label = Ast.Label();

            return(AstFactory.Block(
                       Ast.Assign(blockArgVariable, Ast.Convert(transformedBlock, blockArgVariable.Type)),
                       AstFactory.Infinite(label, null,
                                           (!isBlockDefinition) ?
                                           (MSA.Expression)Ast.Empty() :
                                           (MSA.Expression)Methods.InitializeBlock.OpCall(blockArgVariable),

                                           AstUtils.Try(
                                               Ast.Assign(resultVariable, invoke)
                                               ).Catch(evalUnwinder,
                                                       Ast.Assign(
                                                           resultVariable,
                                                           Ast.Field(evalUnwinder, EvalUnwinder.ReturnValueField)
                                                           )
                                                       ),

                                           // if result != RetrySingleton then break end
                                           AstUtils.Unless(Methods.IsRetrySingleton.OpCall(AstFactory.Box(resultVariable)), Ast.Break(label)),

                                           // if blockParam == #block then retry end
                                           (gen.CurrentMethod.IsTopLevelCode) ? Ast.Empty() :
                                           AstUtils.IfThen(Ast.Equal(gen.MakeMethodBlockParameterRead(), blockArgVariable), RetryStatement.TransformRetry(gen))

                                           ),
                       resultVariable
                       ));
        }
コード例 #8
0
        public void EnterBlockDefinition(
            ScopeBuilder /*!*/ locals,
            MSA.Expression /*!*/ bfcVariable,
            MSA.Expression /*!*/ selfVariable,
            MSA.Expression /*!*/ runtimeScopeVariable,
            MSA.LabelTarget /*!*/ redoLabel)
        {
            Assert.NotNull(locals, bfcVariable, selfVariable);
            Assert.NotNull(redoLabel);

            BlockScope block = new BlockScope(locals, selfVariable, runtimeScopeVariable, bfcVariable, redoLabel);

            block.Parent              = _currentElement;
            block.ParentRescue        = _currentRescue;
            block.ParentLoop          = _currentLoop;
            block.ParentBlock         = _currentBlock;
            block.ParentVariableScope = _currentVariableScope;

            _currentElement       = block;
            _currentRescue        = null;
            _currentLoop          = null;
            _currentBlock         = block;
            _currentVariableScope = block;
        }
コード例 #9
0
        public void EnterLoop(MSA.Expression /*!*/ redoVariable, MSA.Expression /*!*/ resultVariable, MSA.LabelTarget /*!*/ breakLabel, MSA.LabelTarget /*!*/ continueLabel)
        {
            Assert.NotNull(redoVariable, resultVariable, breakLabel, continueLabel);

            LoopScope loop = new LoopScope(redoVariable, resultVariable, breakLabel, continueLabel);

            loop.Parent     = _currentElement;
            loop.ParentLoop = _currentLoop;

            _currentElement = _currentLoop = loop;
        }
コード例 #10
0
ファイル: AstGenerator.cs プロジェクト: jcteague/ironruby
 public BlockScope(ScopeBuilder/*!*/ builder, MSA.Expression/*!*/ selfVariable, MSA.Expression/*!*/ runtimeScopeVariable,
     MSA.Expression/*!*/ bfcVariable, MSA.LabelTarget/*!*/ redoLabel)
     : base(builder, selfVariable, runtimeScopeVariable) {
     Assert.NotNull(bfcVariable, redoLabel);
     _bfcVariable = bfcVariable;
     _redoLabel = redoLabel;
 }
コード例 #11
0
ファイル: AstGenerator.cs プロジェクト: jcteague/ironruby
 internal MSA.Expression/*!*/ AddReturnTarget(MSA.Expression/*!*/ expression) {
     if (expression.Type != typeof(object)) {
         expression = AstFactory.Box(expression);
     }
     if (_returnLabel != null) {
         expression = Ast.Label(_returnLabel, expression);
         _returnLabel = null;
     }
     return expression;
 }
コード例 #12
0
ファイル: AstGenerator.cs プロジェクト: jcteague/ironruby
 public RescueScope(MSA.Expression/*!*/ retryingVariable, MSA.LabelTarget/*!*/ breakLabel, MSA.LabelTarget/*!*/ continueLabel) {
     Assert.NotNull(retryingVariable, breakLabel, continueLabel);
     _retryingVariable = retryingVariable;
     _breakLabel = breakLabel;
     _continueLabel = continueLabel;
 }
コード例 #13
0
ファイル: AstGenerator.cs プロジェクト: jcteague/ironruby
 public LoopScope(MSA.Expression/*!*/ redoVariable, MSA.Expression/*!*/ resultVariable, MSA.LabelTarget/*!*/ breakLabel, MSA.LabelTarget/*!*/ continueLabel) {
     Assert.NotNull(redoVariable, resultVariable, breakLabel, continueLabel);
     _redoVariable = redoVariable;
     _resultVariable = resultVariable;
     _breakLabel = breakLabel;
     _continueLabel = continueLabel;
 }
コード例 #14
0
ファイル: AstGenerator.cs プロジェクト: m4dc4p/ironruby
 public RescueScope(MSA.Expression/*!*/ retryingVariable, MSA.LabelTarget/*!*/ retryLabel) {
     Assert.NotNull(retryingVariable, retryLabel);
     _retryingVariable = retryingVariable;
     _retryLabel = retryLabel;
 }