X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fbackends%2Fjvm%2Fgenerator-jvm-basic.c;h=478a92c6f38cb91acb3c03c3f939c3158023d5f3;hb=7b7ff82e330bd4c42a9987709839251c5ac69089;hp=277940ce17b58fb18f46ee630aa162c2a250c62a;hpb=55d9ee92b95dd306ac80fb643ed21d3b733395d7;p=dsw-obn.git diff --git a/src/backends/jvm/generator-jvm-basic.c b/src/backends/jvm/generator-jvm-basic.c index 277940c..478a92c 100644 --- a/src/backends/jvm/generator-jvm-basic.c +++ b/src/backends/jvm/generator-jvm-basic.c @@ -53,7 +53,7 @@ jvm_get_descriptor(oberon_type_t * type) switch(type -> class) { - case OBERON_TYPE_VOID: + case OBERON_TYPE_NOTYPE: return new_string("V"); break; case OBERON_TYPE_INTEGER: @@ -77,6 +77,9 @@ jvm_get_descriptor(oberon_type_t * type) break; } break; + case OBERON_TYPE_SYSTEM_BYTE: + return new_string("B"); + break; case OBERON_TYPE_REAL: switch(type -> size) { @@ -187,6 +190,7 @@ jvm_get_prefix(oberon_type_t * type) case OBERON_TYPE_INTEGER: case OBERON_TYPE_CHAR: case OBERON_TYPE_SET: + case OBERON_TYPE_SYSTEM_BYTE: return (size <= 4) ? ('i') : ('l'); break; case OBERON_TYPE_PROCEDURE: @@ -194,6 +198,7 @@ jvm_get_prefix(oberon_type_t * type) case OBERON_TYPE_RECORD: case OBERON_TYPE_POINTER: case OBERON_TYPE_STRING: + case OBERON_TYPE_NIL: return 'a'; break; case OBERON_TYPE_REAL: @@ -236,6 +241,9 @@ jvm_get_postfix(oberon_type_t * type) break; } break; + case OBERON_TYPE_SYSTEM_BYTE: + return 'b'; + break; case OBERON_TYPE_CHAR: switch(size) { @@ -261,6 +269,7 @@ jvm_get_postfix(oberon_type_t * type) case OBERON_TYPE_RECORD: case OBERON_TYPE_POINTER: case OBERON_TYPE_STRING: + case OBERON_TYPE_NIL: return 'a'; break; case OBERON_TYPE_REAL: @@ -274,17 +283,45 @@ jvm_get_postfix(oberon_type_t * type) return '!'; } +char * +jvm_get_name(oberon_object_t * x) +{ + switch(x -> class) + { + case OBERON_CLASS_VAR: + case OBERON_CLASS_VAR_PARAM: + case OBERON_CLASS_PARAM: + case OBERON_CLASS_FIELD: + return new_string(x -> name); + case OBERON_CLASS_PROC: + if(x -> parent) + { + return new_string("%s$%s", jvm_get_name(x -> parent), x -> name); + } + else + { + return new_string(x -> name); + } + default: + gen_error("jvm_get_name: wat"); + } + + return NULL; +} + char * jvm_get_field_full_name(oberon_object_t * x) { + char * parent; switch(x -> class) { case OBERON_CLASS_VAR: + return new_string("%s/%s", x -> module -> name, jvm_get_name(x)); case OBERON_CLASS_PROC: - return new_string("%s/%s", x -> module -> name, x -> name); - case OBERON_CLASS_FIELD:; - char * rec_name = jvm_get_class_full_name(x -> parent_type); - return new_string("%s/%s", rec_name, x -> name); + return new_string("%s/%s", x -> module -> name, jvm_get_name(x)); + case OBERON_CLASS_FIELD: + parent = jvm_get_class_full_name(x -> parent_type); + return new_string("%s/%s", parent, jvm_get_name(x)); case OBERON_CLASS_MODULE: return new_string(x -> module -> name); default: @@ -336,6 +373,7 @@ jvm_get_class_full_name(oberon_type_t * type) int num = type -> num_decl; oberon_object_t * arg = type -> decl; + for(int i = 0; i < num; i++) { desc = jvm_get_descriptor_safe(arg -> type); @@ -356,36 +394,6 @@ jvm_get_class_full_name(oberon_type_t * type) return name; } -char * -jvm_get_procedure_signature(oberon_type_t * proc) -{ - char * signature; - char * desc; - - signature = new_string("("); - - int num = proc -> num_decl; - oberon_object_t * arg = proc -> decl; - for(int i = 0; i < num; i++) - { - desc = jvm_get_descriptor(arg -> type); - if(arg -> class == OBERON_CLASS_VAR_PARAM) - { - signature = new_string("%s[%sI", signature, desc); - } - else - { - signature = new_string("%s%s", signature, desc); - } - arg = arg -> next; - } - - desc = jvm_get_descriptor(proc -> base); - signature = new_string("%s)%s", signature, desc); - - return signature; -} - int jvm_cell_size_for_type(oberon_type_t * type) { @@ -399,7 +407,7 @@ jvm_cell_size_for_type(oberon_type_t * type) return 2; } } - else if(type -> class == OBERON_TYPE_VOID) + else if(type -> class == OBERON_TYPE_NOTYPE) { return 0; }