protected override void CopyAttributesToLastStatement(Statement stmt) { base.CopyAttributesToLastStatement(stmt); var cilRef = stmt.QueryAttribute <ILIndexRef>(); if (cilRef != null) { var top = _cilRefStack.Any() ? _cilRefStack.Peek() : null; cilRef = new ILIndexRef(cilRef.Method, cilRef.ILIndex) { Caller = top }; LastStatement.AddAttribute(cilRef); } }
/// <summary> /// Copies all attributes of the given statement to the last output statement. /// </summary> /// <param name="stmt">statement to copy attributes from</param> protected virtual void CopyAttributesToLastStatement(Statement stmt) { LastStatement.CopyAttributesFrom(stmt); }
public Block(List<Statement> statements, LastStatement lastStatement) { Statements = statements; LastStatement = lastStatement; }
/* Parses block * {do | while | repeat | if | for | function | local | assignOrFunctionCall} * [return | break] */ Block Block() { var statements = new List <Statement>(); LastStatement lastStatement = null; bool continueBlock = true; while (continueBlock) { switch (lexer.Current.Symbol) { case Symbol.Do: statements.Add(Do()); break; case Symbol.While: statements.Add(While()); break; case Symbol.Repeat: statements.Add(Repeat()); break; case Symbol.If: statements.Add(If()); break; case Symbol.For: statements.Add(For()); break; case Symbol.Function: statements.Add(Function()); break; case Symbol.Local: statements.Add(Local()); break; case Symbol.Identifier: case Symbol.LeftParen: statements.Add(AssignOrFunctionCall()); break; case Symbol.Return: lastStatement = Return(); continueBlock = false; break; case Symbol.Break: lastStatement = new LastStatement.Break(); continueBlock = false; break; default: continueBlock = false; break; } lexer.TryConsume(Symbol.SemiColon); } return(new Block(statements, lastStatement)); }