[vmkit-commits] [vmkit] r198307 - add j3utf16.cc that I forgot. Implement JVM_IsInterface.

Gael Thomas gael.thomas at lip6.fr
Thu Jan 2 05:58:18 PST 2014


Author: gthomas
Date: Thu Jan  2 07:58:18 2014
New Revision: 198307

URL: http://llvm.org/viewvc/llvm-project?rev=198307&view=rev
Log:
add j3utf16.cc that I forgot. Implement JVM_IsInterface.

Added:
    vmkit/branches/mcjit/lib/j3/vm/j3utf16.cc
Modified:
    vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc

Modified: vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc?rev=198307&r1=198306&r2=198307&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc (original)
+++ vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc Thu Jan  2 07:58:18 2014
@@ -404,7 +404,15 @@ jobject JNICALL JVM_GetClassLoader(JNIEn
 	return res;
 }
 
-jboolean JNICALL JVM_IsInterface(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); }
+jboolean JNICALL JVM_IsInterface(JNIEnv* env, jclass cls) { 
+	jboolean res;
+	enterJVM(); 
+	J3ObjectType* type = J3ObjectType::nativeClass(cls);
+	res = type->isArrayClass() ? 0 : J3Cst::isInterface(type->asClass()->access());
+	leaveJVM(); 
+	return res;
+}
+
 jobjectArray JNICALL JVM_GetClassSigners(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); }
 void JNICALL JVM_SetClassSigners(JNIEnv* env, jclass cls, jobjectArray signers) { enterJVM(); NYI(); leaveJVM(); }
 jobject JNICALL JVM_GetProtectionDomain(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); }

Added: vmkit/branches/mcjit/lib/j3/vm/j3utf16.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3utf16.cc?rev=198307&view=auto
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3utf16.cc (added)
+++ vmkit/branches/mcjit/lib/j3/vm/j3utf16.cc Thu Jan  2 07:58:18 2014
@@ -0,0 +1,61 @@
+#include "j3/j3utf16.h"
+#include "j3/j3object.h"
+#include "j3/j3.h"
+#include "vmkit/names.h"
+
+using namespace j3;
+
+J3Utf16Converter::J3Utf16Converter(const vmkit::Name* _name) { 
+	name = _name; 
+	pos = 0; 
+}
+
+bool J3Utf16Converter::isEof() { 
+	return pos == name->length(); 
+}
+
+uint16_t J3Utf16Converter::nextUtf16() {
+	const char* str = name->cStr();
+	size_t   n = 0;
+	size_t   i = 0;
+	uint16_t x = str[pos++];
+
+	if(x & 0x80) {
+		uint16_t y = str[pos++];
+		if (x & 0x20) {
+			char z = str[pos++];
+			x = ((x & 0x0F) << 12) +
+				((y & 0x3F) << 6) +
+				(z & 0x3F);
+		} else {
+			x = ((x & 0x1F) << 6) +
+				(y & 0x3F);
+		}
+	}
+		
+	return x;
+}
+
+size_t J3CharConverter::convert(J3ObjectHandle* charArray, char* dest) {
+	size_t length = charArray->arrayLength();
+	size_t pos = 0;
+
+	for(uint32_t i=0; i<length; i++) {
+		uint16_t c = charArray->getCharAt(i);
+		if(c > 127) {
+			J3::internalError("implement me: fun char");
+		} else {
+			dest[pos++] = (char)c;
+		}
+	}
+
+	dest[pos] = 0;
+
+	return pos;
+}
+		
+size_t J3CharConverter::maxSize(J3ObjectHandle* charArray) {
+	return 1 + charArray->arrayLength() * 3;
+}
+
+





More information about the vmkit-commits mailing list