public override Unit VisitWhileExpression(WhileExpressionAST whileExpression) { ILGenerator il = code.Method.GetILGenerator(); //declaracion de las etiquetas de salto Label evaluarCond = il.DefineLabel(); Label bodyInstr = il.DefineLabel(); //---> Label loopAboveEnd = code.EndCurrentLoop; code.EndCurrentLoop = il.DefineLabel(); //salto a la comparacion il.Emit(OpCodes.Br, evaluarCond); //body il.MarkLabel(bodyInstr); code.PushOnStack = false; whileExpression.BodyExpressions.Accept(this); //condicion il.MarkLabel(evaluarCond); code.PushOnStack = true; whileExpression.ExpressionConditional.Accept(this); il.Emit(OpCodes.Brtrue, bodyInstr); //lo que viene detras del while. il.MarkLabel(code.EndCurrentLoop); //<--- reponiendo la marca del posible ciclo sobre mi. code.EndCurrentLoop = loopAboveEnd; return(Unit.Create()); }
public override bool VisitWhileExpression(WhileExpressionAST whileExpression) { var other = _other as WhileExpressionAST; if (other == null) { return(false); } return(IsEqualNodes(other.ExpressionConditional, whileExpression.ExpressionConditional) && IsEqualNodes(other.BodyExpressions, whileExpression.BodyExpressions)); }
public override bool VisitWhileExpression(WhileExpressionAST whileExpression) { whileExpression.ExpressionConditional.Accept(this); whileExpression.ReturnType = TigerType.GetType <ErrorType>(); if (whileExpression.ExpressionConditional.ReturnType != TigerType.GetType <IntType>()) { _errorListener.Add(new AnalysisError(AnalysisError.LoadMessage("IfCond"), whileExpression.Line, whileExpression.Columns)); } else { //guardo, si hay, el ciclo previo LoopAST prevLoop = _scope.ContainerLoop; _scope.ContainerLoop = whileExpression; if (whileExpression.BodyExpressions.Accept(this)) { //repongo el ciclo q habia _scope.ContainerLoop = prevLoop; whileExpression.ReturnType = TigerType.GetType <NoType>(); return(true); } } return(false); }
public abstract T VisitWhileExpression(WhileExpressionAST whileExpression);