public object VisitWhileStatement(WhileStatementAst whileStatementAst) { var newCondition = VisitElement(whileStatementAst.Condition); var newBody = VisitElement(whileStatementAst.Body); return(new WhileStatementAst(whileStatementAst.Extent, whileStatementAst.Label, newCondition, newBody)); }
public virtual StatementAst VisitWhileStatement(WhileStatementAst whileStatementAst) { return(new WhileStatementAst( whileStatementAst.Extent, whileStatementAst.Label, whileStatementAst.Condition?.Rewrite(this, SyntaxKind.Pipeline), whileStatementAst.Body?.Rewrite(this, SyntaxKind.StatementBlock))); }
public void ProcessWhileStatement(WhileStatementAst whileStatement) { Guard.Against.Null(whileStatement, nameof(whileStatement)); var conditionType = ProcessExpression(whileStatement.ConditionExpression); if (!(conditionType == DataType.Bool || conditionType == DataType.Double || conditionType == DataType.Long)) { throw new SemanticException( $"While condition should be of bool, double or long type. Provided: {conditionType}"); } var doneLabel = new Instruction("nop"); var startLabel = new Instruction("nop"); if (CodeGenerationEnabled) { CurrentFunction.Builder.Bucket.Add(startLabel); } // cond-expr if (CodeGenerationEnabled) { CurrentFunction.Builder.Bucket.AddRange(ExpressionBucket.Pop()); } // jump(if false) to done if (CodeGenerationEnabled) { CurrentFunction.Builder.Bucket.Add(new object[] { "br.false", doneLabel }); } // # while-block EnterWhileDefination(new Builders.WhileBuilder(CurrentWhile, startLabel, doneLabel)); ProcessBlockStatement(whileStatement.WhileBlock); LeaveWhileDefination(); // jmp .START if (CodeGenerationEnabled) { CurrentFunction.Builder.Bucket.Add(Instruction.Pack("br", startLabel)); } // .DONE:nop if (CodeGenerationEnabled) { CurrentFunction.Builder.Bucket.Add(doneLabel); } }
public static WhileStatementAst Update( this WhileStatementAst ast, PipelineBaseAst condition = null, StatementBlockAst body = null, string label = null) { return(new WhileStatementAst( ast.Extent, label ?? ast.Label, condition?.Clone() ?? ast.Condition?.Clone(), body?.Clone() ?? ast.Body?.Clone())); }
public override AstVisitAction VisitWhileStatement(WhileStatementAst whileStatementAst) { explanations.Add(new Explanation() { Description = $"While '{whileStatementAst.Condition.Extent.Text}' evaluates to true, execute the code in the block {{}}.", CommandName = "While loop", HelpResult = HelpTableQuery("about_while"), TextToHighlight = "while" }.AddDefaults(whileStatementAst, explanations)); return(AstVisitAction.Continue); }
public override object VisitWhileStatement(WhileStatementAst whileStatementAst) { if (whileStatementAst.Label != null) { script_.Write(":" + whileStatementAst.Label + " "); } script_.Write("while("); VisitElement(whileStatementAst.Condition); script_.Write("){"); VisitElement(whileStatementAst.Body); script_.Write("}"); return(whileStatementAst); }
public override AstVisitAction VisitWhileStatement(WhileStatementAst whileStatementAst) { var body = VisitSyntaxNode(whileStatementAst.Body); var condition = VisitSyntaxNode(whileStatementAst.Condition); var block = body as Block; if (block == null) { block = new Block(body); } _currentNode = new While(condition, block); return(AstVisitAction.SkipChildren); }
public object VisitWhileStatement(WhileStatementAst whileStatementAst) { throw PSTraceSource.NewArgumentException("ast"); }
public override AstVisitAction VisitWhileStatement(WhileStatementAst whileStatementAst) { throw new NotImplementedException(); //VisitWhileStatement(whileStatementAst); }
public override StatementAst VisitWhileStatement(WhileStatementAst whileStatementAst) => VisitStatement(base.VisitWhileStatement(whileStatementAst));
public override AstVisitAction VisitWhileStatement(WhileStatementAst ast) { return(DoNextAction(ast)); }
object ICustomAstVisitor.VisitWhileStatement(WhileStatementAst whileStatementAst) => VisitWhileStatement(whileStatementAst);
public object VisitWhileStatement(WhileStatementAst whileStatementAst) { Console.WriteLine("Visited an WhileStatementAst."); return(whileStatementAst); }
public override AstVisitAction VisitWhileStatement(WhileStatementAst ast) { return(AstVisitAction.Continue); }
public object VisitWhileStatement(WhileStatementAst whileStatementAst) { throw new NotImplementedException(); }
public object VisitWhileStatement(WhileStatementAst whileStatementAst) { throw new UnexpectedElementException(); }
object ICustomAstVisitor.VisitWhileStatement(WhileStatementAst whileStatementAst) => ProcessRewriter(VisitWhileStatement, whileStatementAst);
/// <summary/> public virtual AstVisitAction VisitWhileStatement(WhileStatementAst whileStatementAst) => DefaultVisit(whileStatementAst);
public object VisitWhileStatement(WhileStatementAst whileStatementAst) { return(false); }
public object VisitWhileStatement(WhileStatementAst whileStatementAst) => null;
// WhileStatementAst Extension Methods // New Methods Available: // - CreateNodeFromAST(NodeDepth, NodePosition) => Creates a Node // - CreateChildNodes ($item in $collection) {} => Creates Child Nodes public static WhileNode CreateNodeFromAst(this WhileStatementAst _ast, int _depth, int _position, Node _parent, Tree _tree) { return(new WhileNode(_ast, _depth, _position, _parent, _tree)); }
public override AstVisitAction VisitWhileStatement(WhileStatementAst whileStatementAst) { Console.WriteLine("Visited an WhileStatementAst."); Console.WriteLine(" " + whileStatementAst.ToString().Replace(Environment.NewLine, Environment.NewLine + " ")); return(AstVisitAction.Continue); }
public override AstVisitAction VisitWhileStatement(WhileStatementAst whileStatementAst) { return(Visit(whileStatementAst)); }
public virtual object VisitWhileStatement(WhileStatementAst whileStatementAst) { VisitElement(whileStatementAst.Condition); VisitElement(whileStatementAst.Body); return(whileStatementAst); }
public virtual TResult VisitWhileStatement(WhileStatementAst whileStatementAst) => default(TResult);
public override AstVisitAction VisitWhileStatement(WhileStatementAst whileStatementAst) { return(AstVisitAction.SkipChildren); }
public override AstVisitAction VisitWhileStatement(WhileStatementAst ast) { return(Check(ast)); }
public static IEnumerable <Ast> GetChildAst(this WhileStatementAst _ast) { return(_ast.Body.FindAll(Args => Args is Ast && Args.Parent == _ast.Body, false)); }
public override AstVisitAction VisitWhileStatement(WhileStatementAst whileStatementAst) => VisitAst(whileStatementAst);