1 // This filter appends simplified type information to the (possibly already
2 // existing) extra-label line.
3 // If the phase type is available, show it. If the bottom type is available and
4 // differs from the bottom type, show it too (prefixed with 'B:').
5
6 // Simplify a reference type of the form
7 // "[5:]my/package/Class (package1/Class1,package2/Class2,..)"
8 // into
9 // "[5:]Class"
10 function simplify_reference_type(type) {
11 // Clean up interface lists in reference types.
12 var m = /(.*)\(.*\)(.*)/.exec(type);
13 if (m != null && typeof m[1] != 'undefined' && typeof m[2] != 'undefined') {
14 type = m[1] + m[2];
15 }
16 // Remove package name in reference types.
17 var m2 = /(\d+:)?.*\/(.*)/.exec(type);
18 if (m2 != null && typeof m2[2] != 'undefined') {
19 type = (typeof m2[1] != 'undefined' ? m2[1] : "") + m2[2];
20 }
21 return type;
22 }
23
24 // Remove fixed input types for calls and simplify references.
25 function simplifyType(type) {
26 var callTypeStart = "{0:control, 1:abIO, 2:memory, 3:rawptr:BotPTR, 4:return_address";
27 if (type.startsWith(callTypeStart)) {
28 // Exclude types of the first five outputs of call-like nodes.
29 type = type.replace(callTypeStart, "").replace("}", "");
30 prefix = ", ";
31 if (type.startsWith(prefix)) {
32 type = type.slice(prefix.length);
33 }
34 components = type.split(", ");
35 for (i = 0; i < components.length; i++) {
36 components[i] = simplify_reference_type(components[i]);
37 }
38 type = "{" + components.join(", ") + "}";
39 } else {
40 type = simplify_reference_type(type);
41 }
42 type = type.replace(">=", "≥").replace("<=", "≤");
43 return type;
44 }
45
46 // Merge a possibly existing extra label, bottom type, and phase type into a
47 // new, single extra label. For memory nodes, add an extra label with the memory
48 // slice, extracted from the dump_spec field.
49 function mergeAndAppendTypeInfo(extra_label, bottom_type, phase_type, category, dump_spec) {
50 new_extra_label = extra_label == null ? "" : (extra_label + " ");
51 if (category == "memory") {
52 m = /idx=([^\s]+);/.exec(dump_spec);
53 if (m != null) {
54 return new_extra_label + "mem: " + m[1];
55 }
56 }
57 if (phase_type == null && bottom_type == null) {
58 return extra_label;
59 }
60 type = "";
61 // Always show phase type, if available.
62 if (phase_type != null) {
|
1 // This filter appends simplified type information to the (possibly already
2 // existing) extra-label line.
3 // If the phase type is available, show it. If the bottom type is available and
4 // differs from the bottom type, show it too (prefixed with 'B:').
5
6 // Simplify a reference type of the form
7 // "[5:]my/package/Class (package1/Class1,package2/Class2,..)"
8 // into
9 // "[5:]Class"
10 function simplify_reference_type(type) {
11 // Clean up interface lists in reference types.
12 var m = /(.*) \([^\)]*\)(.*)/.exec(type);
13 if (m != null && typeof m[1] != 'undefined' && typeof m[2] != 'undefined') {
14 type = m[1] + m[2];
15 }
16 // Remove package name in reference types.
17 var m2 = /(\d+:)?.*\/(.*)/.exec(type);
18 if (m2 != null && typeof m2[2] != 'undefined') {
19 type = (typeof m2[1] != 'undefined' ? m2[1] : "") + m2[2];
20 }
21 return type;
22 }
23
24 // Remove fixed input types for calls and simplify references.
25 function simplifyType(type) {
26 var original_type = type;
27 var callTypeStart = "{0:control, 1:abIO, 2:memory, 3:rawptr:BotPTR, 4:return_address";
28 if (type.startsWith(callTypeStart)) {
29 // Exclude types of the first five outputs of call-like nodes.
30 type = type.replace(callTypeStart, "").replace("}", "");
31 prefix = ", ";
32 if (type.startsWith(prefix)) {
33 type = type.slice(prefix.length);
34 }
35 components = type.split(", ");
36 for (i = 0; i < components.length; i++) {
37 components[i] = simplify_reference_type(components[i]);
38 }
39 type = "{" + components.join(", ") + "}";
40 } else {
41 type = simplify_reference_type(type);
42 }
43 type = type.replace(">=", "≥").replace("<=", "≤");
44 if (original_type.indexOf("(flat in array)") !== -1) {
45 // Always append "flat in array" property last if found in original type.
46 type += " (flat in array)";
47 }
48 return type;
49 }
50
51 // Merge a possibly existing extra label, bottom type, and phase type into a
52 // new, single extra label. For memory nodes, add an extra label with the memory
53 // slice, extracted from the dump_spec field.
54 function mergeAndAppendTypeInfo(extra_label, bottom_type, phase_type, category, dump_spec) {
55 new_extra_label = extra_label == null ? "" : (extra_label + " ");
56 if (category == "memory") {
57 m = /idx=([^\s]+);/.exec(dump_spec);
58 if (m != null) {
59 return new_extra_label + "mem: " + m[1];
60 }
61 }
62 if (phase_type == null && bottom_type == null) {
63 return extra_label;
64 }
65 type = "";
66 // Always show phase type, if available.
67 if (phase_type != null) {
|