From: bdemsky Date: Sun, 3 Apr 2011 03:56:30 +0000 (+0000) Subject: add enwmethos X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2da2e8a0d925dea49a705a088ac917687b1ae4c1;p=IRC.git add enwmethos --- diff --git a/Robust/src/Runtime/runtime.c b/Robust/src/Runtime/runtime.c index 8dabb783..a47d9cd0 100644 --- a/Robust/src/Runtime/runtime.c +++ b/Robust/src/Runtime/runtime.c @@ -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___)+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) { diff --git a/Robust/src/Runtime/runtime.h b/Robust/src/Runtime/runtime.h index 18bf17de..e3d75f56 100644 --- a/Robust/src/Runtime/runtime.h +++ b/Robust/src/Runtime/runtime.h @@ -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