Every line of 'golang for loop' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.
1584 func _loop(b ...ast.Stmt) *ast.ForStmt { 1585 return _for(nil, nil, nil, b...) 1586 }
214 func loop(suffix string, i, m GP, lookup, offset Register, vsf vectorShuffle) { 215 increment := "increment" + suffix 216 condition := "condition" + suffix 217 done := "done" + suffix 218 219 JMP(LabelRef(condition)) 220 221 // increment 222 Label(increment) 223 vsf.incr(i) 224 225 // condition 226 Label(condition) 227 vsf.cond(i, LabelRef(done)) 228 229 // body 230 vsf.body(m, i, lookup, offset, LabelRef(increment)) 231 232 // done 233 Label(done) 234 }
444 func (p *parser) For() Node { 445 pos := p.curt.Pos 446 lstart := p.nextLabel() 447 lend := p.nextLabel() 448 var init, cond, step Expr 449 p.expect(cpp.FOR) 450 p.expect('(') 451 if p.curt.Kind != ';' { 452 init = p.Expr() 453 } 454 p.expect(';') 455 if p.curt.Kind != ';' { 456 cond = p.Expr() 457 } 458 p.expect(';') 459 if p.curt.Kind != ')' { 460 step = p.Expr() 461 } 462 p.expect(')') 463 p.pushBreakCont(lend, lstart) 464 body := p.Stmt() 465 p.popBreakCont() 466 return &For{ 467 Pos: pos, 468 Init: init, 469 Cond: cond, 470 Step: step, 471 Body: body, 472 LStart: lstart, 473 LEnd: lend, 474 } 475 }
522 func (v *Dumper) StmtForeach(n *ast.StmtForeach) { 523 v.print(0, "&ast.StmtForeach{\n") 524 v.indent++ 525 526 v.dumpPosition(n.Position) 527 v.dumpToken("ForeachTkn", n.ForeachTkn) 528 v.dumpToken("OpenParenthesisTkn", n.OpenParenthesisTkn) 529 v.dumpVertex("Expr", n.Expr) 530 v.dumpToken("AsTkn", n.AsTkn) 531 v.dumpVertex("Key", n.Key) 532 v.dumpToken("DoubleArrowTkn", n.DoubleArrowTkn) 533 v.dumpToken("AmpersandTkn", n.AmpersandTkn) 534 v.dumpVertex("Var", n.Var) 535 v.dumpToken("CloseParenthesisTkn", n.CloseParenthesisTkn) 536 v.dumpToken("ColonTkn", n.ColonTkn) 537 v.dumpVertex("Stmt", n.Stmt) 538 v.dumpToken("EndForeachTkn", n.EndForeachTkn) 539 v.dumpToken("SemiColonTkn", n.SemiColonTkn) 540 541 v.indent-- 542 v.print(v.indent, "},\n") 543 }
1898 func (p *Parser) forClause(s *Stmt) { 1899 fc := &ForClause{ForPos: p.pos} 1900 p.next() 1901 fc.Loop = p.loop(fc.ForPos) 1902 1903 start, end := "do", "done" 1904 if pos, ok := p.gotRsrv("{"); ok { 1905 if p.lang == LangPOSIX { 1906 p.langErr(pos, "for loops with braces", LangBash, LangMirBSDKorn) 1907 } 1908 fc.DoPos = pos 1909 fc.Braces = true 1910 start, end = "{", "}" 1911 } else { 1912 fc.DoPos = p.followRsrv(fc.ForPos, "for foo [in words]", start) 1913 } 1914 1915 s.Comments = append(s.Comments, p.accComs...) 1916 p.accComs = nil 1917 fc.Do, fc.DoLast = p.followStmts(start, fc.DoPos, end) 1918 fc.DonePos = p.stmtEnd(fc, "for", end) 1919 s.Cmd = fc 1920 }
149 func (p *parser) for_() Statement { 150 pos := p.pos 151 p.expect(FOR) 152 name := p.val 153 p.expect(NAME) 154 p.expect(IN) 155 iterable := p.expression() 156 body := p.block() 157 return &For{pos, name, iterable, body} 158 }
1196 func do_FOR_ITER(vm *Vm, delta int32) error { 1197 r, finished := py.Next(vm.TOP()) 1198 if finished != nil { 1199 vm.DROP() 1200 vm.frame.Lasti += delta 1201 } else { 1202 vm.PUSH(r) 1203 } 1204 return nil 1205 }
128 func LoopIndirect(vValue reflect.Value) reflect.Value { 129 for vValue.Kind() == reflect.Ptr { 130 vValue = vValue.Elem() 131 } 132 return vValue 133 }
381 func (self *_parser) parseFor(idx file.Idx, initializer ast.Expression) *ast.ForStatement { 382 383 // Already have consumed " ;" 384 385 var test, update ast.Expression 386 387 if self.token != token.SEMICOLON { 388 test = self.parseExpression() 389 } 390 self.expect(token.SEMICOLON) 391 392 if self.token != token.RIGHT_PARENTHESIS { 393 update = self.parseExpression() 394 } 395 self.expect(token.RIGHT_PARENTHESIS) 396 397 return &ast.ForStatement{ 398 For: idx, 399 Initializer: initializer, 400 Test: test, 401 Update: update, 402 Body: self.parseIterationStatement(), 403 } 404 }
532 func (v *SequenceDiagramVisitor) visitLoopN(e *StatementElement, i int, c *sysl.LoopN) error { 533 return v.visitGroupStmt(e, c.GetStmt(), e.isLastStmt(i), "loop %d times\n", c.GetCount()) 534 }