summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 36c1947)
raw | patch | inline | side by side (parent: 36c1947)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 2 Aug 2017 09:32:41 +0000 (12:32 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 2 Aug 2017 09:32:41 +0000 (12:32 +0300) |
JTest.java | [deleted file] | patch | blob | history |
src/backends/jvm/generator-jvm-basic.c | patch | blob | history | |
src/backends/jvm/generator-jvm.c | patch | blob | history | |
src/test.c | patch | blob | history |
diff --git a/JTest.java b/JTest.java
--- a/JTest.java
+++ /dev/null
@@ -1,8 +0,0 @@
-class JTest
-{
- public static JTest pointer;
-
- {
- pointer = this;
- }
-}
index aad9747f25cbf4d091e86db1f0ea9a3d098753dc..24c28b057429313018bf1529c64154c1e2a27825 100644 (file)
return NULL;
}
+char *
+jvm_get_descriptor_safe(oberon_type_t * type)
+{
+ switch(type -> class)
+ {
+ case OBERON_TYPE_POINTER:
+ return new_string("PTR%s", jvm_get_descriptor_safe(type -> base));
+ break;
+ case OBERON_TYPE_PROCEDURE:
+ case OBERON_TYPE_RECORD:
+ return jvm_get_class_full_name(type);
+ break;
+ case OBERON_TYPE_ARRAY:
+ return new_string("A%sX", jvm_get_descriptor_safe(type -> base));
+ break;
+ default:
+ return jvm_get_descriptor(type);
+ break;
+ }
+
+ return NULL;
+}
+
char
jvm_get_prefix(oberon_type_t * type)
{
name = new_string("SYSTEM$PROCEDURE");
char * desc;
- desc = jvm_get_descriptor(type -> base);
+ desc = jvm_get_descriptor_safe(type -> base);
name = new_string("%s$%s", name, desc);
int num = type -> num_decl;
oberon_object_t * arg = type -> decl;
for(int i = 0; i < num; i++)
{
- desc = jvm_get_descriptor(arg -> type);
+ desc = jvm_get_descriptor_safe(arg -> type);
name = new_string("%s%s", name, desc);
arg = arg -> next;
}
index e4c70b1c23d312e580c24f1a2d2348963548ecc1..d609ed8de96c216a30ac4ec9bceda90ec230583e 100644 (file)
fprintf(fp, ".method <init>()V\n");
fprintf(fp, " aload_0\n");
fprintf(fp, " invokespecial %s/<init>()V\n", abscname);
- fprintf(fp, " aload_0\n");
+ fprintf(fp, " return\n");
+ fprintf(fp, ".end method\n\n");
+
+ fprintf(fp, ".method static <clinit>()V\n");
+ fprintf(fp, " .limit stack 2\n");
+ fprintf(fp, " new %s\n", cname);
+ fprintf(fp, " dup\n");
+ fprintf(fp, " invokespecial %s/<init>()V\n", cname);
fprintf(fp, " putstatic %s/pointer %s\n", cname, absdesc);
fprintf(fp, " return\n");
fprintf(fp, ".end method\n\n");
jvm_generate_store(p, x -> type, x -> gen_var);
}
}
- else if(x -> class == OBERON_CLASS_PROC)
- {
- char * cname = jvm_get_field_full_name_safe(x);
- jvm_generate(p, 0, 1, "new %s", cname);
- jvm_generate(p, 1, 0, "invokespecial %s/<init>()V", cname);
- }
x = x -> next;
}
diff --git a/src/test.c b/src/test.c
index 03ac7fc3ab12979d8fcaadac8c5ccd244769f4bc..d2950b968189c70a5f4b743c5131cd9682498959 100644 (file)
--- a/src/test.c
+++ b/src/test.c
""
"TYPE"
" Ident = ARRAY 20 OF CHAR;"
+ " PrintString = PROCEDURE (str : ARRAY OF CHAR);"
""
"VAR"
" hello : Ident;"
- " cc : CHAR;"
+ " print : PrintString;"
""
"BEGIN"
+ " print := Out.String;"
" hello[0] := h;"
" hello[1] := e;"
" hello[2] := l;"
" hello[11] := bang;"
" hello[12] := null;"
" Out.Open;"
- " Out.String(hello);"
+ " print(hello);"
" Out.Ln;"
"END Test."
;