* src/cacaoh/dummy.c (package_add): New function.
[cacao.git] / src / cacaoh / dummy.c
index 4c9e6975fef527c6b236c138dae8b1c067ed597b..8cc3009322d0deb0bb4ecfd364d77884cc58c7e4 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: dummy.c 8360 2007-08-20 18:02:50Z michi $
-
 */
 
 
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "mm/memory.h"
+
+#include "native/llni.h"
+
 #include "toolbox/logging.h"
 
 #include "vm/global.h"
@@ -77,6 +79,60 @@ bool access_is_accessible_member(classinfo *referer, classinfo *declarer,
 }
 
 
+/* array **********************************************************************/
+
+java_handle_t *array_objectarray_element_get(java_handle_objectarray_t *a, int32_t index)
+{
+       java_handle_t *value;
+       int32_t        size;
+
+       if (a == NULL) {
+               log_println("array_objectarray_element_get(a=%p, index=%d): NullPointerException", a, index);
+               return NULL;
+       }
+
+       size = LLNI_array_size(a);
+
+       if ((index < 0) || (index > size)) {
+               log_println("array_objectarray_element_get(a=%p, index=%d): ArrayIndexOutOfBoundsException", a, index);
+               return NULL;
+       }
+
+       LLNI_objectarray_element_get(a, index, value);
+
+       return value;
+}
+
+void array_objectarray_element_set(java_handle_objectarray_t *a, int32_t index, java_handle_t *value)
+{
+       int32_t size;
+
+       if (a == NULL) {
+               log_println("array_objectarray_element_set(a=%p, index=%d): NullPointerException", a, index);
+               return;
+       }
+
+       size = LLNI_array_size(a);
+
+       if ((index < 0) || (index > size)) {
+               log_println("array_objectarray_element_set(a=%p, index=%d): ArrayIndexOutOfBoundsException", a, index);
+               return;
+       }
+
+       LLNI_objectarray_element_set(a, index, value);
+}
+
+int32_t array_length_get(java_handle_t *a)
+{
+       if (a == NULL) {
+               log_println("array_length_get(a=%p): NullPointerException", a);
+               return 0;
+       }
+
+       return LLNI_array_size(a);
+}
+
+
 /* asm ************************************************************************/
 
 void asm_abstractmethoderror(void)
@@ -125,16 +181,30 @@ java_handle_t *builtin_new(classinfo *c)
 
 java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass)
 {
-       abort();
+       java_objectarray_t *oa = (java_objectarray_t*) mem_alloc(
+               sizeof(java_array_t) + size * sizeof(java_object_t*));
+       java_handle_objectarray_t *h = (java_handle_objectarray_t*) LLNI_WRAP(
+               (java_object_t*) oa);
 
-       return NULL;
+       if (h != NULL) {
+               LLNI_array_size(h) = size;
+       }
+
+       return h;
 }
 
 java_handle_bytearray_t *builtin_newarray_byte(int32_t size)
 {
-       abort();
+       java_bytearray_t *ba = (java_bytearray_t*) mem_alloc(
+               sizeof(java_array_t) + size * sizeof(int8_t));
+       java_handle_bytearray_t *h = (java_handle_bytearray_t*) LLNI_WRAP(
+               (java_object_t*) ba);
 
-       return NULL;
+       if (h != NULL) {
+               LLNI_array_size(h) = size;
+       }
+       
+       return h;
 }
 
 
@@ -365,7 +435,7 @@ void finalizer_run(void *o, void *p)
 
 /* gc *************************************************************************/
 
-void gc_reference_register(java_object_t **ref)
+void gc_reference_register(java_object_t **ref, int32_t reftype)
 {
        vm_abort("gc_reference_register");
 }
@@ -412,6 +482,35 @@ void jit_invalidate_code(methodinfo *m)
 }
 
 
+/* llni ***********************************************************************/
+
+void llni_critical_start()
+{
+       vm_abort("llni_critical_start");
+}
+
+void llni_critical_end()
+{
+       vm_abort("llni_critical_end");
+}
+
+
+/* localref *******************************************************************/
+
+java_handle_t *localref_add(java_object_t *o)
+{
+#if defined(ENABLE_HANDLES)
+       java_handle_t *h = (java_handle_t*) mem_alloc(sizeof(java_handle_t));
+
+       h->heap_object = o;
+
+       return h;
+#else
+       return (java_handle_t*) o;
+#endif
+}
+
+
 /* lock ***********************************************************************/
 
 void lock_init_object_lock(java_object_t *o)
@@ -474,8 +573,22 @@ int32_t dump_size(void)
 }
 
 
+/* package ********************************************************************/
+
+/* void package_add(java_handle_t *packagename) */
+void package_add(utf *packagename)
+{
+       /* Do nothing. */
+}
+
+
 /* primitive ******************************************************************/
 
+classinfo *primitive_arrayclass_get_by_type(int type)
+{
+       return NULL;
+}
+
 classinfo *primitive_class_get_by_type(int type)
 {
        abort();
@@ -615,11 +728,11 @@ intptr_t threads_get_current_tid(void)
        return 0;
 }
 
-void threads_stopworld(void)
+void threads_cast_stopworld(void)
 {
 }
 
-void threads_startworld(void)
+void threads_cast_startworld(void)
 {
 }