Code to generate libcore's Dalvik opcode code.

That was a mouthful.

Change-Id: I49152fdacbfa9593e7a95f5c120fea023b06d03b
diff --git a/opcode-gen/opcode-gen b/opcode-gen/opcode-gen
index 17560d1..8a99134 100755
--- a/opcode-gen/opcode-gen
+++ b/opcode-gen/opcode-gen
@@ -138,6 +138,28 @@
     next;
 }
 
+/BEGIN\(libcore-opcodes\)/ {
+    consumeUntil = "END(libcore-opcodes)";
+    print;
+
+    for (i = 0; i <= MAX_LIBDEX_OPCODE; i++) {
+        if (isUnusedByte(i) || isOptimized(i)) continue;
+        printf("    int OP_%-28s = 0x%02x;\n", constName[i], i);
+    }
+
+    next;
+}
+
+/BEGIN\(libcore-maximum-value\)/ {
+    consumeUntil = "END(libcore-maximum-value)";
+    print;
+
+    # TODO: Make this smarter.
+    printf("        MAXIMUM_VALUE = %d;\n", MAX_LIBDEX_OPCODE);
+
+    next;
+}
+
 /BEGIN\(libdex-opcode-enum\)/ {
     consumeUntil = "END(libdex-opcode-enum)";
     print;
diff --git a/opcode-gen/regen-all b/opcode-gen/regen-all
index 276893e..fbf8359 100755
--- a/opcode-gen/regen-all
+++ b/opcode-gen/regen-all
@@ -40,3 +40,10 @@
 ${progdir}/opcode-gen libdex/InstrUtils.c
 ${progdir}/opcode-gen libdex/OpCode.h
 ${progdir}/opcode-gen libdex/OpCodeNames.c
+
+# It's a minor shame that these files live in a different top-level project.
+# So it goes.
+${progdir}/opcode-gen \
+    ../libcore/dalvik/src/main/java/dalvik/bytecode/OpcodeInfo.java
+${progdir}/opcode-gen \
+    ../libcore/dalvik/src/main/java/dalvik/bytecode/Opcodes.java