@@ -75,131 +75,131 @@ public TruffleDetailsProvider() {
75
75
}
76
76
77
77
public String getDetailsString (String className , Instance instance ) {
78
- if (DEFAULT_CALL_TARGET_MASK .equals (className )) {
79
- String rootNode = DetailsUtils .getInstanceFieldString (instance , "rootNode" ); // NOI18N
78
+ switch (className ) {
79
+ case DEFAULT_CALL_TARGET_MASK : {
80
+ String rootNode = DetailsUtils .getInstanceFieldString (instance , "rootNode" ); // NOI18N
80
81
81
- if (rootNode != null ) {
82
- return rootNode ;
82
+ if (rootNode != null ) {
83
+ return rootNode ;
84
+ }
85
+ return DetailsUtils .getInstanceFieldString (instance , "name" ); // NOI18N
83
86
}
84
- return DetailsUtils .getInstanceFieldString (instance , "name" ); // NOI18N
85
- }
86
- if (OPTIMIZED_CALL_TARGET_MASK .equals (className )
87
- || OPTIMIZED_CALL_TARGET1_MASK .equals (className )
88
- || ENT_OPTIMIZED_CALL_TARGET_MASK .equals (className )) {
89
- String rootNode = DetailsUtils .getInstanceFieldString (instance , "rootNode" ); // NOI18N
87
+ case OPTIMIZED_CALL_TARGET_MASK :
88
+ case OPTIMIZED_CALL_TARGET1_MASK :
89
+ case ENT_OPTIMIZED_CALL_TARGET_MASK : {
90
+ String rootNode = DetailsUtils .getInstanceFieldString (instance , "rootNode" ); // NOI18N
90
91
91
- if (rootNode != null ) {
92
- Object entryPoint = instance .getValueOfField ("entryPoint" ); // NOI18N
92
+ if (rootNode != null ) {
93
+ Object entryPoint = instance .getValueOfField ("entryPoint" ); // NOI18N
93
94
94
- if (entryPoint instanceof Long && ((Long ) entryPoint ).longValue () != 0 ) {
95
- rootNode += " <opt>" ; // NOI18N
96
- }
97
- if (instance .getValueOfField ("sourceCallTarget" ) != null ) { // NOI18N
98
- rootNode += " <split-" + Long .toHexString (instance .getInstanceId ()) + ">" ; // NOI18N
95
+ if (entryPoint instanceof Long && ((Long ) entryPoint ).longValue () != 0 ) {
96
+ rootNode += " <opt>" ; // NOI18N
97
+ }
98
+ if (instance .getValueOfField ("sourceCallTarget" ) != null ) { // NOI18N
99
+ rootNode += " <split-" + Long .toHexString (instance .getInstanceId ()) + ">" ; // NOI18N
100
+ }
101
+ return rootNode ;
102
+ } else {
103
+ return DetailsUtils .getInstanceFieldString (instance , "name" ); // NOI18N
99
104
}
100
- return rootNode ;
101
- } else {
102
- return DetailsUtils .getInstanceFieldString (instance , "name" ); // NOI18N
103
105
}
104
- }
105
- if ( LANG_INFO_MASK . equals ( className ) || LANG_CACHE_MASK . equals ( className )
106
- || LANG_CACHE1_MASK . equals ( className )) {
107
- String name = DetailsUtils .getInstanceFieldString (instance , "name" ); // NOI18N
108
- String version = DetailsUtils .getInstanceFieldString (instance , "version" ); // NOI18N
106
+ case LANG_INFO_MASK :
107
+ case LANG_CACHE_MASK :
108
+ case LANG_CACHE1_MASK : {
109
+ String name = DetailsUtils .getInstanceFieldString (instance , "name" ); // NOI18N
110
+ String version = DetailsUtils .getInstanceFieldString (instance , "version" ); // NOI18N
109
111
110
- if (name != null && version != null ) {
111
- return name + " (version " + version + ")" ; // NOI18N
112
+ if (name != null && version != null ) {
113
+ return name + " (version " + version + ")" ; // NOI18N
114
+ }
115
+ return name ;
112
116
}
113
- return name ;
114
- }
115
- if (POLYGLOT_MASK .equals (className )) {
116
- return DetailsUtils .getInstanceFieldString (instance , "info" ); // NOI18N
117
- }
118
- if (INSTRUMENT_INFO_MASK .equals (className )) {
119
- String name = DetailsUtils .getInstanceFieldString (instance , "name" ); // NOI18N
120
- String version = DetailsUtils .getInstanceFieldString (instance , "version" ); // NOI18N
117
+ case POLYGLOT_MASK :
118
+ return DetailsUtils .getInstanceFieldString (instance , "info" ); // NOI18N
119
+ case INSTRUMENT_INFO_MASK : {
120
+ String name = DetailsUtils .getInstanceFieldString (instance , "name" ); // NOI18N
121
+ String version = DetailsUtils .getInstanceFieldString (instance , "version" ); // NOI18N
121
122
122
- if (name != null && !name .isEmpty () && version != null && !version .isEmpty ()) {
123
- return name + " (version " + version + ")" ; // NOI18N
124
- }
125
- if (name == null || name .isEmpty ()) {
126
- return DetailsUtils .getInstanceFieldString (instance , "id" ); // NOI18N
127
- }
128
- return name ;
129
- }
130
- if (NATIVE_ROOT_MASK .equals (className )) {
131
- return "native call" ; // NOI18N
132
- }
133
- if (NODE_MASK .equals (className )) {
134
- return DetailsUtils .getInstanceFieldString (instance , "sourceSection" );
135
- }
136
- if (TSTRING_MASK .equals (className )) {
137
- Instance next = instance ;
138
- do {
139
- String str = getString (next );
140
- if (str != null ) {
141
- return str ;
123
+ if (name != null && !name .isEmpty () && version != null && !version .isEmpty ()) {
124
+ return name + " (version " + version + ")" ; // NOI18N
142
125
}
143
- next = (Instance ) next .getValueOfField ("next" ); // NOI18N
144
- } while (next != null && !instance .equals (next ));
145
-
146
- Object data = instance .getValueOfField ("data" );
147
- if (data instanceof PrimitiveArrayInstance ) {
148
- Encoding encoding = getEncoding (instance );
149
- Byte stride = (Byte )instance .getValueOfField ("stride" ); // NOI18N
150
- if (stride != null && encoding != null ) {
151
- byte [] bytes = convertBytes ((PrimitiveArrayInstance )data , encoding .naturalStride , stride );
152
- try {
153
- if ("BYTES" .equals (encoding .name )) {
154
- return new String (bytes , "ISO-8859-1" );
155
- }
156
- return new String (bytes , encoding .name );
157
- } catch (UnsupportedEncodingException ex ) {
126
+ if (name == null || name .isEmpty ()) {
127
+ return DetailsUtils .getInstanceFieldString (instance , "id" ); // NOI18N
128
+ }
129
+ return name ;
130
+ }
131
+ case NATIVE_ROOT_MASK :
132
+ return "native call" ; // NOI18N
133
+ case NODE_MASK :
134
+ return DetailsUtils .getInstanceFieldString (instance , "sourceSection" );
135
+ case TSTRING_MASK : {
136
+ Instance next = instance ;
137
+ do {
138
+ String str = getString (next );
139
+ if (str != null ) {
140
+ return str ;
141
+ }
142
+ next = (Instance ) next .getValueOfField ("next" ); // NOI18N
143
+ } while (next != null && !instance .equals (next ));
144
+ Object data = instance .getValueOfField ("data" );
145
+ if (data instanceof PrimitiveArrayInstance ) {
146
+ Encoding encoding = getEncoding (instance );
147
+ Byte stride = (Byte )instance .getValueOfField ("stride" ); // NOI18N
148
+ if (stride != null && encoding != null ) {
149
+ byte [] bytes = convertBytes ((PrimitiveArrayInstance )data , encoding .naturalStride , stride );
158
150
try {
159
- return new String (bytes , encoding .name .replace ('_' , '-' ));
160
- } catch (UnsupportedEncodingException ex1 ) {
161
- return new String (bytes );
151
+ if ("BYTES" .equals (encoding .name )) {
152
+ return new String (bytes , "ISO-8859-1" );
153
+ }
154
+ return new String (bytes , encoding .name );
155
+ } catch (UnsupportedEncodingException ex ) {
156
+ try {
157
+ return new String (bytes , encoding .name .replace ('_' , '-' ));
158
+ } catch (UnsupportedEncodingException ex1 ) {
159
+ return new String (bytes );
160
+ }
162
161
}
163
162
}
163
+ } else {
164
+ return DetailsUtils .getInstanceString ((Instance ) data );
164
165
}
165
- } else {
166
- return DetailsUtils .getInstanceString ((Instance ) data );
166
+ break ;
167
167
}
168
- }
169
- if (TS_LONG_MASK .equals (className )) {
170
- return String .valueOf (DetailsUtils .getLongFieldValue (instance , "value" , 0 )); // NOI18N
171
- }
172
- if (TS_CONCAT_MASK .equals (className )) {
173
- Object vall = instance .getValueOfField ("left" ); // NOI18N
174
- Object valr = instance .getValueOfField ("right" ); // NOI18N
168
+ case TS_LONG_MASK :
169
+ return String .valueOf (DetailsUtils .getLongFieldValue (instance , "value" , 0 )); // NOI18N
170
+ case TS_CONCAT_MASK : {
171
+ Object vall = instance .getValueOfField ("left" ); // NOI18N
172
+ Object valr = instance .getValueOfField ("right" ); // NOI18N
173
+ String left = DetailsUtils .getInstanceString ((Instance )vall );
175
174
176
- String left = DetailsUtils .getInstanceString ((Instance )vall );
175
+ if (left == null ) {
176
+ return DetailsUtils .getInstanceString ((Instance )valr );
177
+ }
178
+ if (valr == null || left .length () > DetailsUtils .MAX_ARRAY_LENGTH ) {
179
+ return left ;
180
+ }
181
+ String value = left + DetailsUtils .getInstanceString ((Instance )valr );
177
182
178
- if (left == null ) {
179
- return DetailsUtils .getInstanceString ((Instance )valr );
180
- }
181
- if (valr == null || left .length () > DetailsUtils .MAX_ARRAY_LENGTH ) {
182
- return left ;
183
+ if (value .length () > DetailsUtils .MAX_ARRAY_LENGTH ) {
184
+ return value .substring (0 , DetailsUtils .MAX_ARRAY_LENGTH ) + "..." ; // NOI18N
185
+ }
186
+ return value ;
183
187
}
184
- String value = left + DetailsUtils . getInstanceString (( Instance ) valr );
185
-
186
- if (value . length () > DetailsUtils .MAX_ARRAY_LENGTH ) {
187
- return value . substring ( 0 , DetailsUtils . MAX_ARRAY_LENGTH ) + "..." ; // NOI18N
188
+ case LLVM_NODE_MASK : {
189
+ String name = DetailsUtils . getInstanceFieldString ( instance , "originalName" ); // NOI18N
190
+ if (name == null ) name = DetailsUtils .getInstanceFieldString ( instance , "name" ); // NOI18N
191
+ return name ;
188
192
}
189
- return value ;
190
- }
191
- if (LLVM_NODE_MASK .equals (className )) {
192
- String name = DetailsUtils .getInstanceFieldString (instance , "originalName" ); // NOI18N
193
- if (name == null ) name = DetailsUtils .getInstanceFieldString (instance , "name" ); // NOI18N
194
- return name ;
195
- }
196
- if (LLVM_FOREIGN_NODE_MASK .equals (className )) {
197
- Instance classNode = (Instance ) instance .getValueOfField ("callNode" ); // NOI18N
198
-
199
- if (classNode != null ) {
200
- String value = DetailsUtils .getInstanceFieldString (classNode , "callTarget" ); // NOI18N
201
- if (value != null ) return "LLVM: " +value ; // NOI18N
193
+ case LLVM_FOREIGN_NODE_MASK : {
194
+ Instance classNode = (Instance ) instance .getValueOfField ("callNode" ); // NOI18N
195
+ if (classNode != null ) {
196
+ String value = DetailsUtils .getInstanceFieldString (classNode , "callTarget" ); // NOI18N
197
+ if (value != null ) return "LLVM: " +value ; // NOI18N
198
+ }
199
+ break ;
202
200
}
201
+ default :
202
+ break ;
203
203
}
204
204
return null ;
205
205
}
0 commit comments