Format the name and signature of a named declaration in a nice fashion for writing to the log file. @param d @return
(Decl.Named<?> d)
| 704 | * @return |
| 705 | */ |
| 706 | private static String toNameString(Decl.Named<?> d) { |
| 707 | String kind; |
| 708 | String rest; |
| 709 | if(d instanceof Decl.Function) { |
| 710 | Type.Callable t = ((Decl.Function)d).getType(); |
| 711 | kind = "function"; |
| 712 | rest = d.getQualifiedName().toString() + t.getParameter() + "->" + t.getReturn(); |
| 713 | } else if(d instanceof Decl.Method) { |
| 714 | Decl.Method m = (Decl.Method) d; |
| 715 | Type.Method t = m.getType(); |
| 716 | // FIXME: this needs to be improved! |
| 717 | kind = "method"; |
| 718 | rest = m.getQualifiedName() + toMethodParametersString(m.getTemplate()) + t.getParameter() + "->" + t.getReturn(); |
| 719 | |
| 720 | } else if(d instanceof Decl.Type) { |
| 721 | kind = "type"; |
| 722 | rest = ((Decl.Type)d).getQualifiedName().toString(); |
| 723 | } else { |
| 724 | throw new RuntimeException("unknown declaration encountered: " + d); |
| 725 | } |
| 726 | // Remove all whitespace |
| 727 | rest = rest.replace(" ", "_"); |
| 728 | // |
| 729 | return kind + " " + rest; |
| 730 | } |
| 731 | |
| 732 | private static String toNameString(Decl.Named<?> d, Tuple<Type> parameters) { |
| 733 | String name = toNameString(d); |
no test coverage detected