// TODO: Add vardecl to while loop? // It's pretty dumb but C++ allows it =/ protected void ExecuteWhileStmt(AstWhileStmt stmt) { if (HadErrorOrReturn()) { return; } while (!m_runtimeError) { m_blockexitk = BLOCKEXITK.Normal; object conditionVal = EvaluateExpr(stmt.m_condition); if (!IsTruthy(conditionVal)) { break; } ExecuteStmt(stmt.m_body); if (m_blockexitk == BLOCKEXITK.Break) { break; } } }
public SymbolStatusTable(SymbolStatusTable?parent, AstWhileStmt loop) { this.Parent = parent; this.mSymbolStatus = new Dictionary <ISymbol, SymbolStatus>(); this.Breakable = loop; this.Continuable = loop; }
public override NodeFinderResult VisitWhileStmt(AstWhileStmt ws, int i = 0) { if (GetRelativeLocation(ws.Body.Location, i) == RelativeLocation.Same) { return(ws.Body.Accept(this, i)); } return(new NodeFinderResult(ws.Scope, stmt: ws)); }
private AstWhileStmt AnalyseWhileStatement(AstWhileStmt whl) { whl.SubScope = new Scope("loop", whl.Scope); whl.SubScope.DefineLoop(whl); whl.Body.AttachTo(whl, whl.SubScope); InferType(whl.Body, null); return(whl); }
public override string VisitWhileStmt(AstWhileStmt wh, int indentLevel = 0) { var str = "loop "; if (wh.Label != null) { str += " #label " + wh.Label.Name; } str += wh.Body.Accept(this); return(str); }
private void GenerateWhile(AstWhileStmt whl) { var bbBody = LLVM.AppendBasicBlock(currentLLVMFunction, "_loop_body"); var bbEnd = LLVM.AppendBasicBlock(currentLLVMFunction, "_loop_end"); loopBodyMap[whl] = bbBody; breakTargetMap[whl] = bbEnd; builder.CreateBr(bbBody); builder.PositionBuilderAtEnd(bbBody); GenerateExpression(whl.Body, false); if (!whl.Body.GetFlag(ExprFlags.Returns) && !whl.Body.GetFlag(ExprFlags.Breaks)) { builder.CreateBr(bbBody); } builder.PositionBuilderAtEnd(bbEnd); }
public virtual ReturnType VisitWhileStmt(AstWhileStmt stmt, DataType data = default) => default;
protected void ResolveWhileStmt(AstWhileStmt stmt) { ResolveExpr(stmt.m_condition); ResolveStmt(stmt.m_body); }