mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
implement instanceOf(); add interface type; etc.
This commit is contained in:
parent
86b7a75977
commit
a29dc10313
@ -5,6 +5,7 @@
|
|||||||
(object objectMask)
|
(object objectMask)
|
||||||
(object name)
|
(object name)
|
||||||
(object super)
|
(object super)
|
||||||
|
(object interfaceTable)
|
||||||
(object fieldTable)
|
(object fieldTable)
|
||||||
(object methodTable)
|
(object methodTable)
|
||||||
(object staticTable))
|
(object staticTable))
|
||||||
@ -48,6 +49,22 @@
|
|||||||
(object name)
|
(object name)
|
||||||
(object spec))
|
(object spec))
|
||||||
|
|
||||||
|
(type interface
|
||||||
|
(uint32_t id)
|
||||||
|
(object name)
|
||||||
|
(object supers)
|
||||||
|
(object methodTable)
|
||||||
|
(object staticTable))
|
||||||
|
|
||||||
|
(type pair
|
||||||
|
(object first)
|
||||||
|
(object second))
|
||||||
|
|
||||||
|
(type triple
|
||||||
|
(object first)
|
||||||
|
(object second)
|
||||||
|
(object third))
|
||||||
|
|
||||||
(type trace
|
(type trace
|
||||||
(object method)
|
(object method)
|
||||||
(uint32_t ip)
|
(uint32_t ip)
|
||||||
|
39
src/vm.cpp
39
src/vm.cpp
@ -24,7 +24,6 @@ enum ObjectType {
|
|||||||
class Thread;
|
class Thread;
|
||||||
|
|
||||||
Type typeOf(object);
|
Type typeOf(object);
|
||||||
|
|
||||||
object& objectClass(object);
|
object& objectClass(object);
|
||||||
void assert(Thread* t, bool v);
|
void assert(Thread* t, bool v);
|
||||||
|
|
||||||
@ -418,6 +417,41 @@ makeStackOverflowError(Thread* t)
|
|||||||
return makeStackOverflowError(t, 0, makeTrace(t));
|
return makeStackOverflowError(t, 0, makeTrace(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
isLongOrDouble(object o)
|
||||||
|
{
|
||||||
|
return typeOf(o) == LongType or typeOf(o) == DoubleType;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
instanceOf(Thread* t, object class_, object o)
|
||||||
|
{
|
||||||
|
if (o == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeOf(class_) == InterfaceType) {
|
||||||
|
Type id = interfaceId(t, class_);
|
||||||
|
for (object oc = objectClass(o); oc; oc = classSuper(t, oc)) {
|
||||||
|
object itable = classInterfaceTable(t, oc);
|
||||||
|
for (unsigned i = 0; i < rawArrayLength(t, itable); i += 2) {
|
||||||
|
if (interfaceId(t, rawArrayBody(t, itable)[i]) == id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Type id = classId(t, class_);
|
||||||
|
for (object oc = objectClass(o); oc; oc = classSuper(t, oc)) {
|
||||||
|
if (classId(t, oc) == id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
object
|
object
|
||||||
run(Thread* t)
|
run(Thread* t)
|
||||||
{
|
{
|
||||||
@ -1802,7 +1836,8 @@ run(Thread* t)
|
|||||||
ExceptionHandler* eh = exceptionHandlerTableBody(t, eht, i);
|
ExceptionHandler* eh = exceptionHandlerTableBody(t, eht, i);
|
||||||
uint16_t catchType = exceptionHandlerCatchType(eh);
|
uint16_t catchType = exceptionHandlerCatchType(eh);
|
||||||
if (catchType == 0 or
|
if (catchType == 0 or
|
||||||
instanceOf(rawArrayBody(t, codePool(t, code))[catchType],
|
instanceOf(t,
|
||||||
|
rawArrayBody(t, codePool(t, code))[catchType],
|
||||||
exception))
|
exception))
|
||||||
{
|
{
|
||||||
sp = frameStackBase(t, frame);
|
sp = frameStackBase(t, frame);
|
||||||
|
Loading…
Reference in New Issue
Block a user