From c70893f6874c1c1075c9c1cb54a910ffd75c55ac Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 1 Apr 2011 02:10:17 +0000 Subject: [PATCH] make hashCode a native method for java lang Object... --- Robust/src/Runtime/object.c | 12 ++++++++++++ Robust/src/Runtime/object.h | 10 ++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Robust/src/Runtime/object.c b/Robust/src/Runtime/object.c index 98183c2e..4c3c7a03 100644 --- a/Robust/src/Runtime/object.c +++ b/Robust/src/Runtime/object.c @@ -10,9 +10,21 @@ #include "thread.h" #endif +#ifdef D___Object______nativehashCode____ int CALL01(___Object______nativehashCode____, struct ___Object___ * ___this___) { return (int)((INTPTR) VAR(___this___)); } +#endif + +#ifdef D___Object______hashCode____ +int CALL01(___Object______hashCode____, struct ___Object___ * ___this___) { + if (!VAR(___this___)->___cachedHash___) { + VAR(___this___)->___cachedHash___=1; + VAR(___this___)->___cachedCode___=(int)((INTPTR)VAR(___this___)); + } + return VAR(___this___)->___cachedCode___; +} +#endif int CALL01(___Object______getType____, struct ___Object___ * ___this___) { return ((int *)VAR(___this___))[0]; diff --git a/Robust/src/Runtime/object.h b/Robust/src/Runtime/object.h index 7f4cdb15..8c177340 100644 --- a/Robust/src/Runtime/object.h +++ b/Robust/src/Runtime/object.h @@ -2,8 +2,14 @@ #define OBJECT_H #include "runtime.h" #include "structdefs.h" - -int CALL01(___Object______nativehashCode____, struct ___Object___ * ___this___); int CALL01(___Object______getType____, struct ___Object___ * ___this___); +#include "methodheaders.h" +#ifdef D___Object______nativehashCode____ +int CALL01(___Object______nativehashCode____, struct ___Object___ * ___this___); +#endif +#ifdef D___Object______hashCode____ +int CALL01(___Object______hashCode____, struct ___Object___ * ___this___); +#endif +int CALL01(___Object______getType____, struct ___Object___ * ___this___); #ifdef THREADS int CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___); int CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___); -- 2.34.1