MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / toNameString

Method toNameString

src/main/java/wyc/task/QuickCheck.java:706–730  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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);

Callers 4

toStringMethod · 0.80
toStringMethod · 0.80
toStringMethod · 0.80
toStringMethod · 0.80

Calls 10

getQualifiedNameMethod · 0.80
getTypeMethod · 0.65
getParameterMethod · 0.65
getReturnMethod · 0.65
replaceMethod · 0.65
sizeMethod · 0.65
toStringMethod · 0.45
getTemplateMethod · 0.45
toBareStringMethod · 0.45

Tested by

no test coverage detected