add enwmethos
authorbdemsky <bdemsky>
Sun, 3 Apr 2011 03:56:30 +0000 (03:56 +0000)
committerbdemsky <bdemsky>
Sun, 3 Apr 2011 03:56:30 +0000 (03:56 +0000)
Robust/src/Runtime/runtime.c
Robust/src/Runtime/runtime.h

index 8dabb7839ca5c75bffb79c1d15b8c8a1810cb700..a47d9cd0b8ca38b8e2478aa38dc31e3939482a8f 100644 (file)
@@ -824,6 +824,32 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarray(int type, int len
 #endif
 #endif
 
+/* Converts C character arrays into Java strings */
+#ifdef PRECISE_GC
+__attribute__((malloc)) struct ___String___ * NewStringShort(void * ptr, const short *str,int length) {
+#else
+__attribute__((malloc)) struct ___String___ * NewStringShort(const short *str,int length) {
+#endif
+  int i;
+#ifdef PRECISE_GC
+  struct ArrayObject * chararray=allocate_newarray((struct garbagelist *)ptr, CHARARRAYTYPE, length);
+  INTPTR ptrarray[]={1, (INTPTR) ptr, (INTPTR) chararray};
+  struct ___String___ * strobj=allocate_new((struct garbagelist *) &ptrarray, STRINGTYPE);
+  chararray=(struct ArrayObject *) ptrarray[2];
+#else
+  struct ArrayObject * chararray=allocate_newarray(CHARARRAYTYPE, length);
+  struct ___String___ * strobj=allocate_new(STRINGTYPE);
+#endif
+  strobj->___value___=chararray;
+  strobj->___count___=length;
+  strobj->___offset___=0;
+
+  for(i=0; i<length; i++) {
+    ((short *)(((char *)&chararray->___length___)+sizeof(int)))[i]=str[i];
+  }
+  return strobj;
+}
+
 /* Converts C character arrays into Java strings */
 #ifdef PRECISE_GC
 __attribute__((malloc)) struct ___String___ * NewString(void * ptr, const char *str,int length) {
index 18bf17de3a24a8c7c73285e82260b83cd0e57a04..e3d75f5699bad10862d8a590f70838b08aeb0dad 100644 (file)
@@ -80,16 +80,19 @@ __attribute__((malloc)) void * allocate_new(void *, int type);
 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length);
 #endif
 __attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length);
+__attribute__((malloc)) struct ___String___ * NewStringShort(void *, const short *str,int length);
 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
 #elif defined MULTICORE_GC
 __attribute__((malloc)) void * allocate_new(void *, int type);
 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length);
 __attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length);
+__attribute__((malloc)) struct ___String___ * NewStringShort(void *, const short *str,int length);
 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
 #else
 __attribute__((malloc)) void * allocate_new(int type);
 __attribute__((malloc)) struct ArrayObject * allocate_newarray(int type, int length);
 __attribute__((malloc)) struct ___String___ * NewString(const char *str,int length);
+__attribute__((malloc)) struct ___String___ * NewStringShort(const short *str,int length);
 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(int index);
 #endif