| 653 | } |
| 654 | |
| 655 | func (g *JavaGen) javaBasicType(T *types.Basic) string { |
| 656 | switch T.Kind() { |
| 657 | case types.Bool, types.UntypedBool: |
| 658 | return "boolean" |
| 659 | case types.Int: |
| 660 | return "long" |
| 661 | case types.Int8: |
| 662 | return "byte" |
| 663 | case types.Int16: |
| 664 | return "short" |
| 665 | case types.Int32, types.UntypedRune: // types.Rune |
| 666 | return "int" |
| 667 | case types.Int64, types.UntypedInt: |
| 668 | return "long" |
| 669 | case types.Uint8: // types.Byte |
| 670 | // TODO(crawshaw): Java bytes are signed, so this is |
| 671 | // questionable, but vital. |
| 672 | return "byte" |
| 673 | // TODO(crawshaw): case types.Uint, types.Uint16, types.Uint32, types.Uint64: |
| 674 | case types.Float32: |
| 675 | return "float" |
| 676 | case types.Float64, types.UntypedFloat: |
| 677 | return "double" |
| 678 | case types.String, types.UntypedString: |
| 679 | return "String" |
| 680 | default: |
| 681 | g.errorf("unsupported basic type: %s", T) |
| 682 | return "TODO" |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | // javaType returns a string that can be used as a Java type. |
| 687 | func (g *JavaGen) javaType(T types.Type) string { |