示例#1
0
 public RescueClause(LeftValue target, Statements statements, SourceSpan location)
     : base(location)
 {
     _target     = target;
     _types      = Expression.EmptyArray;
     _statements = statements;
 }
示例#2
0
 public CaseExpression(Expression value, WhenClause /*!*/[] whenClauses, Statements elseStatements, SourceSpan location)
     : base(location)
 {
     _value          = value;
     _whenClauses    = whenClauses ?? WhenClause.EmptyArray;
     _elseStatements = elseStatements;
 }
示例#3
0
 public CaseExpression(Expression value, List <WhenClause> whenClauses, Statements elseStatements, SourceSpan location)
     : base(location)
 {
     _value          = value;
     _whenClauses    = whenClauses;
     _elseStatements = elseStatements;
 }
 public ElseIfClause(Expression condition, Statements /*!*/ statements, SourceSpan location)
     : base(location)
 {
     Assert.NotNull(statements);
     _statements = statements;
     _condition  = condition;
 }
示例#5
0
 public WhenClause(Expression[] comparisons, Expression comparisonArray, Statements statements, SourceSpan location)
     : base(location)
 {
     _comparisons     = comparisons;
     _comparisonArray = comparisonArray;
     _statements      = statements;
 }
示例#6
0
 public RescueClause(Expression /*!*/[] /*!*/ types, LeftValue target, Statements statements, SourceSpan location)
     : base(location)
 {
     Assert.NotNullItems(types);
     _types      = types;
     _target     = target;
     _statements = statements;
 }
示例#7
0
 public RescueClause(Expression /*!*/ type, LeftValue target, Statements statements, SourceSpan location)
     : base(location)
 {
     Assert.NotNull(type);
     _types      = new Expression[] { type };
     _target     = target;
     _statements = statements;
 }
示例#8
0
 public RescueClause(CompoundRightValue type, LeftValue target, Statements statements, SourceSpan location)
     : base(location)
 {
     _types      = type.RightValues;
     _splatType  = type.SplattedValue;
     _target     = target;
     _statements = statements;
 }
示例#9
0
        public FileInitializerStatement(LexicalScope /*!*/ definedScope, Statements /*!*/ statements, SourceSpan location)
            : base(location)
        {
            Assert.NotNull(definedScope);

            _definedScope = definedScope;
            _statements   = statements;
        }
示例#10
0
        internal BlockExpression(Statements /*!*/ statements, SourceSpan location)
            : base(location)
        {
            Assert.NotNull(statements);
            Debug.Assert(statements.Count > 1);

            _statements = statements;
        }
示例#11
0
        public BlockDefinition(LexicalScope /*!*/ definedScope, CompoundLeftValue /*!*/ parameters, Statements /*!*/ body, SourceSpan location)
            : base(location)
        {
            Assert.NotNull(definedScope, parameters, body);

            _definedScope = definedScope;
            _body         = body;
            _parameters   = parameters;
        }
示例#12
0
        public BlockDefinition(LexicalScope /*!*/ definedScope, Parameters parameters, Statements /*!*/ body, SourceSpan location)
            : base(location)
        {
            Assert.NotNull(definedScope, body);

            _definedScope = definedScope;
            _body         = body;
            _parameters   = parameters ?? Parameters.Empty;
        }
示例#13
0
文件: Body.cs 项目: yyyyj/ironruby
        public Body(Statements /*!*/ statements, List <RescueClause> rescueClauses, Statements elseStatements,
                    Statements ensureStatements, SourceSpan location)
            : base(location)
        {
            Assert.NotNull(statements);

            _statements       = statements;
            _rescueClauses    = rescueClauses;
            _elseStatements   = elseStatements;
            _ensureStatements = ensureStatements;
        }
示例#14
0
        public WhileLoopExpression(Expression /*!*/ condition, bool isWhileLoop, bool isPostTest, Statements /*!*/ statements, SourceSpan location)
            : base(location)
        {
            ContractUtils.RequiresNotNull(condition, "condition");
            ContractUtils.RequiresNotNull(statements, "statements");

            _condition   = condition;
            _isWhileLoop = isWhileLoop;
            _isPostTest  = isPostTest;
            _statements  = statements;
        }
示例#15
0
        public UnlessExpression(Expression /*!*/ condition, Statements /*!*/ statements, ElseIfClause elseClause, SourceSpan location)
            : base(location)
        {
            ContractUtils.RequiresNotNull(condition, "condition");
            ContractUtils.RequiresNotNull(statements, "statements");
            ContractUtils.Requires(elseClause == null || elseClause.Condition == null, "elseClause", "No condition allowed.");

            _statements = statements;
            _condition  = condition;
            _elseClause = elseClause;
        }
示例#16
0
        public SourceUnitTree(LexicalScope /*!*/ definedScope, Statements /*!*/ statements, List <FileInitializerStatement> initializers,
                              RubyEncoding /*!*/ encoding, int dataOffset)
            : base(SourceSpan.None)
        {
            Assert.NotNull(definedScope, statements, encoding);

            _definedScope = definedScope;
            _statements   = statements;
            _initializers = initializers;
            _encoding     = encoding;
            _dataOffset   = dataOffset;
        }
