use of com.oracle.truffle.espresso.impl.KeysArray in project graal by oracle.
the class EspressoInterop method getMembers.
@ExportMessage
@TruffleBoundary
static Object getMembers(StaticObject receiver, @SuppressWarnings("unused") boolean includeInternal) {
receiver.checkNotForeign();
if (isNull(receiver)) {
return EmptyKeysArray.INSTANCE;
}
ArrayList<String> members = new ArrayList<>();
if (receiver.getKlass() == receiver.getKlass().getMeta().java_lang_Class) {
// SVM does not like ArrayList.addAll(). Do manual copy.
for (String s : CLASS_KEYS) {
members.add(s);
}
}
ObjectKlass k = getInteropKlass(receiver);
for (Field f : k.getFieldTable()) {
if (f.isPublic() && !f.isRemoved()) {
members.add(f.getNameAsString());
}
}
for (Method.MethodVersion m : k.getVTable()) {
if (LookupVirtualMethodNode.isCandidate(m.getMethod())) {
// Note: If there are overloading, the same key may appear twice.
// TODO: Cache the keys array in the Klass.
members.add(m.getMethod().getInteropString());
}
}
// SVM does not like ArrayList.toArray(). Do manual copy.
String[] array = new String[members.size()];
int pos = 0;
for (String str : members) {
array[pos++] = str;
}
return new KeysArray(array);
}
Aggregations