edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;C529561 File: Ruby.csproj =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;C529561 (server) 8/14/2008 5:49 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj;RubyAST @@ -229,10 +229,8 @@ - - =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj.vspscc;C390406 edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/AstGenerator.cs;C509767 File: AstGenerator.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/AstGenerator.cs;C509767 (server) 8/14/2008 6:17 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/AstGenerator.cs;RubyAST @@ -622,7 +622,7 @@ return result; } - internal MSA.Expression/*!*/ TransformStatements(List/*!*/ statements, ResultOperation resultOperation) { + internal MSA.Expression/*!*/ TransformStatements(List/*!*/ statements, ResultOperation resultOperation) { Assert.NotNullItems(statements); if (statements.Count > 0) { @@ -651,7 +651,7 @@ } } - internal MSA.Expression/*!*/ TransformStatementsToExpression(List statements) { + internal MSA.Expression/*!*/ TransformStatementsToExpression(List statements) { if (statements == null || statements.Count == 0) { return Ast.Null(); } @@ -660,7 +660,7 @@ return statements[0].TransformRead(this); } - MSA.Expression[] result = new MSA.Expression[statements.Count]; + var result = new MSA.Expression[statements.Count]; for (int i = 0; i < result.Length - 1; i++) { result[i] = statements[i].Transform(this); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/AstFactory.cs;C515501 File: AstFactory.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/AstFactory.cs;C515501 (server) 8/14/2008 5:28 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/AstFactory.cs;RubyAST @@ -73,13 +73,6 @@ #endregion - public static MSA.Expression/*!*/ Result(MSA.Expression/*!*/ resultVariable, MSA.Expression/*!*/ statement) { - return Ast.Comma( - statement, - resultVariable - ); - } - public static MSA.Expression/*!*/ Infinite(MSA.LabelTarget/*!*/ label, params MSA.Expression[]/*!*/ body) { return AstUtils.Infinite(Ast.Block(body), label); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/BlockDefinition.cs;C509767 File: BlockDefinition.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/BlockDefinition.cs;C509767 (server) 8/14/2008 6:19 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/BlockDefinition.cs;RubyAST @@ -35,15 +35,14 @@ internal const int MaxBlockArity = BlockDispatcher.MaxBlockArity; private readonly CompoundLeftValue/*!*/ _parameters; - private readonly List/*!*/ _body; + private readonly List/*!*/ _body; private readonly LexicalScope _definedScope; public CompoundLeftValue/*!*/ Parameters { get { return _parameters; } } - // TODO: readonly - public List/*!*/ Body { + public List/*!*/ Body { get { return _body; } } @@ -57,7 +56,7 @@ get { return _parameters.UnsplattedValue != null; } } - public BlockDefinition(LexicalScope definedScope, CompoundLeftValue/*!*/ parameters, List/*!*/ body, SourceSpan location) + public BlockDefinition(LexicalScope definedScope, CompoundLeftValue/*!*/ parameters, List/*!*/ body, SourceSpan location) : base(location) { Assert.NotNull(parameters, body); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Body.cs;C515501 File: Body.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Body.cs;C515501 (server) 8/14/2008 6:15 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Body.cs;RubyAST @@ -35,16 +35,16 @@ // statements // end - private readonly List/*!*/ _statements; + private readonly List/*!*/ _statements; private readonly List _rescueClauses; // optional - private readonly List _elseStatements; // optional - private readonly List _ensureStatements; // optional + private readonly List _elseStatements; // optional + private readonly List _ensureStatements; // optional // TODO: readonly - public List/*!*/ Statements { get { return _statements; } } + public List/*!*/ Statements { get { return _statements; } } public List RescueClauses { get { return _rescueClauses; } } - public List ElseStatements { get { return _elseStatements; } } - public List EnsureStatements { get { return _ensureStatements; } } + public List ElseStatements { get { return _elseStatements; } } + public List EnsureStatements { get { return _ensureStatements; } } private bool HasExceptionHandling { get { @@ -52,8 +52,8 @@ } } - public Body(List/*!*/ statements, List rescueClauses, List elseStatements, - List ensureStatements, SourceSpan location) + public Body(List/*!*/ statements, List rescueClauses, List elseStatements, + List ensureStatements, SourceSpan location) : base(location) { Assert.NotNull(statements); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/SourceUnitTree.cs;C510808 File: SourceUnitTree.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/SourceUnitTree.cs;C510808 (server) 8/14/2008 6:18 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/SourceUnitTree.cs;RubyAST @@ -13,6 +13,7 @@ * * ***************************************************************************/ +using System; using System.Collections.Generic; using System.Diagnostics; using System.Scripting; @@ -23,27 +24,26 @@ using Ruby.Runtime; using Ruby.Runtime.Calls; using MSA = System.Linq.Expressions; +using AstUtils = Microsoft.Scripting.Ast.Utils; namespace Ruby.Compiler.Ast { using Ast = System.Linq.Expressions.Expression; - using AstUtils = Microsoft.Scripting.Ast.Utils; - using System; public partial class SourceUnitTree : Node { private readonly LexicalScope/*!*/ _definedScope; private readonly List _initializers; - private readonly List _statements; + private readonly List _statements; public List Initializers { get { return _initializers; } } - public List Statements { + public List Statements { get { return _statements; } } - public SourceUnitTree(LexicalScope/*!*/ definedScope, List statements, List initializers, SourceSpan location) + public SourceUnitTree(LexicalScope/*!*/ definedScope, List statements, List initializers, SourceSpan location) : base(location) { ContractUtils.RequiresNotNull(definedScope, "scope"); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Clauses/ElseIfClause.cs;C509767 File: ElseIfClause.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Clauses/ElseIfClause.cs;C509767 (server) 8/14/2008 6:17 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Clauses/ElseIfClause.cs;RubyAST @@ -20,14 +20,14 @@ namespace Ruby.Compiler.Ast { public partial class ElseIfClause : Node { - private readonly List/*!*/ _statements; + private readonly List/*!*/ _statements; /// /// Null means a simple else. /// private readonly Expression _condition; - public List/*!*/ Statements { + public List/*!*/ Statements { get { return _statements; } } @@ -35,7 +35,7 @@ get { return _condition; } } - public ElseIfClause(Expression condition, List/*!*/ statements, SourceSpan location) + public ElseIfClause(Expression condition, List/*!*/ statements, SourceSpan location) : base(location) { Assert.NotNullItems(statements); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Clauses/RescueClause.cs;C509767 File: RescueClause.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Clauses/RescueClause.cs;C509767 (server) 8/14/2008 6:16 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Clauses/RescueClause.cs;RubyAST @@ -29,7 +29,7 @@ private readonly List _types; // optional private readonly LeftValue _target; // optional - private readonly List _statements; // optional + private readonly List _statements; // optional public List Types { get { return _types; } @@ -39,16 +39,16 @@ get { return _target; } } - public List Statements { + public List Statements { get { return _statements; } } - public RescueClause(List statements, SourceSpan location) + public RescueClause(List statements, SourceSpan location) : base(location) { _statements = statements; } - public RescueClause(List types, LeftValue target, List statements, SourceSpan location) + public RescueClause(List types, LeftValue target, List statements, SourceSpan location) : base(location) { _types = types; _target = target; =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Clauses/WhenClause.cs;C509767 File: WhenClause.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Clauses/WhenClause.cs;C509767 (server) 8/14/2008 6:20 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Clauses/WhenClause.cs;RubyAST @@ -26,9 +26,9 @@ // next private readonly Arguments/*!*/ _comparison; - private readonly List _statements; // optional + private readonly List _statements; // optional - public List Statements { + public List Statements { get { return _statements; } } @@ -36,7 +36,7 @@ get { return _comparison; } } - public WhenClause(Arguments/*!*/ comparison, List statements, SourceSpan location) + public WhenClause(Arguments/*!*/ comparison, List statements, SourceSpan location) : base(location) { ContractUtils.RequiresNotNull(comparison, "comparison"); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/CaseExpression.cs;C510808 File: CaseExpression.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/CaseExpression.cs;C510808 (server) 8/14/2008 5:22 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/CaseExpression.cs;RubyAST @@ -106,25 +106,27 @@ MSA.Expression resultVariable = gen.CurrentScope.DefineHiddenVariable("#case-compare-result", typeof(bool)); MSA.LabelTarget label = Ast.Label(); - return AstFactory.Result(resultVariable, - Ast.Block( - Ast.Assign(enumVariable, Ast.Call( - AstFactory.OpCall("Unsplat", array), - typeof(IEnumerable).GetMethod("GetEnumerator"))), - Ast.Assign(resultVariable, Ast.False()), - AstUtils.While( - Ast.Call(enumVariable, typeof(IEnumerator).GetMethod("MoveNext")), - AstUtils.If( - MakeTest(gen, Ast.Property(enumVariable, typeof(IEnumerator).GetProperty("Current")), value), - Ast.Block( - Ast.Assign(resultVariable, Ast.True()), - Ast.Break(label) - ) - ), - null, - label - ) - ) + return Ast.Comma( + Ast.Assign(enumVariable, Ast.Call( + AstFactory.OpCall("Unsplat", array), + typeof(IEnumerable).GetMethod("GetEnumerator")) + ), + + Ast.Assign(resultVariable, Ast.False()), + + AstUtils.While( + Ast.Call(enumVariable, typeof(IEnumerator).GetMethod("MoveNext")), + AstUtils.If( + MakeTest(gen, Ast.Property(enumVariable, typeof(IEnumerator).GetProperty("Current")), value), + Ast.Block( + Ast.Assign(resultVariable, Ast.True()), + Ast.Break(label) + ) + ), + null, + label + ), + resultVariable ); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/Expression.cs;C478584 File: Expression.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/Expression.cs;C478584 (server) 8/14/2008 5:47 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/Expression.cs;RubyAST @@ -18,21 +18,54 @@ using System.Scripting; using Ruby.Builtins; using MSA = System.Linq.Expressions; +using AstUtils = Microsoft.Scripting.Ast.Utils; namespace Ruby.Compiler.Ast { using Ast = System.Linq.Expressions.Expression; + /// + /// Represents expressions. Statements are considered special cases of expressions in AST class hierarchy. + /// Unlike syntactic expression a syntactic statement cannot be assigned to a left value. + /// However certain Ruby constructs (e.g. block-expression) allow to read the value of a statement. + /// Usually such value is null (e.g. undef, alias, while/until statements), + /// although some syntactic statements evaluate to a non-null value (e.g. if/unless-statements). + /// public abstract class Expression : Node { internal static readonly List/*!*/ EmptyList = new List(); protected Expression(SourceSpan location) : base(location) { + } + /// + /// Transform as expression (value is read); + /// + internal abstract MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen); + + /// + /// Transform as statement (value is not read). + /// + internal virtual MSA.Expression/*!*/ Transform(AstGenerator/*!*/ gen) { + return AstUtils.Comma(Location, TransformRead(gen)); } - internal abstract MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen); + /// + /// Transform and handle the result according to the specified result operation. + /// + internal virtual MSA.Expression/*!*/ TransformResult(AstGenerator/*!*/ gen, ResultOperation resultOperation) { + MSA.Expression resultExpression = TransformRead(gen); + MSA.Expression statement; + if (resultOperation.Variable != null) { + statement = Ast.Assign(resultOperation.Variable, Ast.Convert(resultExpression, resultOperation.Variable.Type)); + } else { + statement = Ast.Return(resultExpression); + } + + return AstUtils.Comma(Location, statement); + } + // Condition under which the expression is considered "defined?". // Returns null if there is no condition. internal virtual MSA.Expression TransformDefinedCondition(AstGenerator/*!*/ gen) { =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/ForLoopExpression.cs;C510808 File: ForLoopExpression.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/ForLoopExpression.cs;C510808 (server) 8/14/2008 6:20 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/ForLoopExpression.cs;RubyAST @@ -41,7 +41,7 @@ get { return _list; } } - public ForLoopExpression(CompoundLeftValue/*!*/ variables, Expression/*!*/ list, List body, SourceSpan location) + public ForLoopExpression(CompoundLeftValue/*!*/ variables, Expression/*!*/ list, List body, SourceSpan location) : base(location) { Assert.NotNull(variables, list); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/IfExpression.cs;C509767 File: IfExpression.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/IfExpression.cs;C509767 (server) 8/14/2008 6:18 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/IfExpression.cs;RubyAST @@ -23,14 +23,14 @@ public partial class IfExpression : Expression { private Expression/*!*/ _condition; - private List _body; + private List _body; private List _elseIfClauses; public Expression/*!*/ Condition { get { return _condition; } } - public List Body { + public List Body { get { return _body; } } @@ -38,7 +38,7 @@ get { return _elseIfClauses; } } - public IfExpression(Expression/*!*/ condition, List/*!*/ body, List/*!*/ elseIfClauses, SourceSpan location) + public IfExpression(Expression/*!*/ condition, List/*!*/ body, List/*!*/ elseIfClauses, SourceSpan location) : base(location) { ContractUtils.RequiresNotNull(body, "body"); ContractUtils.RequiresNotNull(condition, "condition"); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/RescueExpression.cs;C509767 File: RescueExpression.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/RescueExpression.cs;C509767 (server) 8/14/2008 6:15 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/RescueExpression.cs;RubyAST @@ -24,17 +24,17 @@ public partial class RescueExpression : Expression { private readonly SourceSpan _rescueSpan; private readonly Expression/*!*/ _guardedExpression; - private readonly Statement/*!*/ _rescueClauseStatement; + private readonly Expression/*!*/ _rescueClauseStatement; public Expression/*!*/ GuardedExpression { get { return _guardedExpression; } } - public Statement/*!*/ RescueClauseStatement { + public Expression/*!*/ RescueClauseStatement { get { return _rescueClauseStatement; } } - public RescueExpression(Expression/*!*/ guardedExpression, Statement/*!*/ rescueClauseStatement, SourceSpan rescueSpan, SourceSpan location) + public RescueExpression(Expression/*!*/ guardedExpression, Expression/*!*/ rescueClauseStatement, SourceSpan rescueSpan, SourceSpan location) : base(location) { ContractUtils.RequiresNotNull(guardedExpression, "guardedExpression"); ContractUtils.RequiresNotNull(rescueClauseStatement, "rescueClauseStatement"); @@ -46,9 +46,9 @@ internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) { return new Body( - CollectionUtils.MakeList(new ExpressionStatement(_guardedExpression)), + CollectionUtils.MakeList(_guardedExpression), CollectionUtils.MakeList( - new RescueClause(CollectionUtils.MakeList(_rescueClauseStatement), _rescueSpan) + new RescueClause(CollectionUtils.MakeList(_rescueClauseStatement), _rescueSpan) ), null, null, Location).TransformToExpression(gen); } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/UnlessExpression.cs;C509767 File: UnlessExpression.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/UnlessExpression.cs;C509767 (server) 8/14/2008 6:17 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/UnlessExpression.cs;RubyAST @@ -23,14 +23,14 @@ public partial class UnlessExpression : Expression { private readonly Expression/*!*/ _condition; - private readonly List _statements; + private readonly List _statements; private readonly ElseIfClause _elseClause; public Expression/*!*/ Condition { get { return _condition; } } - public List Statements { + public List Statements { get { return _statements; } } @@ -38,7 +38,7 @@ get { return _elseClause; } } - public UnlessExpression(Expression/*!*/ condition, List/*!*/ statements, ElseIfClause elseClause, SourceSpan location) + public UnlessExpression(Expression/*!*/ condition, List/*!*/ statements, ElseIfClause elseClause, SourceSpan location) : base(location) { ContractUtils.RequiresNotNull(condition, "condition"); ContractUtils.RequiresNotNull(statements, "statements"); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/WhileLoopExpression.cs;C509767 File: WhileLoopExpression.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/WhileLoopExpression.cs;C509767 (server) 8/14/2008 5:01 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Expressions/WhileLoopExpression.cs;RubyAST @@ -23,21 +23,18 @@ namespace Ruby.Compiler.Ast { using Ast = System.Linq.Expressions.Expression; + // while do end + // until do end public partial class WhileLoopExpression : Expression { - // while/until cond - // body - // end - - private readonly LexicalScope/*!*/ _scope; private readonly Expression _condition; - private readonly List _statements; // optional + private readonly List _statements; // optional private readonly bool _isWhileLoop; public Expression Condition { get { return _condition; } } - public List Statements { + public List Statements { get { return _statements; } } @@ -45,13 +42,12 @@ get { return _isWhileLoop; } } - public WhileLoopExpression(LexicalScope/*!*/ scope, Expression/*!*/ condition, bool isWhileLoop, List/*!*/ statements, SourceSpan location) + public WhileLoopExpression(Expression/*!*/ condition, bool isWhileLoop, List/*!*/ statements, SourceSpan location) : base(location) { ContractUtils.RequiresNotNull(condition, "condition"); ContractUtils.RequiresNotNullItems(statements, "statements"); - _scope = scope; _condition = condition; _isWhileLoop = isWhileLoop; _statements = statements; @@ -64,7 +60,6 @@ MSA.Expression blockUnwinder = gen.CurrentScope.DefineHiddenVariable("#unwinder", typeof(BlockUnwinder)); MSA.VariableExpression evalUnwinder = gen.CurrentScope.DefineHiddenVariable("#unwinder", typeof(EvalUnwinder)); - bool isInnerLoop = gen.CurrentLoop != null; MSA.LabelTarget loopLabel = Ast.Label(); @@ -124,7 +119,7 @@ ); } - return AstFactory.Result(resultVariable, loop); + return Ast.Comma(loop, resultVariable); } } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/JumpStatements/JumpStatement.cs;C509767 File: JumpStatement.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/JumpStatements/JumpStatement.cs;C509767 (server) 8/14/2008 6:20 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/JumpStatements/JumpStatement.cs;RubyAST @@ -20,7 +20,7 @@ namespace Ruby.Compiler.Ast { using Ast = System.Linq.Expressions.Expression; - public abstract class JumpStatement : Statement { + public abstract class JumpStatement : Expression { private readonly LexicalScope/*!*/ _scope; private readonly Arguments _arguments; =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/AliasStatement.cs;C509767 File: AliasStatement.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/AliasStatement.cs;C509767 (server) 8/14/2008 5:56 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/AliasStatement.cs;RubyAST @@ -21,7 +21,7 @@ namespace Ruby.Compiler.Ast { using Ast = System.Linq.Expressions.Expression; - public partial class AliasStatement : Statement { + public partial class AliasStatement : Expression { private readonly SymbolId _newName; private readonly SymbolId _oldName; private readonly bool _isMethodAlias; =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/ConditionalStatement.cs;C509767 File: ConditionalStatement.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/ConditionalStatement.cs;C509767 (server) 8/14/2008 5:56 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/ConditionalStatement.cs;RubyAST @@ -25,21 +25,21 @@ /// Represents if- and unless- statements. /// Also used for (condition) ? jump-statement : jump-statement. /// - public partial class ConditionalStatement : Statement { + public partial class ConditionalStatement : Expression { private readonly Expression/*!*/ _condition; - private readonly Statement/*!*/ _body; - private readonly Statement _elseStatement; + private readonly Expression/*!*/ _body; + private readonly Expression _elseStatement; private readonly bool _negateCondition; public Expression/*!*/ Condition { get { return _condition; } } - public Statement/*!*/ Body { + public Expression/*!*/ Body { get { return _body; } } - public Statement ElseStatement { + public Expression ElseStatement { get { return _elseStatement; } } @@ -47,7 +47,7 @@ get { return _negateCondition; } } - public ConditionalStatement(Expression/*!*/ condition, bool negateCondition, Statement/*!*/ body, Statement elseStatement, SourceSpan location) + public ConditionalStatement(Expression/*!*/ condition, bool negateCondition, Expression/*!*/ body, Expression elseStatement, SourceSpan location) : base(location) { ContractUtils.RequiresNotNull(condition, "condition"); ContractUtils.RequiresNotNull(body, "body"); =================================================================== delete: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/ExpressionStatement.cs;C478584 File: ExpressionStatement.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/ExpressionStatement.cs;C478584 (server) 8/14/2008 6:09 PM +++ [no target file] @@ -1,40 +1,0 @@ -/* **************************************************************************** - * - * Copyright (c) Microsoft Corporation. - * - * This source code is subject to terms and conditions of the Microsoft Public License. A - * copy of the license can be found in the License.html file at the root of this distribution. If - * you cannot locate the Microsoft Public License, please send an email to - * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound - * by the terms of the Microsoft Public License. - * - * You must not remove this notice, or any other, from this software. - * - * - * ***************************************************************************/ - -using System.Diagnostics; -using MSA = System.Linq.Expressions; - -namespace Ruby.Compiler.Ast { - - public partial class ExpressionStatement : Statement { - private readonly Expression/*!*/ _expression; - - public Expression/*!*/ Expression { - get { return _expression; } - } - - public ExpressionStatement(Expression/*!*/ expression) - : base(expression.Location) { - Debug.Assert(expression != null); - - _expression = expression; - } - - internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) { - return _expression.TransformRead(gen); - } - } -} - =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/Finalizer.cs;C509767 File: Finalizer.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/Finalizer.cs;C509767 (server) 8/14/2008 5:56 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/Finalizer.cs;RubyAST @@ -21,19 +21,19 @@ namespace Ruby.Compiler.Ast { - public partial class Finalizer : Statement { + public partial class Finalizer : Expression { // END { body } private readonly LexicalScope/*!*/ _definedScope; // TODO: - private readonly List _statements; + private readonly List _statements; - public List Statements { + public List Statements { get { return _statements; } } - public Finalizer(LexicalScope/*!*/ definedScope, List statements, SourceSpan location) + public Finalizer(LexicalScope/*!*/ definedScope, List statements, SourceSpan location) : base(location) { Assert.NotNull(definedScope); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/Initializer.cs;C509767 File: Initializer.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/Initializer.cs;C509767 (server) 8/14/2008 5:56 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/Initializer.cs;RubyAST @@ -21,19 +21,19 @@ namespace Ruby.Compiler.Ast { - public partial class Initializer : Statement { + public partial class Initializer : Expression { // BEGIN { body } private readonly LexicalScope/*!*/ _definedScope; // TODO: - private readonly List _statements; + private readonly List _statements; - public List Statements { + public List Statements { get { return _statements; } } - public Initializer(LexicalScope/*!*/ definedScope, List statements, SourceSpan location) + public Initializer(LexicalScope/*!*/ definedScope, List statements, SourceSpan location) : base(location) { Assert.NotNull(definedScope); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/RescueStatement.cs;C509767 File: RescueStatement.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/RescueStatement.cs;C509767 (server) 8/14/2008 5:56 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/RescueStatement.cs;RubyAST @@ -20,24 +20,24 @@ namespace Ruby.Compiler.Ast { // statement rescue statement - public partial class RescueStatement : Statement { + public partial class RescueStatement : Expression { private readonly SourceSpan _rescueSpan; - private readonly Statement/*!*/ _guardedStatement; - private readonly Statement/*!*/ _rescueClauseStatement; + private readonly Expression/*!*/ _guardedStatement; + private readonly Expression/*!*/ _rescueClauseStatement; public SourceSpan RescueSpan { get { return _rescueSpan; } } - public Statement/*!*/ GuardedStatement { + public Expression/*!*/ GuardedStatement { get { return _guardedStatement; } } - public Statement/*!*/ RescueClauseStatement { + public Expression/*!*/ RescueClauseStatement { get { return _rescueClauseStatement; } } - public RescueStatement(Statement/*!*/ guardedStatement, Statement/*!*/ rescueClauseStatement, SourceSpan rescueSpan, SourceSpan location) + public RescueStatement(Expression/*!*/ guardedStatement, Expression/*!*/ rescueClauseStatement, SourceSpan rescueSpan, SourceSpan location) : base(location) { ContractUtils.RequiresNotNull(guardedStatement, "guardedStatement"); ContractUtils.RequiresNotNull(rescueClauseStatement, "rescueClauseStatement"); =================================================================== delete: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/Statement.cs;C478584 File: Statement.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/Statement.cs;C478584 (server) 8/14/2008 6:21 PM +++ [no target file] @@ -1,50 +1,0 @@ -/* **************************************************************************** - * - * Copyright (c) Microsoft Corporation. - * - * This source code is subject to terms and conditions of the Microsoft Public License. A - * copy of the license can be found in the License.html file at the root of this distribution. If - * you cannot locate the Microsoft Public License, please send an email to - * ironruby@microsoft.com. By using this source code in any fashion, you are agreeing to be bound - * by the terms of the Microsoft Public License. - * - * You must not remove this notice, or any other, from this software. - * - * - * ***************************************************************************/ - -using System.Collections.Generic; -using System.Scripting; -using AstUtils = Microsoft.Scripting.Ast.Utils; -using MSA = System.Linq.Expressions; - -namespace Ruby.Compiler.Ast { - using Ast = System.Linq.Expressions.Expression; - - public abstract class Statement : Node { - internal static readonly List/*!*/ EmptyList = new List(); - - protected Statement(SourceSpan location) - : base(location) { - } - - internal virtual MSA.Expression/*!*/ Transform(AstGenerator/*!*/ gen) { - return AstUtils.Comma(Location, TransformRead(gen)); - } - - internal virtual MSA.Expression/*!*/ TransformResult(AstGenerator/*!*/ gen, ResultOperation resultOperation) { - MSA.Expression resultExpression = TransformRead(gen); - MSA.Expression statement; - - if (resultOperation.Variable != null) { - statement = Ast.Assign(resultOperation.Variable, Ast.Convert(resultExpression, resultOperation.Variable.Type)); - } else { - statement = Ast.Return(resultExpression); - } - - return AstUtils.Comma(Location, statement); - } - - internal abstract MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen); - } -} =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/UndefineStatement.cs;C509767 File: UndefineStatement.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/UndefineStatement.cs;C509767 (server) 8/14/2008 5:56 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/UndefineStatement.cs;RubyAST @@ -22,7 +22,7 @@ namespace Ruby.Compiler.Ast { using Ast = System.Linq.Expressions.Expression; - public partial class UndefineStatement : Statement { + public partial class UndefineStatement : Expression { private readonly List/*!*/ _items; public UndefineStatement(List/*!*/ items, SourceSpan location) =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/WhileLoopStatement.cs;C509767 File: WhileLoopStatement.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/WhileLoopStatement.cs;C509767 (server) 8/14/2008 4:49 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Statements/WhileLoopStatement.cs;RubyAST @@ -20,23 +20,20 @@ namespace Ruby.Compiler.Ast { - public partial class WhileLoopStatement : Statement { - // until cond - // body - // end - + // while + // until + // while + // until + public partial class WhileLoopStatement : Expression { private readonly Expression/*!*/ _condition; - private readonly Statement _statements; // optional + private readonly Expression _statements; // optional private readonly bool _isWhileLoop; - private readonly bool _isPostTest; - private readonly LexicalScope/*!*/ _parentScope; - public Expression/*!*/ Condition { get { return _condition; } } - public Statement Statements { + public Expression Statements { get { return _statements; } } @@ -44,28 +41,22 @@ get { return _isWhileLoop; } } - public bool IsPostTest { - get { return _isPostTest; } - } - - public WhileLoopStatement(LexicalScope/*!*/ parentScope, Expression/*!*/ condition, bool isPostTest, bool isWhileLoop, - Statement/*!*/ body, SourceSpan location) + public WhileLoopStatement(Expression/*!*/ condition, bool isWhileLoop, + Expression/*!*/ body, SourceSpan location) : base(location) { - Assert.NotNull(parentScope, condition); + Assert.NotNull(condition); - _parentScope = parentScope; _condition = condition; _isWhileLoop = isWhileLoop; _statements = body; - _isPostTest = isPostTest; } internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) { - List stmt = new List(1); + List stmt = new List(1); if (_statements != null) { stmt.Add(_statements); } - return new WhileLoopExpression(_parentScope, _condition, _isWhileLoop, stmt, Location).TransformRead(gen); + return new WhileLoopExpression(_condition, _isWhileLoop, stmt, Location).TransformRead(gen); } } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Walkers/NodeTypes.cs;C525618 File: NodeTypes.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Walkers/NodeTypes.cs;C525618 (server) 8/14/2008 6:11 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Walkers/NodeTypes.cs;RubyAST @@ -161,7 +161,6 @@ public partial class AliasStatement { public override NodeTypes NodeType { get { return NodeTypes.AliasStatement; } } internal protected override void Walk(Walker/*!*/ walker) { walker.Walk(this); } } public partial class ConditionalStatement { public override NodeTypes NodeType { get { return NodeTypes.ConditionalStatement; } } internal protected override void Walk(Walker/*!*/ walker) { walker.Walk(this); } } - public partial class ExpressionStatement { public override NodeTypes NodeType { get { return NodeTypes.ExpressionStatement; } } internal protected override void Walk(Walker/*!*/ walker) { walker.Walk(this); } } public partial class Finalizer { public override NodeTypes NodeType { get { return NodeTypes.Finalizer; } } internal protected override void Walk(Walker/*!*/ walker) { walker.Walk(this); } } public partial class Initializer { public override NodeTypes NodeType { get { return NodeTypes.Initializer; } } internal protected override void Walk(Walker/*!*/ walker) { walker.Walk(this); } } public partial class RescueStatement { public override NodeTypes NodeType { get { return NodeTypes.RescueStatement; } } internal protected override void Walk(Walker/*!*/ walker) { walker.Walk(this); } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Walkers/Walker.cs;C525618 File: Walker.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Walkers/Walker.cs;C525618 (server) 8/14/2008 6:12 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Walkers/Walker.cs;RubyAST @@ -580,13 +580,6 @@ Exit(node); } - internal protected virtual void Walk(ExpressionStatement/*!*/ node) { - if (Enter(node)) { - node.Expression.Walk(this); - } - Exit(node); - } - internal protected virtual void Walk(Initializer/*!*/ node) { if (Enter(node)) { VisitOptionalList(node.Statements); =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Walkers/Walker.Generated.cs;C525618 File: Walker.Generated.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Walkers/Walker.Generated.cs;C525618 (server) 8/14/2008 6:11 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Walkers/Walker.Generated.cs;RubyAST @@ -137,8 +137,6 @@ public virtual void Exit(AliasStatement/*!*/ node) { } public virtual bool Enter(ConditionalStatement/*!*/ node) { return true; } public virtual void Exit(ConditionalStatement/*!*/ node) { } - public virtual bool Enter(ExpressionStatement/*!*/ node) { return true; } - public virtual void Exit(ExpressionStatement/*!*/ node) { } public virtual bool Enter(Finalizer/*!*/ node) { return true; } public virtual void Exit(Finalizer/*!*/ node) { } public virtual bool Enter(Initializer/*!*/ node) { return true; } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Parser.cs;C525618 File: Parser.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Parser.cs;C525618 (server) 8/14/2008 5:00 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Parser.cs;RubyAST @@ -249,29 +249,29 @@ Tokenizer.ReportError(Errors.MatchGroupReferenceReadOnly, matchRef.VariableName); } - private Statement/*!*/ MakeGlobalAlias(SymbolId newVar, SymbolId/*!*/ existingVar, SourceSpan location) { + private AliasStatement/*!*/ MakeGlobalAlias(SymbolId newVar, SymbolId/*!*/ existingVar, SourceSpan location) { return new AliasStatement(false, newVar, existingVar, location); } - private Statement/*!*/ MakeGlobalAlias(SymbolId newVar, RegexMatchReference/*!*/ existingVar, SourceSpan location) { + private Expression/*!*/ MakeGlobalAlias(SymbolId newVar, RegexMatchReference/*!*/ existingVar, SourceSpan location) { if (existingVar.CanAlias) { return new AliasStatement(false, newVar, existingVar.VariableSymbol, location); } else { _tokenizer.ReportError(Errors.CannotAliasGroupMatchVariable); - return new ExpressionStatement(new ErrorExpression(location)); + return new ErrorExpression(location); } } - private Statement/*!*/ MakeGlobalAlias(RegexMatchReference/*!*/ newVar, SymbolId existingVar, SourceSpan location) { + private AliasStatement/*!*/ MakeGlobalAlias(RegexMatchReference/*!*/ newVar, SymbolId existingVar, SourceSpan location) { return new AliasStatement(false, newVar.VariableSymbol, existingVar, location); } - private Statement/*!*/ MakeGlobalAlias(RegexMatchReference/*!*/ newVar, RegexMatchReference/*!*/ existingVar, SourceSpan location) { + private Expression/*!*/ MakeGlobalAlias(RegexMatchReference/*!*/ newVar, RegexMatchReference/*!*/ existingVar, SourceSpan location) { if (existingVar.CanAlias) { return new AliasStatement(false, newVar.VariableSymbol, existingVar.VariableSymbol, location); } else { _tokenizer.ReportError(Errors.CannotAliasGroupMatchVariable); - return new ExpressionStatement(new ErrorExpression(location)); + return new ErrorExpression(location); } } @@ -283,7 +283,7 @@ return result; } - private IfExpression/*!*/ MakeIfExpression(Expression/*!*/ condition, List/*!*/ body, List/*!*/ elseIfClauses, SourceSpan location) { + private IfExpression/*!*/ MakeIfExpression(Expression/*!*/ condition, List/*!*/ body, List/*!*/ elseIfClauses, SourceSpan location) { // last else-if/else clause is the first one in the list: elseIfClauses.Reverse(); return new IfExpression(condition, body, elseIfClauses, location); @@ -327,12 +327,8 @@ return arguments; } - private Statement/*!*/ MakeLoopStatement(Statement/*!*/ statement, Expression/*!*/ condition, bool isWhileLoop, SourceSpan location) { - ExpressionStatement exprStmt; - BlockExpression blockExpr; - - bool isPostTest = ((exprStmt = statement as ExpressionStatement) != null && (blockExpr = exprStmt.Expression as BlockExpression) != null); - return new WhileLoopStatement(CurrentScope, condition, isPostTest, isWhileLoop, statement, location); + private Expression/*!*/ MakeLoopStatement(Expression/*!*/ statement, Expression/*!*/ condition, bool isWhileLoop, SourceSpan location) { + return new WhileLoopStatement(condition, isWhileLoop, statement, location); } public static string/*!*/ TerminalToString(int terminal) { =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Parser.Generated.cs;C525618 File: Parser.Generated.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Parser.Generated.cs;C525618 (server) 8/14/2008 5:04 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Parser.Generated.cs;RubyAST @@ -1931,7 +1931,7 @@ // program -> @1 compstmt #line 166 "Parser.y" { - _ast = new SourceUnitTree(CurrentScope, GetValue(1).Statements, _initializers, yyloc); + _ast = new SourceUnitTree(CurrentScope, GetValue(1).Expressions, _initializers, yyloc); } } @@ -1940,7 +1940,7 @@ // compstmt -> stmts opt_terms #line 172 "Parser.y" { - yyval.Statements = GetValue(2).Statements; + yyval.Expressions = GetValue(2).Expressions; } } @@ -1949,7 +1949,7 @@ // stmts -> #line 178 "Parser.y" { - yyval.Statements = new List(); + yyval.Expressions = new List(); } } @@ -1958,7 +1958,7 @@ // stmts -> stmt #line 182 "Parser.y" { - yyval.Statements = CollectionUtils.MakeList(GetValue(1).Statement); + yyval.Expressions = CollectionUtils.MakeList(GetValue(1).Expression); } } @@ -1967,8 +1967,8 @@ // stmts -> stmts terms stmt #line 186 "Parser.y" { - GetValue(3).Statements.Add(GetValue(1).Statement); - yyval.Statements = GetValue(3).Statements; + GetValue(3).Expressions.Add(GetValue(1).Expression); + yyval.Expressions = GetValue(3).Expressions; } } @@ -1977,7 +1977,7 @@ // stmts -> Error stmt #line 191 "Parser.y" { - yyval.Statements = CollectionUtils.MakeList(GetValue(1).Statement); + yyval.Expressions = CollectionUtils.MakeList(GetValue(1).Expression); } } @@ -1986,7 +1986,7 @@ // stmt -> Undef undef_list #line 198 "Parser.y" { - yyval.Statement = new UndefineStatement(GetValue(1).Identifiers, yyloc); + yyval.Expression = new UndefineStatement(GetValue(1).Identifiers, yyloc); } } @@ -2008,7 +2008,7 @@ // stmt -> UppercaseBegin @2 '{' compstmt '}' #line 210 "Parser.y" { - yyval.Statement = AddInitializer(new Initializer(CurrentScope, GetValue(2).Statements, yyloc)); + yyval.Expression = AddInitializer(new Initializer(CurrentScope, GetValue(2).Expressions, yyloc)); LeaveScope(); } } @@ -2031,7 +2031,7 @@ // stmt -> UppercaseEnd @3 '{' compstmt '}' #line 223 "Parser.y" { - yyval.Statement = new Finalizer(CurrentScope, GetValue(2).Statements, yyloc); + yyval.Expression = new Finalizer(CurrentScope, GetValue(2).Expressions, yyloc); LeaveScope(); } } @@ -2042,7 +2042,7 @@ #line 228 "Parser.y" { MatchReferenceReadOnlyError(GetValue(3).RegexMatchReference); - yyval.Statement = new ExpressionStatement(new ErrorExpression(yyloc)); + yyval.Expression = new ErrorExpression(yyloc); } } @@ -2051,7 +2051,7 @@ // stmt -> jump_statement #line 233 "Parser.y" { - yyval.Statement = GetValue(1).JumpStatement; + yyval.Expression = GetValue(1).JumpStatement; } } @@ -2060,7 +2060,7 @@ // stmt -> conditional_statement #line 237 "Parser.y" { - yyval.Statement = GetValue(1).Statement; + yyval.Expression = GetValue(1).Expression; } } @@ -2069,7 +2069,7 @@ // stmt -> expression_statement #line 241 "Parser.y" { - yyval.Statement = new ExpressionStatement(GetValue(1).Expression); + yyval.Expression = GetValue(1).Expression; } } @@ -2087,7 +2087,7 @@ // alias_statement -> Alias method_name_or_symbol @4 method_name_or_symbol #line 252 "Parser.y" { - yyval.Statement = new AliasStatement(true, GetValue(3).SymbolId, GetValue(1).SymbolId, yyloc); + yyval.Expression = new AliasStatement(true, GetValue(3).SymbolId, GetValue(1).SymbolId, yyloc); } } @@ -2096,7 +2096,7 @@ // alias_statement -> Alias GlobalVariable GlobalVariable #line 256 "Parser.y" { - yyval.Statement = MakeGlobalAlias(GetValue(2).SymbolId, GetValue(1).SymbolId, yyloc); + yyval.Expression = MakeGlobalAlias(GetValue(2).SymbolId, GetValue(1).SymbolId, yyloc); } } @@ -2105,7 +2105,7 @@ // alias_statement -> Alias GlobalVariable match_reference #line 260 "Parser.y" { - yyval.Statement = MakeGlobalAlias(GetValue(2).SymbolId, GetValue(1).RegexMatchReference, yyloc); + yyval.Expression = MakeGlobalAlias(GetValue(2).SymbolId, GetValue(1).RegexMatchReference, yyloc); } } @@ -2321,7 +2321,7 @@ // conditional_statement -> stmt IfMod expr #line 371 "Parser.y" { - yyval.Statement = new ConditionalStatement(GetValue(1).Expression, false, GetValue(3).Statement, null, yyloc); + yyval.Expression = new ConditionalStatement(GetValue(1).Expression, false, GetValue(3).Expression, null, yyloc); } } @@ -2330,7 +2330,7 @@ // conditional_statement -> stmt UnlessMod expr #line 375 "Parser.y" { - yyval.Statement = new ConditionalStatement(GetValue(1).Expression, true, GetValue(3).Statement, null, yyloc); + yyval.Expression = new ConditionalStatement(GetValue(1).Expression, true, GetValue(3).Expression, null, yyloc); } } @@ -2339,7 +2339,7 @@ // conditional_statement -> stmt WhileMod expr #line 379 "Parser.y" { - yyval.Statement = MakeLoopStatement(GetValue(3).Statement, GetValue(1).Expression, true, yyloc); + yyval.Expression = MakeLoopStatement(GetValue(3).Expression, GetValue(1).Expression, true, yyloc); } } @@ -2348,7 +2348,7 @@ // conditional_statement -> stmt UntilMod expr #line 383 "Parser.y" { - yyval.Statement = MakeLoopStatement(GetValue(3).Statement, GetValue(1).Expression, false, yyloc); + yyval.Expression = MakeLoopStatement(GetValue(3).Expression, GetValue(1).Expression, false, yyloc); } } @@ -2357,7 +2357,7 @@ // conditional_statement -> stmt RescueMod stmt #line 387 "Parser.y" { - yyval.Statement = new RescueStatement(GetValue(3).Statement, GetValue(1).Statement, MergeLocations(GetLocation(2), GetLocation(1)), yyloc); + yyval.Expression = new RescueStatement(GetValue(3).Expression, GetValue(1).Expression, MergeLocations(GetLocation(2), GetLocation(1)), yyloc); } } @@ -2366,7 +2366,7 @@ // conditional_statement -> arg '?' jump_statement_parameterless ':' jump_statement_parameterless #line 391 "Parser.y" { - yyval.Statement = new ConditionalStatement(GetValue(5).Expression, false, GetValue(3).JumpStatement, GetValue(1).JumpStatement, yyloc); + yyval.Expression = new ConditionalStatement(GetValue(5).Expression, false, GetValue(3).JumpStatement, GetValue(1).JumpStatement, yyloc); } } @@ -2521,7 +2521,7 @@ // cmd_brace_block -> LbraceArg @5 block_parameters_opt @6 compstmt '}' #line 476 "Parser.y" { - yyval.BlockDefinition = new BlockDefinition(CurrentScope, GetValue(4).CompoundLeftValue, GetValue(2).Statements, yyloc); + yyval.BlockDefinition = new BlockDefinition(CurrentScope, GetValue(4).CompoundLeftValue, GetValue(2).Expressions, yyloc); LeaveScope(); } } @@ -3184,7 +3184,7 @@ // arg -> lhs '=' arg RescueMod arg #line 773 "Parser.y" { - yyval.Expression = new SimpleAssignmentExpression(GetValue(5).LeftValue, new RescueExpression(GetValue(3).Expression, new ExpressionStatement(GetValue(1).Expression), MergeLocations(GetLocation(2), GetLocation(1)), MergeLocations(GetLocation(3), GetLocation(1))), SymbolId.Empty, yyloc); + yyval.Expression = new SimpleAssignmentExpression(GetValue(5).LeftValue, new RescueExpression(GetValue(3).Expression, GetValue(1).Expression, MergeLocations(GetLocation(2), GetLocation(1)), MergeLocations(GetLocation(3), GetLocation(1))), SymbolId.Empty, yyloc); } } @@ -4167,7 +4167,7 @@ // primary -> If expr then compstmt if_tail End #line 1255 "Parser.y" { - yyval.Expression = MakeIfExpression(GetValue(5).Expression, GetValue(3).Statements, GetValue(2).ElseIfClauses, yyloc); + yyval.Expression = MakeIfExpression(GetValue(5).Expression, GetValue(3).Expressions, GetValue(2).ElseIfClauses, yyloc); } } @@ -4176,7 +4176,7 @@ // primary -> Unless expr then compstmt else_opt End #line 1259 "Parser.y" { - yyval.Expression = new UnlessExpression(GetValue(5).Expression, GetValue(3).Statements, GetValue(2).ElseIfClause, yyloc); + yyval.Expression = new UnlessExpression(GetValue(5).Expression, GetValue(3).Expressions, GetValue(2).ElseIfClause, yyloc); } } @@ -4203,7 +4203,7 @@ // primary -> While @11 expr do @12 compstmt End #line 1271 "Parser.y" { - yyval.Expression = new WhileLoopExpression(CurrentScope, GetValue(5).Expression, true, GetValue(2).Statements, yyloc); + yyval.Expression = new WhileLoopExpression(GetValue(5).Expression, true, GetValue(2).Expressions, yyloc); } } @@ -4230,7 +4230,7 @@ // primary -> Until @13 expr do @14 compstmt End #line 1283 "Parser.y" { - yyval.Expression = new WhileLoopExpression(CurrentScope, GetValue(5).Expression, false, GetValue(2).Statements, yyloc); + yyval.Expression = new WhileLoopExpression(GetValue(5).Expression, false, GetValue(2).Expressions, yyloc); } } @@ -4257,7 +4257,7 @@ // primary -> For block_parameters In @15 expr do @16 compstmt End #line 1296 "Parser.y" { - yyval.Expression = new ForLoopExpression(GetValue(8).CompoundLeftValue, GetValue(5).Expression, GetValue(2).Statements, yyloc); + yyval.Expression = new ForLoopExpression(GetValue(8).CompoundLeftValue, GetValue(5).Expression, GetValue(2).Expressions, yyloc); } } @@ -4276,7 +4276,7 @@ #line 1309 "Parser.y" { _tokenizer.ReportWarning("(...) interpreted as grouped expression"); - yyval.Expression = new BlockExpression(new Body(CollectionUtils.MakeList(new ExpressionStatement(GetValue(4).Expression)), null, null, null, yyloc), yyloc); + yyval.Expression = new BlockExpression(new Body(CollectionUtils.MakeList(GetValue(4).Expression), null, null, null, yyloc), yyloc); } } @@ -4285,7 +4285,7 @@ // block_expression -> LeftParen compstmt ')' #line 1314 "Parser.y" { - yyval.Expression = new BlockExpression(new Body(GetValue(2).Statements, null, null, null, yyloc), yyloc); + yyval.Expression = new BlockExpression(new Body(GetValue(2).Expressions, null, null, null, yyloc), yyloc); } } @@ -4438,7 +4438,7 @@ ErrorSink.Add(_sourceUnit, "else without rescue is useless", GetLocation(2), -1, Severity.Warning); } - yyval.Body = new Body(GetValue(4).Statements, GetValue(3).RescueClauses, (elseIf != null) ? elseIf.Statements : null, GetValue(1).Statements, yyloc); + yyval.Body = new Body(GetValue(4).Expressions, GetValue(3).RescueClauses, (elseIf != null) ? elseIf.Statements : null, GetValue(1).Expressions, yyloc); } } @@ -4492,7 +4492,7 @@ // if_tail -> Elsif expr then compstmt if_tail #line 1446 "Parser.y" { - GetValue(1).ElseIfClauses.Add(new ElseIfClause(GetValue(4).Expression, GetValue(2).Statements, yyloc)); + GetValue(1).ElseIfClauses.Add(new ElseIfClause(GetValue(4).Expression, GetValue(2).Expressions, yyloc)); yyval.ElseIfClauses = GetValue(1).ElseIfClauses; } } @@ -4511,7 +4511,7 @@ // else_opt -> Else compstmt #line 1457 "Parser.y" { - yyval.ElseIfClause = new ElseIfClause(null, GetValue(1).Statements, yyloc); + yyval.ElseIfClause = new ElseIfClause(null, GetValue(1).Expressions, yyloc); } } @@ -4592,7 +4592,7 @@ // do_block -> BlockDo @25 block_parameters_opt @26 compstmt End #line 1501 "Parser.y" { - yyval.BlockDefinition = new BlockDefinition(CurrentScope, GetValue(4).CompoundLeftValue, GetValue(2).Statements, yyloc); + yyval.BlockDefinition = new BlockDefinition(CurrentScope, GetValue(4).CompoundLeftValue, GetValue(2).Expressions, yyloc); LeaveScope(); } } @@ -4701,7 +4701,7 @@ // brace_block -> '{' @27 block_parameters_opt @28 compstmt '}' #line 1557 "Parser.y" { - yyval.BlockDefinition = new BlockDefinition(CurrentScope, GetValue(4).CompoundLeftValue, GetValue(2).Statements, yyloc); + yyval.BlockDefinition = new BlockDefinition(CurrentScope, GetValue(4).CompoundLeftValue, GetValue(2).Expressions, yyloc); LeaveScope(); } } @@ -4728,7 +4728,7 @@ // brace_block -> Do @29 block_parameters_opt @30 compstmt End #line 1569 "Parser.y" { - yyval.BlockDefinition = new BlockDefinition(CurrentScope, GetValue(4).CompoundLeftValue, GetValue(2).Statements, yyloc); + yyval.BlockDefinition = new BlockDefinition(CurrentScope, GetValue(4).CompoundLeftValue, GetValue(2).Expressions, yyloc); LeaveScope(); } } @@ -4757,7 +4757,7 @@ // when_clause -> When when_args then compstmt #line 1587 "Parser.y" { - yyval.WhenClause = new WhenClause(GetValue(3).Arguments, GetValue(1).Statements, yyloc); + yyval.WhenClause = new WhenClause(GetValue(3).Arguments, GetValue(1).Expressions, yyloc); } } @@ -4812,7 +4812,7 @@ // rescue_clause -> Rescue exc_list exc_var then compstmt #line 1623 "Parser.y" { - yyval.RescueClause = new RescueClause(GetValue(4).Expressions, GetValue(3).LeftValue, GetValue(1).Statements, yyloc); + yyval.RescueClause = new RescueClause(GetValue(4).Expressions, GetValue(3).LeftValue, GetValue(1).Expressions, yyloc); } } @@ -4848,7 +4848,7 @@ // ensure_opt -> Ensure compstmt #line 1648 "Parser.y" { - yyval.Statements = GetValue(1).Statements; + yyval.Expressions = GetValue(1).Expressions; } } @@ -5068,7 +5068,7 @@ { // pop _tokenizer.StringEmbeddedCodeEnd(GetValue(3).term); - yyval.Expression = new BlockExpression(new Body(GetValue(2).Statements, null, null, null, GetLocation(2)), GetLocation(2)); + yyval.Expression = new BlockExpression(new Body(GetValue(2).Expressions, null, null, null, GetLocation(2)), GetLocation(2)); } } =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Parser.y;C525618 File: Parser.y =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Parser.y;C525618 (server) 8/14/2008 5:02 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/Parser.y;RubyAST @@ -53,11 +53,11 @@ %type program -%type stmt -%type stmts compstmt ensure_opt +%type stmt +%type stmts compstmt ensure_opt %type jump_statement jump_statement_with_parameters jump_statement_parameterless -%type alias_statement -%type conditional_statement +%type alias_statement +%type conditional_statement %type primary expr expression_statement superclass var_ref singleton case_expression %type arg @@ -176,11 +176,11 @@ stmts : /* empty */ { - $$ = new List(); + $$ = new List(); } | stmt { - $$ = CollectionUtils.MakeList($1); + $$ = CollectionUtils.MakeList($1); } | stmts terms stmt { @@ -189,7 +189,7 @@ } | ERROR stmt { - $$ = CollectionUtils.MakeList($2); + $$ = CollectionUtils.MakeList($2); } ; @@ -227,7 +227,7 @@ | match_reference ASSIGNMENT command_call { MatchReferenceReadOnlyError($1); - $$ = new ExpressionStatement(new ErrorExpression(@$)); + $$ = new ErrorExpression(@$); } | jump_statement { @@ -239,7 +239,7 @@ } | expression_statement { - $$ = new ExpressionStatement($1); + $$ = $1; } ; @@ -771,7 +771,7 @@ } | lhs '=' arg RESCUE_MOD arg { - $$ = new SimpleAssignmentExpression($1, new RescueExpression($3, new ExpressionStatement($5), MergeLocations(@4, @5), MergeLocations(@3, @5)), SymbolId.Empty, @$); + $$ = new SimpleAssignmentExpression($1, new RescueExpression($3, $5, MergeLocations(@4, @5), MergeLocations(@3, @5)), SymbolId.Empty, @$); } | lhs '=' arg RESCUE_MOD jump_statement_parameterless { @@ -1269,7 +1269,7 @@ } compstmt END { - $$ = new WhileLoopExpression(CurrentScope, $3, true, $6, @$); + $$ = new WhileLoopExpression($3, true, $6, @$); } | UNTIL { @@ -1281,7 +1281,7 @@ } compstmt END { - $$ = new WhileLoopExpression(CurrentScope, $3, false, $6, @$); + $$ = new WhileLoopExpression($3, false, $6, @$); } | case_expression | FOR block_parameters IN @@ -1308,7 +1308,7 @@ opt_nl ')' { _tokenizer.ReportWarning("(...) interpreted as grouped expression"); - $$ = new BlockExpression(new Body(CollectionUtils.MakeList(new ExpressionStatement($2)), null, null, null, @$), @$); + $$ = new BlockExpression(new Body(CollectionUtils.MakeList($2), null, null, null, @$), @$); } | LEFT_PAREN compstmt ')' { =================================================================== edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/TokenValue.cs;C509767 File: TokenValue.cs =================================================================== --- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/TokenValue.cs;C509767 (server) 8/14/2008 6:20 PM +++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Parser/TokenValue.cs;RubyAST @@ -57,7 +57,6 @@ internal VariableFactory VariableFactory { get { return (VariableFactory)obj; } set { obj = value; } } public RubyRegexOptions RegExOptions { get { return (RubyRegexOptions)Integer; } set { Integer = (int)value; } } - public Statement Statement { get { return (Statement)node; } set { node = value; } } public Expression Expression { get { return (Expression)node; } set { node = value; } } public CallExpression CallExpression { get { return (CallExpression)node; } set { node = value; } } public ElseIfClause ElseIfClause { get { return (ElseIfClause)node; } set { node = value; } } @@ -86,7 +85,7 @@ public List/*!*/ WhenClauses { get { return (List)obj; } set { obj = value; } } public List/*!*/ LeftValueList { get { return (List)obj; } set { obj = value; } } public List/*!*/ Expressions { get { return (List)obj; } set { obj = value; } } - public List/*!*/ Statements { get { return (List)obj; } set { obj = value; } } + public List/*!*/ Statements { get { return (List)obj; } set { obj = value; } } public List RescueClauses { get { return (List)obj; } set { obj = value; } } public List Maplets { get { return (List)obj; } set { obj = value; } } public List/*!*/ LocalVariables { get { return (List)obj; } set { obj = value; } } ===================================================================