/* src/vm/string.c - java.lang.String related functions
- Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
- C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
- E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
- J. Wenninger, Institut f. Computersprachen - TU Wien
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
#include <assert.h>
+#include "vmcore/system.h"
+
#include "vm/types.h"
#include "vm/global.h"
bool string_init(void)
{
+ TRACESUBSYSTEMINITIALIZATION("string_init");
+
/* create string (javastring) hashtable */
hashtable_create(&hashtable_string, HASHTABLE_STRING_SIZE);
s4 nbytes;
s4 len;
- assert(text);
+ if (text == NULL)
+ return NULL;
/* Get number of bytes. We need this to completely emulate the messy */
/* behaviour of the RI. :( */
return utf_null;
LLNI_field_get_ref(s, value, value);
+
+ if (value == NULL)
+ return utf_null;
+
LLNI_field_get_val(s, count, count);
LLNI_field_get_val(s, offset, offset);
*******************************************************************************/
+#if 0
+/* TWISTI This one is currently not used. */
+
static void literalstring_free(java_object_t* string)
{
heapstring_t *s;
/* dispose memory of java-characterarray */
FREE(a, sizeof(java_chararray_t) + sizeof(u2) * (a->header.size - 1)); /* +10 ?? */
}
+#endif
/* javastring_intern ***********************************************************
}
-/* javastring_print ************************************************************
+/* javastring_fprint ***********************************************************
- Print the given Java string.
+ Print the given Java string to the given stream.
*******************************************************************************/
-void javastring_print(java_handle_t *s)
+void javastring_fprint(java_handle_t *s, FILE *stream)
{
java_lang_String *so;
java_handle_chararray_t *value;
for (i = offset; i < offset + count; i++) {
c = LLNI_array_direct(value, i);
- putchar(c);
+ fputc(c, stream);
}
}