IronRuby.Compiler.Ast.AstGenerator.Return C# (CSharp) Method

Return() private method

private Return ( System.Linq.Expressions expression ) : Expression
expression System.Linq.Expressions
return System.Linq.Expressions.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, AstUtils.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);
        }

Usage Example

Esempio n. 1
0
        internal static MSA.Expression /*!*/ TransformRetry(AstGenerator /*!*/ gen)
        {
            // eval:
            if (gen.CompilerOptions.IsEval)
            {
                return(Methods.EvalRetry.OpCall(gen.CurrentRfcVariable));
            }

            // rescue clause:
            if (gen.CurrentRescue != null)
            {
                return(Ast.Block(
                           Ast.Assign(gen.CurrentRescue.RetryingVariable, Ast.Constant(true)),
                           Ast.Continue(gen.CurrentRescue.ContinueLabel),
                           Ast.Empty()
                           ));
            }

            // block:
            if (gen.CurrentBlock != null)
            {
                return(gen.Return(Methods.BlockRetry.OpCall(gen.CurrentBlock.BfcVariable)));
            }

            // primary frame:
            return(gen.Return(Methods.MethodRetry.OpCall(gen.CurrentRfcVariable, gen.MakeMethodBlockParameterRead())));
        }
All Usage Examples Of IronRuby.Compiler.Ast.AstGenerator::Return