JavaClassReader.st
changeset 128 acc4e8e77092
parent 122 e731a1c1d499
child 135 098936234135
--- a/JavaClassReader.st	Wed Jul 10 10:58:40 1996 +0000
+++ b/JavaClassReader.st	Wed Jul 10 15:01:25 1996 +0000
@@ -342,7 +342,7 @@
     "/ read magic, determine byte order
     "/
     msb := true.
-    magic := self nextU4.
+    magic := inStream nextUnsignedLongMSB:msb.
     magic = 16rCAFEBABE ifFalse:[
         magic = 16rBEBAFECA ifFalse:[
             self error:'not a java class file'.
@@ -357,8 +357,8 @@
     "/
     "/ get version
     "/
-    minorVsn := self nextU2.
-    majorVsn := self nextU2.
+    minorVsn := inStream nextUnsignedShortMSB:msb.
+    majorVsn := inStream nextUnsignedShortMSB:msb.
 
     (majorVsn ~~ 45 or:[minorVsn ~~ 3]) ifTrue:[
         Transcript show:'warning this file has version '; show:majorVsn; show:'.'; showCR:minorVsn. 
@@ -379,9 +379,9 @@
     "/
     "/ access flags
     "/
-    access_flags := self nextU2.
-    this_class_index := self nextU2.
-    super_class_index := self nextU2.
+    access_flags := inStream nextUnsignedShortMSB:msb.
+    this_class_index := inStream nextUnsignedShortMSB:msb.
+    super_class_index := inStream nextUnsignedShortMSB:msb.
 
     super_class_index == 0 ifTrue:[
         super_class := nil
@@ -474,9 +474,9 @@
 readSourceFileAttributeFor:aJavaClass
     |attribute_length sourceFile_index sourceFile|
 
-    attribute_length := self nextU4.
+    attribute_length := inStream nextUnsignedLongMSB:msb.
 
-    sourceFile_index := self nextU2.
+    sourceFile_index := inStream nextUnsignedShortMSB:msb.
     sourceFile := constants at:sourceFile_index.
 
     aJavaClass setSourceFile:sourceFile.
@@ -551,7 +551,7 @@
 
     Verbose ifTrue:[Transcript show:'attrib at pos: '; showCR:inStream position].
 
-    attribute_name_index := self nextU2.
+    attribute_name_index := inStream nextUnsignedShortMSB:msb.
 
     "/
     "/ UNDOC feature ?
@@ -567,7 +567,7 @@
     Verbose ifTrue:[Transcript show:'attrib name: '; showCR:attribute_name].
 
     (self readAttribute:attribute_name for:something) ifFalse:[
-        attribute_length := self nextU4.
+        attribute_length := inStream nextUnsignedLongMSB:msb.
         attribute_info := ByteArray new:(attribute_length).
         inStream nextBytes:attribute_length into:attribute_info startingAt:1.
 
@@ -585,7 +585,7 @@
 readAttributesFor:something
     |attributes_count|
 
-    attributes_count := self nextU2.
+    attributes_count := inStream nextUnsignedShortMSB:msb.
 
     1 to:attributes_count do:[:i |
         self readAttributeFor:something.
@@ -606,7 +606,7 @@
     "/
     "/ get tag
     "/
-    tag := self nextU1.
+    tag := inStream nextByte.
     Verbose ifTrue:[Transcript show:'tag = '; showCR:tag].
 
     constReader := #(
@@ -640,7 +640,7 @@
     "/
     "/ get constant pool
     "/
-    constantPoolCount := self nextU2.
+    constantPoolCount := inStream nextUnsignedShortMSB:msb.
     Verbose ifTrue:[Transcript show:'constantPoolCount = '; showCR:constantPoolCount].
 
     constants := JavaConstantPool "Array" new:constantPoolCount-1.
@@ -686,7 +686,7 @@
 readConstant_Asciz
     |len string|
 
-    len := self nextU2.
+    len := inStream nextUnsignedShortMSB:msb.
     string := String new:len.
     inStream nextBytes:len into:string startingAt:1.
 
@@ -706,7 +706,7 @@
 readConstant_Class
     |name_index name|
 
-    name_index := self nextU2.
+    name_index := inStream nextUnsignedShortMSB:msb.
 
     Verbose ifTrue:[Transcript show:'class; index= '; showCR:name_index].
 
@@ -731,8 +731,8 @@
 readConstant_Double
     |high low aFloat|
 
-    high := self nextU4.
-    low := self nextU4.
+    high := inStream nextUnsignedLongMSB:msb.
+    low := inStream nextUnsignedLongMSB:msb.
 
     aFloat := Float new.
     UninterpretedBytes isBigEndian ifTrue:[
@@ -772,8 +772,8 @@
 readConstant_Fieldref
     |class_index name_and_type_index|
 
-    class_index := self nextU2.
-    name_and_type_index := self nextU2.
+    class_index := inStream nextUnsignedShortMSB:msb.
+    name_and_type_index := inStream nextUnsignedShortMSB:msb.
 
     Verbose ifTrue:[Transcript show:'fieldref; classindex= ';     showCR:class_index].
     Verbose ifTrue:[Transcript show:'fieldref; name&typeindex= '; showCR:name_and_type_index].
@@ -795,7 +795,7 @@
 readConstant_Float
     |high aFloat|
 
-    high := self nextU4.
+    high := inStream nextUnsignedLongMSB:msb.
 
     aFloat := ShortFloat basicNew.
     UninterpretedBytes isBigEndian ifTrue:[
@@ -825,7 +825,7 @@
 readConstant_Integer
     |value|
 
-    value := self nextS4.
+    value := inStream nextLongMSB:msb.
 
     Verbose ifTrue:[Transcript show:'integer; value= ';     showCR:value].
 
@@ -843,8 +843,8 @@
 readConstant_InterfaceMethodref
     |class_index name_and_type_index|
 
-    class_index := self nextU2.
-    name_and_type_index := self nextU2.
+    class_index := inStream nextUnsignedShortMSB:msb.
+    name_and_type_index := inStream nextUnsignedShortMSB:msb.
 
     Verbose ifTrue:[Transcript show:'methodref; classindex= ';     showCR:class_index].
     Verbose ifTrue:[Transcript show:'methodref; name&typeindex= '; showCR:name_and_type_index].
@@ -866,8 +866,8 @@
 readConstant_Long
     |high low value|
 
-    high := self nextU4.
-    low := self nextU4.
+    high := inStream nextUnsignedLongMSB:msb.
+    low := inStream nextUnsignedLongMSB:msb.
 
     value := (high bitShift:32) bitOr:low.
     (high bitTest:16r80000000) ifTrue:[
@@ -890,8 +890,8 @@
 readConstant_Methodref
     |class_index name_and_type_index|
 
-    class_index := self nextU2.
-    name_and_type_index := self nextU2.
+    class_index := inStream nextUnsignedShortMSB:msb.
+    name_and_type_index := inStream nextUnsignedShortMSB:msb.
 
     Verbose ifTrue:[Transcript show:'methodref; classindex= ';     showCR:class_index].
     Verbose ifTrue:[Transcript show:'methodref; name&typeindex= '; showCR:name_and_type_index].
@@ -913,8 +913,8 @@
 readConstant_NameAndType
     |name_index signature_index|
 
-    name_index := self nextU2.
-    signature_index := self nextU2.
+    name_index := inStream nextUnsignedShortMSB:msb.
+    signature_index := inStream nextUnsignedShortMSB:msb.
 
     Verbose ifTrue:[Transcript show:'methodref; nameindex= ';     showCR:name_index].
     Verbose ifTrue:[Transcript show:'methodref; signatureindex= '; showCR:signature_index].
@@ -936,7 +936,7 @@
 readConstant_String
     |tag string_index|
 
-    string_index := self nextU2.
+    string_index := inStream nextUnsignedShortMSB:msb.
 
     Verbose ifTrue:[Transcript show:'string; index= '; showCR:string_index].
 
@@ -959,9 +959,9 @@
 readConstantValueAttributeFor:aField
     |attribute_length constantvalue_index constantValue|
 
-    attribute_length := self nextU4.
+    attribute_length := inStream nextUnsignedLongMSB:msb.
 
-    constantvalue_index := self nextU2.
+    constantvalue_index := inStream nextUnsignedShortMSB:msb.
     constantValue := constants at:constantvalue_index.
 
     aField constantValue:constantValue.
@@ -981,16 +981,16 @@
 readFieldInfofield
     |access_flags name_index signature_index attributes_count field|
 
-    access_flags := self nextU2.
-    name_index := self nextU2.
-    signature_index := self nextU2.
+    access_flags := inStream nextUnsignedShortMSB:msb.
+    name_index := inStream nextUnsignedShortMSB:msb.
+    signature_index := inStream nextUnsignedShortMSB:msb.
 
     field := JavaField new.
     field setAccessFlags:access_flags.
     field setName:(constants at:name_index).
     field setSignature:(constants at:signature_index).
 
-    attributes_count := self nextU2.
+    attributes_count := inStream nextUnsignedShortMSB:msb.
 
     Verbose ifTrue:[Transcript show:'  field name: '; show:(constants at:name_index);
                                show:' access: '; show:access_flags;
@@ -1016,7 +1016,7 @@
     "/
     "/ get fieldInfos
     "/
-    nFields := self nextU2.
+    nFields := inStream nextUnsignedShortMSB:msb.
     Verbose ifTrue:[Transcript show:'fieldsCount = '; showCR:nFields].
 
     fields := Array new:nFields.
@@ -1043,14 +1043,14 @@
     "/
     "/ get interfaces
     "/
-    interfacesCount := self nextU2.
+    interfacesCount := inStream nextUnsignedShortMSB:msb.
     Verbose ifTrue:[Transcript show:'interfacesCount = '; showCR:interfacesCount].
 
     interfaces := Array new:interfacesCount.
 
     1 to:interfacesCount do:[:i |
         Verbose ifTrue:[Transcript show:'interface: '; showCR:i].
-        interface_index := self nextU2.
+        interface_index := inStream nextUnsignedShortMSB:msb.
         interface := constants at:interface_index.
 
         interfaces at:i put:interface.
@@ -1071,24 +1071,24 @@
     |attribute_length max_stack max_locals code_length code
      exception_table_length exception_table unknown1 unknown2|
 
-    attribute_length := self nextU4.
+    attribute_length := inStream nextUnsignedLongMSB:msb.
 
 
     Verbose ifTrue:[Transcript show:'attribute_length: 0x'; showCR:(attribute_length printStringRadix:16)].
 
     minorVsn > 2 ifTrue:[
-        unknown1 := self nextU1.
-        max_stack := self nextU1.
-        max_locals := self nextU2.
-        unknown2 := self nextU2.
+        unknown1 := inStream nextByte.
+        max_stack := inStream nextByte.
+        max_locals := inStream nextUnsignedShortMSB:msb.
+        unknown2 := inStream nextUnsignedShortMSB:msb.
         Verbose ifTrue:[Transcript show:'?1: '; showCR:unknown1].
         Verbose ifTrue:[Transcript show:'?2: '; showCR:unknown2].
     ] ifFalse:[
-        max_stack := self nextU1.
-        max_locals := self nextU1.
+        max_stack := inStream nextByte.
+        max_locals := inStream nextByte.
     ].
 
-    code_length := self nextU2.
+    code_length := inStream nextUnsignedShortMSB:msb.
     Verbose ifTrue:[Transcript show:'code_length: '; showCR:(code_length printStringRadix:16)].
     Verbose ifTrue:[Transcript show:'code at pos: '; showCR:inStream position].
 
@@ -1097,7 +1097,7 @@
 
     Verbose ifTrue:[Transcript show:'method code:'; showCR:code.].
 
-    exception_table_length := self nextU2.
+    exception_table_length := inStream nextUnsignedShortMSB:msb.
     Verbose ifTrue:[Transcript show:'exception_table_length: '; showCR:(exception_table_length printStringRadix:16)].
     exception_table_length ~~ 0 ifTrue:[
         Verbose ifTrue:[Transcript show:'exceptionTable length:'; showCR:exception_table_length.].
@@ -1106,10 +1106,10 @@
         1 to:exception_table_length do:[:i |
             |start_pc end_pc handler_pc catch_type|
 
-            start_pc := self nextU2.
-            end_pc := self nextU2.
-            handler_pc := self nextU2.
-            catch_type := constants at:self nextU2.
+            start_pc := inStream nextUnsignedShortMSB:msb.
+            end_pc := inStream nextUnsignedShortMSB:msb.
+            handler_pc := inStream nextUnsignedShortMSB:msb.
+            catch_type := constants at:(inStream nextUnsignedShortMSB:msb).
             exception_table at:i put:(JavaExceptionTableEntry
                                             startPC:start_pc
                                             endPC:end_pc
@@ -1141,15 +1141,15 @@
 readExceptionsAttributeFor:aJavaMethod
     |attribute_length exception_table_length exception_table|
 
-    attribute_length := self nextU4.
+    attribute_length := inStream nextUnsignedLongMSB:msb.
 
-    exception_table_length := self nextU2.
+    exception_table_length := inStream nextUnsignedShortMSB:msb.
     exception_table_length ~~ 0 ifTrue:[
         exception_table := Array new:exception_table_length.
         1 to:exception_table_length do:[:i |
             |idx ex|
 
-            idx := self nextU2.
+            idx := inStream nextUnsignedShortMSB:msb.
             ex := constants at:idx.
             exception_table at:i put:ex.
         ].
@@ -1167,16 +1167,16 @@
 readLineNumberTableAttributeFor:aJavaMethod
     |attribute_length line_number_table_length line_number_table|
 
-    attribute_length := self nextU4.
+    attribute_length := inStream nextUnsignedLongMSB:msb.
 
-    line_number_table_length := self nextU2.
+    line_number_table_length := inStream nextUnsignedShortMSB:msb.
     line_number_table_length ~~ 0 ifTrue:[
         line_number_table := Array new:line_number_table_length.
         1 to:line_number_table_length do:[:i |
             |start_pc line_number|
 
-            start_pc := self nextU2.
-            line_number := self nextU2.
+            start_pc := inStream nextUnsignedShortMSB:msb.
+            line_number := inStream nextUnsignedShortMSB:msb.
             line_number_table at:i put:(start_pc -> line_number).
         ].
     ].
@@ -1198,21 +1198,21 @@
 readLocalVariableTableAttributeFor:aJavaMethod
     |attribute_length local_variable_table_length local_variable_table|
 
-    attribute_length := self nextU4.
+    attribute_length := inStream nextUnsignedLongMSB:msb.
 
-    local_variable_table_length := self nextU2.
+    local_variable_table_length := inStream nextUnsignedShortMSB:msb.
     local_variable_table_length ~~ 0 ifTrue:[
         local_variable_table := JavaLocalVariableTable new:local_variable_table_length.
         1 to:local_variable_table_length do:[:i |
             |start_pc length name_index sig_index slot name signature|
 
-            start_pc := self nextU2.
-            length := self nextU2.
-            name_index := self nextU2.
+            start_pc := inStream nextUnsignedShortMSB:msb.
+            length := inStream nextUnsignedShortMSB:msb.
+            name_index := inStream nextUnsignedShortMSB:msb.
             name := constants at:name_index.
-            sig_index := self nextU2.
+            sig_index := inStream nextUnsignedShortMSB:msb.
             signature := constants at:sig_index.
-            slot := self nextU2.
+            slot := inStream nextUnsignedShortMSB:msb.
 
             local_variable_table at:i put:(JavaLocalVariableTableEntry new 
                                                 startPC:start_pc 
@@ -1243,9 +1243,9 @@
     "/
     "/ get a method
     "/
-    access_flags := self nextU2.
-    name_index := self nextU2.
-    signature_index := self nextU2.
+    access_flags := inStream nextUnsignedShortMSB:msb.
+    name_index := inStream nextUnsignedShortMSB:msb.
+    signature_index := inStream nextUnsignedShortMSB:msb.
 
     name := constants at:name_index.
     signature := constants at:signature_index.
@@ -1278,7 +1278,7 @@
     "/
     "/ get methods
     "/
-    methodsCount := self nextU2.
+    methodsCount := inStream nextUnsignedShortMSB:msb.
     Verbose ifTrue:[Transcript show:'methodsCount = '; showCR:methodsCount].
 
     1 to:methodsCount do:[:i |
@@ -1294,35 +1294,9 @@
     "Created: 15.4.1996 / 16:46:30 / cg"
 ! !
 
-!JavaClassReader methodsFor:'low level reading'!
-
-nextS4
-    ^ inStream nextLongMSB:msb
-
-    "Created: 15.4.1996 / 15:04:28 / cg"
-!
-
-nextU1
-    ^ inStream nextByte
-
-    "Created: 15.4.1996 / 15:15:43 / cg"
-!
-
-nextU2
-    ^ inStream nextUnsignedShortMSB:msb
-
-    "Created: 15.4.1996 / 15:12:25 / cg"
-!
-
-nextU4
-    ^ inStream nextUnsignedLongMSB:msb
-
-    "Created: 15.4.1996 / 15:04:28 / cg"
-! !
-
 !JavaClassReader  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClassReader.st,v 1.36 1996/07/06 21:54:02 cg Exp $'
+    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClassReader.st,v 1.37 1996/07/10 15:01:25 cg Exp $'
 ! !
 JavaClassReader initialize!