this lets us chain together addition operations where possible
(sz string)
| 49 | // this lets us chain together addition |
| 50 | // operations where possible |
| 51 | func (s *sizeGen) addConstant(sz string) { |
| 52 | if !s.p.ok() { |
| 53 | return |
| 54 | } |
| 55 | |
| 56 | switch s.state { |
| 57 | case assign: |
| 58 | s.p.print("\ns = " + sz) |
| 59 | s.state = expr |
| 60 | return |
| 61 | case add: |
| 62 | s.p.print("\ns += " + sz) |
| 63 | s.state = expr |
| 64 | return |
| 65 | case expr: |
| 66 | s.p.print(" + " + sz) |
| 67 | return |
| 68 | } |
| 69 | |
| 70 | panic("unknown size state") |
| 71 | } |
| 72 | |
| 73 | func (s *sizeGen) Execute(p Elem, ctx Context) error { |
| 74 | s.ctx = &ctx |