示例#17
0
        public IfExpression(Expression /*!*/ condition, Statements /*!*/ body, List <ElseIfClause> /*!*/ elseIfClauses, SourceSpan location)
            : base(location)
        {
            ContractUtils.RequiresNotNull(body, "body");
            ContractUtils.RequiresNotNull(condition, "condition");
            ContractUtils.RequiresNotNull(elseIfClauses, "elseIfClauses");

            // all but the last clause should have non-null conditions:
            for (int i = 0; i < elseIfClauses.Count - 1; i++)
            {
                if (elseIfClauses[i].Condition == null)
                {
                    throw ExceptionUtils.MakeArgumentItemNullException(i, "elseIfClauses");
                }
            }

            _condition     = condition;
            _body          = body;
            _elseIfClauses = elseIfClauses;
        }
示例#18
0
        private MSA.Expression /*!*/ TransformStatementsToExpression(Statements statements, bool toBoolean, bool positive)
        {
            if (statements == null || statements.Count == 0)
            {
                return(toBoolean ? AstUtils.Constant(!positive) : AstUtils.Constant(null));
            }

            var last = toBoolean ? statements.Last.TransformCondition(this, positive) : statements.Last.TransformReadStep(this);

            if (statements.Count == 1)
            {
                return(last);
            }

            var result = new AstBlock();

            foreach (var statement in statements.AllButLast)
            {
                result.Add(statement.Transform(this));
            }
            result.Add(last);

            return(result);
        }
 public ShutdownHandlerStatement(LexicalScope /*!*/ definedScope, Statements /*!*/ body, SourceSpan location)
     : base(location)
 {
     _block = new BlockDefinition(definedScope, CompoundLeftValue.UnspecifiedBlockSignature, body, location);
 }
示例#20
0
 internal MSA.Expression /*!*/ TransformStatementsToExpression(Statements statements)
 {
     return(TransformStatementsToExpression(statements, false, false));
 }
示例#21
0
 internal MSA.Expression /*!*/ TransformStatementsToBooleanExpression(Statements statements, bool positive)
 {
     return(TransformStatementsToExpression(statements, true, positive));
 }
示例#22
0
        internal MSA.Expression /*!*/ TransformStatements(MSA.Expression prologue, Statements /*!*/ statements, MSA.Expression epilogue,
                                                          ResultOperation resultOperation)
        {
            Assert.NotNull(statements);

            int count = statements.Count + (prologue != null ? 1 : 0) + (epilogue != null ? 1 : 0);

            if (count == 0)
            {
                if (resultOperation.IsIgnore)
                {
                    return(AstUtils.Empty());
                }
                else if (resultOperation.Variable != null)
                {
                    return(Ast.Assign(resultOperation.Variable, AstUtils.Constant(null, resultOperation.Variable.Type)));
                }
                else
                {
                    return(Ast.Return(CurrentFrame.ReturnLabel, AstUtils.Constant(null)));
                }
            }
            else if (count == 1)
            {
                if (prologue != null)
                {
                    return(prologue);
                }

                if (epilogue != null)
                {
                    return(epilogue);
                }

                if (resultOperation.IsIgnore)
                {
                    return(statements.First.Transform(this));
                }
                else
                {
                    return(statements.First.TransformResult(this, resultOperation));
                }
            }
            else
            {
                var result = new AstBlock();

                if (prologue != null)
                {
                    result.Add(prologue);
                }

                // transform all but the last statement if it is an expression stmt:
                foreach (var statement in statements.AllButLast)
                {
                    result.Add(statement.Transform(this));
                }

                if (statements.Count > 0)
                {
                    if (resultOperation.IsIgnore)
                    {
                        result.Add(statements.Last.Transform(this));
                    }
                    else
                    {
                        result.Add(statements.Last.TransformResult(this, resultOperation));
                    }
                }

                if (epilogue != null)
                {
                    result.Add(epilogue);
                }

                result.Add(AstUtils.Empty());
                return(result);
            }
        }
示例#23
0
 internal MSA.Expression /*!*/ TransformStatements(MSA.Expression prologue, Statements /*!*/ statements, ResultOperation resultOperation)
 {
     return(TransformStatements(prologue, statements, null, resultOperation));
 }
示例#24
0
 public ShutdownHandlerStatement(LexicalScope /*!*/ definedScope, Statements /*!*/ body, SourceSpan location)
     : base(location)
 {
     _block = new BlockDefinition(definedScope, null, body, location);
 }
示例#25
0
        public ForLoopExpression(LexicalScope /*!*/ definedScope, Parameters /*!*/ variables, Expression /*!*/ list, Statements body, SourceSpan location)
            : base(location)
        {
            Assert.NotNull(definedScope, variables, list);

            _block = new BlockDefinition(definedScope, variables, body, location);
            _list  = list;
        }
示例#26
0
 public WhenClause(Expression /*!*/[] comparisons, Statements statements, SourceSpan location)
     : base(location)
 {
     _comparisons = comparisons ?? Expression.EmptyArray;
     _statements  = statements;
 }
示例#27
0
 private BlockExpression()
     : base(SourceSpan.None)
 {
     _statements = EmptyStatements;
 }