MCPcopy Index your code
hub / github.com/clojure/clojure / fromString

Method fromString

src/jvm/clojure/asm/TypePath.java:119–154  ·  view source on GitHub ↗

Converts a type path in string form, in the format used by #toString(), into a TypePath object. @param typePath a type path in string form, in the format used by #toString(). May be null or empty. @return the corresponding TypePath object, or null if the path i

(final String typePath)

Source from the content-addressed store, hash-verified

117 * @return the corresponding TypePath object, or <tt>null</tt> if the path is empty.
118 */
119 public static TypePath fromString(final String typePath) {
120 if (typePath == null || typePath.length() == 0) {
121 return null;
122 }
123 int typePathLength = typePath.length();
124 ByteVector output = new ByteVector(typePathLength);
125 output.putByte(0);
126 int typePathIndex = 0;
127 while (typePathIndex < typePathLength) {
128 char c = typePath.charAt(typePathIndex++);
129 if (c == '[') {
130 output.put11(ARRAY_ELEMENT, 0);
131 } else if (c == '.') {
132 output.put11(INNER_TYPE, 0);
133 } else if (c == '*') {
134 output.put11(WILDCARD_BOUND, 0);
135 } else if (c >= '0' && c <= '9') {
136 int typeArg = c - '0';
137 while (typePathIndex < typePathLength) {
138 c = typePath.charAt(typePathIndex++);
139 if (c >= '0' && c <= '9') {
140 typeArg = typeArg * 10 + c - '0';
141 } else if (c == ';') {
142 break;
143 } else {
144 throw new IllegalArgumentException();
145 }
146 }
147 output.put11(TYPE_ARGUMENT, typeArg);
148 } else {
149 throw new IllegalArgumentException();
150 }
151 }
152 output.data[0] = (byte) (output.length / 2);
153 return new TypePath(output.data, 0);
154 }
155
156 /**
157 * Returns a string representation of this type path. {@link #ARRAY_ELEMENT} steps are represented

Callers

nothing calls this directly

Calls 3

putByteMethod · 0.95
put11Method · 0.95
lengthMethod · 0.65

Tested by

no test coverage detected