(n ast.Node, inType, outType types.Type)
| 590 | } |
| 591 | |
| 592 | func (c *codegen) emitConversion(n ast.Node, inType, outType types.Type) error { |
| 593 | glog.V(2).Infof("Conversion: %q to %q", inType, outType) |
| 594 | switch { |
| 595 | case types.Equals(types.Int, inType) && types.Equals(types.Float, outType): |
| 596 | c.emit(n, code.I2f, nil) |
| 597 | case types.Equals(types.String, inType) && types.Equals(types.Float, outType): |
| 598 | c.emit(n, code.S2f, nil) |
| 599 | case types.Equals(types.String, inType) && types.Equals(types.Int, outType): |
| 600 | c.emit(n, code.S2i, nil) |
| 601 | case types.Equals(types.Float, inType) && types.Equals(types.String, outType): |
| 602 | c.emit(n, code.F2s, nil) |
| 603 | case types.Equals(types.Int, inType) && types.Equals(types.String, outType): |
| 604 | c.emit(n, code.I2s, nil) |
| 605 | case types.Equals(types.Pattern, inType) && types.Equals(types.Bool, outType): |
| 606 | // nothing, pattern is implicit bool |
| 607 | case types.Equals(inType, outType): |
| 608 | // Nothing; no-op. |
| 609 | default: |
| 610 | return errors.Errorf("can't convert %q to %q", inType, outType) |
| 611 | } |
| 612 | return nil |
| 613 | } |
| 614 | |
| 615 | func (c *codegen) writeJumps() { |
| 616 | for j, i := range c.obj.Program { |
no test coverage detected