public RescueScope(MSA.Expression /*!*/ retryingVariable, MSA.LabelTarget /*!*/ breakLabel, MSA.LabelTarget /*!*/ continueLabel) { Assert.NotNull(retryingVariable, breakLabel, continueLabel); _retryingVariable = retryingVariable; _breakLabel = breakLabel; _continueLabel = continueLabel; }
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; }
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; }
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; }
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); }
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)); }
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 )); }
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; }
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; }
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; }
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; }
public RescueScope(MSA.Expression/*!*/ retryingVariable, MSA.LabelTarget/*!*/ breakLabel, MSA.LabelTarget/*!*/ continueLabel) { Assert.NotNull(retryingVariable, breakLabel, continueLabel); _retryingVariable = retryingVariable; _breakLabel = breakLabel; _continueLabel = continueLabel; }
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; }
public RescueScope(MSA.Expression/*!*/ retryingVariable, MSA.LabelTarget/*!*/ retryLabel) { Assert.NotNull(retryingVariable, retryLabel); _retryingVariable = retryingVariable; _retryLabel = retryLabel; }