diff options
author | Andrew Haley <aph@redhat.com> | 2012-04-11 10:47:43 +0000 |
---|---|---|
committer | Andrew Haley <aph@gcc.gnu.org> | 2012-04-11 10:47:43 +0000 |
commit | cca4dd5983e33e31bfb559b7544428db628fd554 (patch) | |
tree | 22431b761201f7586d181a8501e813148ae881b4 /gcc/java/jcf-dump.c | |
parent | ada371011e40f98f5d03767f34bb11e3dbf53bab (diff) | |
download | gcc-cca4dd5983e33e31bfb559b7544428db628fd554.zip gcc-cca4dd5983e33e31bfb559b7544428db628fd554.tar.gz gcc-cca4dd5983e33e31bfb559b7544428db628fd554.tar.bz2 |
jcf.h (bootstrap_method): New.
2012-04-11 Andrew Haley <aph@redhat.com>
* jcf.h (bootstrap_method): New.
(BootstrapMethods): New.
(JCF): Add BootstrapMethods.
(enum cpool_tag): Add MethodHandle, MethodType, and InvokeDynamic.
* jcf-reader.c (jcf_parse_bootstrap_methods): New.
(jcf_parse_constant_pool): Handlers for MethodHandle, MethodType,
and InvokeDynamic.
(jcf_parse_bootstrap_methods): New.
* javaop.def (invokedynamic): New opcode.
* jcf-parse.c (get_constant): An unknown constant type should not
be an internal error, but a fatal one. Make it so.
* jcf-dump.c (HANDLE_BOOTSTRAP_METHODS_ATTRIBUTE): New.
(HANDLE_END_BOOTSTRAP_METHODS): New.
(print_constant): Handlers for MethodHandle, MethodType, and
InvokeDynamic.
From-SVN: r186307
Diffstat (limited to 'gcc/java/jcf-dump.c')
-rw-r--r-- | gcc/java/jcf-dump.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/gcc/java/jcf-dump.c b/gcc/java/jcf-dump.c index 0c5878c..9173ea4 100644 --- a/gcc/java/jcf-dump.c +++ b/gcc/java/jcf-dump.c @@ -430,6 +430,23 @@ utf8_equal_string (JCF *jcf, int index, const char * value) print_element_value (out, jcf, 1); \ } +#define HANDLE_BOOTSTRAP_METHODS_ATTRIBUTE() \ +{ \ + COMMON_HANDLE_ATTRIBUTE(jcf, attribute_name, attribute_length); \ + fputc ('\n', out); jcf_parse_bootstrap_methods (jcf, attribute_length); \ +} + +#define HANDLE_END_BOOTSTRAP_METHODS(NUM_METHODS) \ + { \ + int i; \ + for (i = 0; i < NUM_METHODS; i++) \ + { \ + bootstrap_method *m = &jcf->bootstrap_methods.methods[i]; \ + fprintf (out, " %d: ", i); \ + print_constant (out, jcf, m->method_ref, 1); \ + fprintf (out, "\n"); \ + } \ + } #define PROCESS_OTHER_ATTRIBUTE(JCF, INDEX, LENGTH) \ { COMMON_HANDLE_ATTRIBUTE(JCF, INDEX, LENGTH); \ @@ -898,6 +915,53 @@ print_constant (FILE *out, JCF *jcf, int index, int verbosity) fputc ('\"', out); } break; + case CONSTANT_MethodHandle: + { + int kind = JPOOL_USHORT1 (jcf, index); + if (verbosity > 0) + fprintf (out, "MethodHandle kind: %d=", kind); + switch(kind) { + case 1: + case 2: + case 3: + case 4: + if (verbosity > 0) + fprintf (out, "Fieldref: %ld=", JPOOL_USHORT2 (jcf, index)); + print_constant (out, jcf, JPOOL_USHORT2 (jcf, index), 0); + case 5: + case 6: + case 7: + case 8: + if (verbosity > 0) + fprintf (out, "Methodref: %ld=", JPOOL_USHORT2 (jcf, index)); + print_constant (out, jcf, JPOOL_USHORT2 (jcf, index), 0); + break; + case 9: + if (verbosity > 0) + fprintf (out, "InterfaceMethodref: %ld=", JPOOL_USHORT2 (jcf, index)); + print_constant (out, jcf, JPOOL_USHORT2 (jcf, index), 0); + break; + } + break; + } + case CONSTANT_MethodType: + if (verbosity > 0) + fprintf (out, "MethodType %ld: ", JPOOL_USHORT1 (jcf, index)); + print_signature (out, jcf, JPOOL_USHORT1 (jcf, index), 0); + break; + case CONSTANT_InvokeDynamic: + { + uint16 name_and_type = JPOOL_USHORT2 (jcf, index); + if (verbosity > 0) + fprintf (out, "InvokeDynamic: "); + fprintf (out, "bootstrap_method: %ld ", JPOOL_USHORT1 (jcf, index)); + if (verbosity == 2) + fprintf (out, " name_and_type: %d=<", name_and_type); + print_constant_terse (out, jcf, name_and_type, CONSTANT_NameAndType); + if (verbosity == 2) + fputc ('>', out); + break; + } default: fprintf (out, "(Unknown constant type %d)", kind); } |