diff options
Diffstat (limited to 'mk2rbc/node.go')
| -rw-r--r-- | mk2rbc/node.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mk2rbc/node.go b/mk2rbc/node.go index 9d5af91c4..c0c4c98e8 100644 --- a/mk2rbc/node.go +++ b/mk2rbc/node.go @@ -294,3 +294,28 @@ func (ssw *switchNode) emit(gctx *generationContext) { ssCase.emit(gctx) } } + +type foreachNode struct { + varName string + list starlarkExpr + actions []starlarkNode +} + +func (f *foreachNode) emit(gctx *generationContext) { + gctx.newLine() + gctx.writef("for %s in ", f.varName) + f.list.emit(gctx) + gctx.write(":") + gctx.indentLevel++ + hasStatements := false + for _, a := range f.actions { + if _, ok := a.(*commentNode); !ok { + hasStatements = true + } + a.emit(gctx) + } + if !hasStatements { + gctx.emitPass() + } + gctx.indentLevel-- +} |