mirror of
https://github.com/corda/corda.git
synced 2025-01-27 14:49:35 +00:00
sketch of resolveField() and resolveMethod() implementations
This commit is contained in:
parent
5e225c94a3
commit
ef48f14839
70
src/vm.cpp
70
src/vm.cpp
@ -527,6 +527,76 @@ isSpecialMethod(Thread* t, object method, object class_)
|
||||
and isSuperclass(t, methodClass(t, method), class_);
|
||||
}
|
||||
|
||||
object
|
||||
findField(Thread* t, object class_, object reference)
|
||||
{
|
||||
object table = classFieldTable(t, class_);
|
||||
object name = referenceName(t, reference);
|
||||
for (unsigned i = 0; i < rawArrayLength(t, table); ++i) {
|
||||
object fieldName = fieldName(t, rawArrayBody(t, table)[i]);
|
||||
if (strcmp(reinterpret_cast<char*>(byteArrayBody(t, fieldName)),
|
||||
reinterpret_cast<char*>(byteArrayBody(t, name))) == 0)
|
||||
{
|
||||
#error compare specs
|
||||
return rawArrayBody(t, table)[i];
|
||||
}
|
||||
}
|
||||
#error make message
|
||||
t->exception = makeNoSuchFieldError(t, message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
object
|
||||
findMethod(Thread* t, object class_, object reference)
|
||||
{
|
||||
object table = classMethodTable(t, class_);
|
||||
object name = referenceName(t, reference);
|
||||
for (unsigned i = 0; i < rawArrayLength(t, table); ++i) {
|
||||
object methodName = methodName(t, rawArrayBody(t, table)[i]);
|
||||
if (strcmp(reinterpret_cast<char*>(byteArrayBody(t, methodName)),
|
||||
reinterpret_cast<char*>(byteArrayBody(t, name))) == 0)
|
||||
{
|
||||
#error compare specs
|
||||
return rawArrayBody(t, table)[i];
|
||||
}
|
||||
}
|
||||
#error make message
|
||||
t->exception = makeNoSuchMethodError(t, message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline object
|
||||
resolve(Thread* t, object pool, unsigned index,
|
||||
object (find*)(Thread*, object, object))
|
||||
{
|
||||
object o = rawArrayBody(t, pool)[index];
|
||||
if (typeOf(o) == ReferenceType) {
|
||||
PROTECT(pool);
|
||||
|
||||
object class_ = resolveClass(t, referenceClass(t, o));
|
||||
if (UNLIKELY(t->exception)) return 0;
|
||||
|
||||
o = find(t, class_, rawArrayBody(t, pool)[index]);
|
||||
if (UNLIKELY(t->exception)) return 0;
|
||||
|
||||
return set(t, rawArrayBody(t, pool)[index], o);
|
||||
} else {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
inline object
|
||||
resolveField(Thread* t, object pool, unsigned index)
|
||||
{
|
||||
return resolve(t, pool, index, findField);
|
||||
}
|
||||
|
||||
inline object
|
||||
resolveMethod(Thread* t, object pool, unsigned index)
|
||||
{
|
||||
return resolve(t, pool, index, findMethod);
|
||||
}
|
||||
|
||||
object
|
||||
run(Thread* t)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user