intitial checkin
authorcg
Tue, 16 Apr 1996 13:34:16 +0000
changeset 6 b23a6474754f
parent 5 f026f5d20c15
child 7 de8ce26e1f2c
intitial checkin
JavaDecompiler.st
JavaExceptionTableEntry.st
JavaField.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/JavaDecompiler.st	Tue Apr 16 13:34:16 1996 +0000
@@ -0,0 +1,364 @@
+Object subclass:#JavaDecompiler
+	instanceVariableNames:'code pc javaMethod'
+	classVariableNames:'DecoderTable'
+	poolDictionaries:''
+	category:'Java-Support'
+!
+
+
+!JavaDecompiler class methodsFor:'initialization'!
+
+initialize
+    DecoderTable := #(
+        (nop)                                   "/ 0
+        (aconst_null)                           "/ 1
+        (iconst_m1)                             "/ 2
+        (iconst_0)                              "/ 3
+        (iconst_1)                              "/ 4
+        (iconst_2)                              "/ 5
+        (iconst_3)                              "/ 6
+        (iconst_4)                              "/ 7
+        (iconst_5)                              "/ 8
+        (lconst_0)                              "/ 9
+        
+        (lconst_1)                              "/ 10
+        (fconst_0)                              "/ 11
+        (fconst_1)                              "/ 12
+        (fconst_2)                              "/ 13
+        (dconst_0)                              "/ 14
+        (dconst_1)                              "/ 15
+        (bipush signedByte)                     "/ 16
+        (sipush signedShort)                    "/ 17
+        (ldc1 constIndexByte)                   "/ 18
+        (ldc2 constIndexShort)                  "/ 19
+
+        (ldc2w constIndexShort)                 "/ 20
+        (iload localIndexByte)                  "/ 21
+        (lload localIndexByte)                  "/ 22
+        (fload localIndexByte)                  "/ 23
+        (dload localIndexByte)                  "/ 24
+        (aload localIndexByte)                  "/ 25
+        nil                                     "/ 26
+        (iload_1)                               "/ 27
+        (iload_2)                               "/ 28
+        (iload_3)                               "/ 29
+
+        (lload_0)                               "/ 30
+        (lload_1)                               "/ 31
+        (lload_2)                               "/ 32
+        (lload_3)                               "/ 33
+        (fload_0)                               "/ 34
+        (fload_1)                               "/ 35
+        (fload_2)                               "/ 36
+        (fload_3)                               "/ 37
+        (dload_0)                               "/ 38
+        (dload_1)                               "/ 39
+
+        (dload_2)                               "/ 40
+        (dload_3)                               "/ 41
+        (aload_0)                               "/ 42
+        (aload_1)                               "/ 43
+        (aload_2)                               "/ 44
+        (aload_3)                               "/ 45
+        (iaload)                                "/ 46
+        (laload)                                "/ 47
+        (faload)                                "/ 48
+        (daload)                                "/ 49
+
+        (aaload)                                "/ 50
+        (baload)                                "/ 51
+        (caload)                                "/ 52
+        (saload)                                "/ 53
+        (istore localIndexByte)                 "/ 54
+        (lstore localIndexByte)                 "/ 55
+        (fstore localIndexByte)                 "/ 56
+        (dstore localIndexByte)                 "/ 57
+        (astore localIndexByte)                 "/ 58
+        (istore_0)                              "/ 59
+
+        (istore_1)                              "/ 60
+        (istore_2)                              "/ 61
+        (istore_3)                              "/ 62
+        (lstore_0)                              "/ 63
+        (lstore_1)                              "/ 64
+        (lstore_2)                              "/ 65
+        (lstore_3)                              "/ 66
+        (fstore_0)                              "/ 67
+        (fstore_1)                              "/ 68
+        (fstore_2)                              "/ 69
+
+        (fstore_3)                              "/ 70
+        (dstore_0)                              "/ 71
+        (dstore_1)                              "/ 72
+        (dstore_2)                              "/ 73
+        (dstore_3)                              "/ 74
+        (astore_0)                              "/ 75
+        (astore_1)                              "/ 76
+        (astore_2)                              "/ 77
+        (astore_3)                              "/ 78
+        (iastore)                               "/ 79
+
+        (lastore)                               "/ 80
+        (fastore)                               "/ 81
+        (dastore)                               "/ 82
+        (aastore)                               "/ 83
+        (bastore)                               "/ 84
+        (castore)                               "/ 85
+        (sastore)                               "/ 86
+        (pop)                                   "/ 87
+        (pop2)                                  "/ 88
+        (dup)                                   "/ 89
+
+        (dup_x1)                                "/ 90
+        (dup_x2)                                "/ 91
+        (dup2)                                  "/ 92
+        (dup2_x1)                               "/ 93
+        (dup2_x2)                               "/ 94
+        (swap)                                  "/ 95
+        (iadd)                                  "/ 96
+        (ladd)                                  "/ 97
+        (fadd)                                  "/ 98
+        (dadd)                                  "/ 99
+
+        (isub)                                  "/ 100
+        (lsub)                                  "/ 101
+        (fsub)                                  "/ 102
+        (dsub)                                  "/ 103
+        (imul)                                  "/ 104
+        (lmul)                                  "/ 105
+        (fmul)                                  "/ 106
+        (dmul)                                  "/ 107
+        (idiv)                                  "/ 108
+        (ldiv)                                  "/ 109
+
+        (fdiv)                                  "/ 110
+        (ddiv)                                  "/ 111
+        (imod)                                  "/ 112
+        (lmod)                                  "/ 113
+        (fmod)                                  "/ 114
+        (dmod)                                  "/ 115
+        (ineg)                                  "/ 116
+        (lneg)                                  "/ 117
+        (fneg)                                  "/ 118
+        (dneg)                                  "/ 119
+
+        (ishl)                                  "/ 120
+        (lshl)                                  "/ 121
+        (ishr)                                  "/ 122
+        (lshr)                                  "/ 123
+        (iushr)                                 "/ 124
+        (lushr)                                 "/ 125
+        (iand)                                  "/ 126
+        (land)                                  "/ 127
+        (ior)                                   "/ 128
+        (lor)                                   "/ 129
+
+        (ixor)                                  "/ 130
+        (lxor)                                  "/ 131
+"/        (iinc localIndexByte signedByte)        "/ 132
+        (i2l)                                   "/ 132
+        (i2f)                                   "/ 133
+        (i2d)                                   "/ 134
+        nil                                     "/ 135
+        (l2i)                                   "/ 136
+        (l2f)                                   "/ 137
+        (l2d)                                   "/ 138
+        (l2i)                                   "/ 139
+
+        (f2l)                                   "/ 140
+        (f2d)                                   "/ 141
+        (d2i)                                   "/ 142
+        (d2l)                                   "/ 143
+        (d2f)                                   "/ 144
+        (int2byte)                              "/ 145
+        (int2char)                              "/ 146
+        (int2short)                             "/ 147
+        (lcmp)                                  "/ 148
+        (fcmpl)                                 "/ 149
+
+        (fcmpg)                                 "/ 150
+        (dcmpl)                                 "/ 151
+        (dcmpg)                                 "/ 152
+        (ifeq signedBranchShort)                "/ 153
+        (ifne signedBranchShort)                "/ 154
+        (iflt signedBranchShort)                "/ 155
+        (ifge signedBranchShort)                "/ 156
+        (ifgt signedBranchShort)                "/ 157
+        (ifle signedBranchShort)                "/ 158
+        (if_icmpeq signedBranchShort)           "/ 159
+
+        (if_icmpne signedBranchShort)           "/ 160
+        (if_icmplt signedBranchShort)           "/ 161
+        (if_icmpge signedBranchShort)           "/ 162
+        (if_icmpgt signedBranchShort)           "/ 163
+        (if_icmple signedBranchShort)           "/ 164
+        (if_acmpeq signedBranchShort)           "/ 165
+        (if_acmpne signedBranchShort)           "/ 166
+        (goto signedBranchShort)                "/ 167
+        (jsr signedBranchShort)                 "/ 168
+        (ret localIndexByte)                    "/ 169
+
+        (tableswitch tableSwitchBytes)          "/ 170
+        (lookupswitch lookupSwitchBytes)        "/ 171
+        (ireturn)                               "/ 172
+        (lreturn)                               "/ 173
+        (freturn)                               "/ 174
+        (dreturn)                               "/ 175
+        (areturn)                               "/ 176
+        (return)                                "/ 177
+        (getstatic constIndexShort)             "/ 178
+        (putstatic constIndexShort)             "/ 179
+
+        (getfield constIndexShort)              "/ 180
+        (putfield constIndexShort)              "/ 181
+        (invokevirtual constIndexShort)         "/ 182
+        (invokenonvirtual constIndexShort)      "/ 183
+        (invokestatic constIndexShort)          "/ 184
+        (invokeinterface constIndexShort nargsByte reservedByte)          "/ 185
+        (newfromname)                           "/ 186
+        (new constIndexShort)                   "/ 187
+        (newarray arrayTypeByte)                "/ 188
+        (anewarray constIndexShort)             "/ 189
+
+        (arraylength)                           "/ 190
+        (athrough)                              "/ 191
+        (checkcast)                             "/ 192
+        (instanceof constIndexShort)            "/ 193
+        (monitorenter)                          "/ 194
+        (monitorexit)                           "/ 195
+        (verifystack)                           "/ 196
+        (breakpoint)                            "/ 197
+        (multianewarray constIndexShort dimensionsByte)             "/ 198
+        nil                                     "/ 199
+
+        nil                                     "/ 200
+        nil                                     "/ 201
+        nil                                     "/ 202
+        nil                                     "/ 203
+        nil                                     "/ 204
+        nil                                     "/ 205
+        nil                                     "/ 206
+        nil                                     "/ 207
+        nil                                     "/ 208
+        nil                                     "/ 209
+                                         
+        nil                                     "/ 210
+        nil                                     "/ 211
+        nil                                     "/ 212
+        nil                                     "/ 213
+        nil                                     "/ 214
+        nil                                     "/ 215
+        nil                                     "/ 216
+        nil                                     "/ 217
+        nil                                     "/ 218
+        nil                                     "/ 219
+
+        nil                                     "/ 220
+        nil                                     "/ 221
+        nil                                     "/ 222
+        nil                                     "/ 223
+        nil                                     "/ 224
+        nil                                     "/ 225
+        nil                                     "/ 226
+        nil                                     "/ 227
+        nil                                     "/ 228
+        nil                                     "/ 229
+                                    
+        nil                                     "/ 230
+        nil                                     "/ 231
+        nil                                     "/ 232
+        nil                                     "/ 233
+        nil                                     "/ 234
+        nil                                     "/ 235
+        nil                                     "/ 236
+        nil                                     "/ 237
+        nil                                     "/ 238
+        nil                                     "/ 239
+
+        nil                                     "/ 240
+        nil                                     "/ 241
+        nil                                     "/ 242
+        nil                                     "/ 243
+        nil                                     "/ 244
+        nil                                     "/ 245
+        nil                                     "/ 246
+        nil                                     "/ 247
+        nil                                     "/ 248
+        nil                                     "/ 249
+                                              
+        nil                                     "/ 250
+        nil                                     "/ 251
+        nil                                     "/ 252
+        nil                                     "/ 253
+        nil                                     "/ 254
+        nil                                     "/ 255
+    )
+
+    "
+     JavaDecompiler initialize
+    "
+
+    "Modified: 16.4.1996 / 14:56:13 / cg"
+! !
+
+!JavaDecompiler class methodsFor:'decompiling'!
+
+decompile:aJavaMethod
+    self new decompile:aJavaMethod
+! !
+
+!JavaDecompiler methodsFor:'decompiling'!
+
+decompile:aJavaMethod
+    |endPC insn spec|
+
+    javaMethod := aJavaMethod.
+    code := aJavaMethod javaByteCode.
+    endPC := code size.
+    pc := 1.
+    [pc <= endPC] whileTrue:[
+        insn := code at:pc.
+        pc := pc + 1.
+        spec := DecoderTable at:(insn + 1).
+        Transcript show:(spec at:1); show:' '.
+        spec from:2 to:spec size do:[:what |
+            self perform:what
+        ].
+        Transcript cr.
+    ]
+
+    "Created: 16.4.1996 / 14:59:29 / cg"
+    "Modified: 16.4.1996 / 15:27:05 / cg"
+! !
+
+!JavaDecompiler methodsFor:'operand decoding'!
+
+constIndexShort
+    |hi low index constants|
+
+    hi := code at:pc.
+    low := code at:pc + 1.
+    pc := pc + 2.
+
+    index := (hi bitShift:8) + low.
+    "change from unsigned 0..FFFF to signed -8000..7FFF"
+    index >= 16r8000 ifTrue:[
+        index := index - 16r10000 
+    ].
+
+    Transcript 
+        show:index; 
+        show:' ['; 
+        show:(javaMethod constantPool at:index) displayString; 
+        show:']'
+
+    "Created: 16.4.1996 / 15:00:04 / cg"
+    "Modified: 16.4.1996 / 15:30:55 / cg"
+! !
+
+!JavaDecompiler class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaDecompiler.st,v 1.1 1996/04/16 13:34:16 cg Exp $'
+! !
+JavaDecompiler initialize!
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/JavaExceptionTableEntry.st	Tue Apr 16 13:34:16 1996 +0000
@@ -0,0 +1,32 @@
+Object subclass:#JavaExceptionTableEntry
+	instanceVariableNames:'startPC endPC handlerPC catchType'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Java-Support'
+!
+
+
+!JavaExceptionTableEntry class methodsFor:'instance creation'!
+
+startPC:start_pc endPC:end_pc handlerPC:handler_pc catchType:catch_type
+    ^ self new startPC:start_pc endPC:end_pc handlerPC:handler_pc catchType:catch_type
+
+    "Created: 16.4.1996 / 12:11:13 / cg"
+! !
+
+!JavaExceptionTableEntry methodsFor:'private accessing'!
+
+startPC:start_pc endPC:end_pc handlerPC:handler_pc catchType:catch_type
+    startPC := start_pc.
+    endPC := end_pc.
+    handlerPC := handler_pc.
+    catchType := catch_type
+
+    "Created: 16.4.1996 / 12:11:45 / cg"
+! !
+
+!JavaExceptionTableEntry class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaExceptionTableEntry.st,v 1.1 1996/04/16 13:34:03 cg Exp $'
+! !
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/JavaField.st	Tue Apr 16 13:34:16 1996 +0000
@@ -0,0 +1,39 @@
+JavaRef subclass:#JavaField
+	instanceVariableNames:'accessFlags name signature constantValue'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Java-Reader-Support'
+!
+
+
+!JavaField methodsFor:'private accessing'!
+
+setAccessFlags:flags
+    accessFlags := flags.
+
+    "Created: 16.4.1996 / 13:04:25 / cg"
+!
+
+setConstantValue:something
+    constantValue := something.
+
+    "Created: 16.4.1996 / 13:04:58 / cg"
+!
+
+setName:aString
+    name := aString.
+
+    "Created: 16.4.1996 / 13:04:35 / cg"
+!
+
+setSignature:aString
+    signature := aString.
+
+    "Created: 16.4.1996 / 13:04:43 / cg"
+! !
+
+!JavaField class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaField.st,v 1.1 1996/04/16 13:33:45 cg Exp $'
+! !