WriteFunction appends the string representation of f to the Printer's buffer.
(f *semantic.Function)
| 85 | // WriteFunction appends the string representation of f to the Printer's |
| 86 | // buffer. |
| 87 | func (p *Printer) WriteFunction(f *semantic.Function) *Printer { |
| 88 | p.WriteString("// order: ") |
| 89 | p.WriteString(f.Order.String()) |
| 90 | p.WriteString("¶") |
| 91 | switch { |
| 92 | case f.Extern: |
| 93 | p.WriteString("extern ") |
| 94 | case f.Subroutine: |
| 95 | p.WriteString("sub ") |
| 96 | default: |
| 97 | p.WriteString("cmd ") |
| 98 | } |
| 99 | p.WriteType(f.Signature.Return) |
| 100 | p.WriteRune(' ') |
| 101 | p.WriteString(f.Name()) |
| 102 | p.WriteRune('(') |
| 103 | params := f.CallParameters() |
| 104 | p.list(params, func(param *semantic.Parameter) { |
| 105 | p.WriteType(param.Type) |
| 106 | p.WriteRune(' ') |
| 107 | p.WriteString(param.Name()) |
| 108 | }) |
| 109 | p.WriteString(") ") |
| 110 | p.WriteStatement(f.Block) |
| 111 | return p |
| 112 | } |
| 113 | |
| 114 | // WriteExpression appends the string representation of n to the Printer's |
| 115 | // buffer. |