JavaClassReader.st
author cg
Fri, 18 Sep 1998 14:34:43 +0000
changeset 370 2a2e5914ee22
parent 366 42a5f6d73925
child 376 ffd6472dbf91
permissions -rw-r--r--
also look for zar suffix files.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
083530508d9c intitial checkin
cg
parents:
diff changeset
     1
Object subclass:#JavaClassReader
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
     2
	instanceVariableNames:'inStream msb constants majorVsn minorVsn constNeeds2Slots
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
     3
		constSlot'
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
     4
	classVariableNames:'Verbose Silent AbsolutelySilent LazyClassLoading
275
92b7ebb0b54c *** empty log message ***
cg
parents: 273
diff changeset
     5
		InvalidClassFormatSignal ClassLoaderQuerySignal'
1
083530508d9c intitial checkin
cg
parents:
diff changeset
     6
	poolDictionaries:''
083530508d9c intitial checkin
cg
parents:
diff changeset
     7
	category:'Java-Support'
083530508d9c intitial checkin
cg
parents:
diff changeset
     8
!
083530508d9c intitial checkin
cg
parents:
diff changeset
     9
083530508d9c intitial checkin
cg
parents:
diff changeset
    10
135
098936234135 *** empty log message ***
cg
parents: 128
diff changeset
    11
!JavaClassReader class methodsFor:'initialization'!
1
083530508d9c intitial checkin
cg
parents:
diff changeset
    12
083530508d9c intitial checkin
cg
parents:
diff changeset
    13
initialize
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    14
    InvalidClassFormatSignal := Signal new mayProceed:true.
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    15
    InvalidClassFormatSignal notifierString:'class load failure'.
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    16
    InvalidClassFormatSignal nameClass:self message:#invalidClassFormatSignal.
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    17
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
    18
    Verbose := false. 
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
    19
    Silent := true.
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
    20
    AbsolutelySilent := false.
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
    21
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
    22
    LazyClassLoading := false. "/ true.
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    23
    ClassLoaderQuerySignal := QuerySignal new
29
eb3367f8fb9b checkin from browser
cg
parents: 27
diff changeset
    24
eb3367f8fb9b checkin from browser
cg
parents: 27
diff changeset
    25
    "
eb3367f8fb9b checkin from browser
cg
parents: 27
diff changeset
    26
     JavaClassReader initialize
eb3367f8fb9b checkin from browser
cg
parents: 27
diff changeset
    27
    "
eb3367f8fb9b checkin from browser
cg
parents: 27
diff changeset
    28
275
92b7ebb0b54c *** empty log message ***
cg
parents: 273
diff changeset
    29
    "Modified: / 27.1.1998 / 17:54:23 / cg"
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    30
! !
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    31
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    32
!JavaClassReader class methodsFor:'Signal constants'!
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    33
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    34
classLoaderQuerySignal
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    35
    ^ ClassLoaderQuerySignal
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    36
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    37
    "Created: 14.8.1997 / 19:56:03 / cg"
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    38
!
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    39
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    40
invalidClassFormatSignal
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    41
    ^ InvalidClassFormatSignal
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    42
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
    43
    "Created: 3.8.1997 / 18:17:21 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
    44
! !
083530508d9c intitial checkin
cg
parents:
diff changeset
    45
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    46
!JavaClassReader class methodsFor:'constants'!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    47
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    48
fileMajorVersion
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    49
    ^ 45
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    50
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    51
    "Modified: / 7.5.1998 / 13:14:27 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    52
    "Created: / 7.5.1998 / 13:16:35 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    53
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    54
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    55
fileMinorVersion
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    56
    ^ 3
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    57
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    58
    "Modified: / 7.5.1998 / 13:14:27 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    59
    "Created: / 7.5.1998 / 13:16:40 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    60
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    61
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    62
magic_LSB
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    63
    ^ 16rBEBAFECA
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    64
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    65
    "Modified: / 7.5.1998 / 13:14:27 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    66
    "Created: / 7.5.1998 / 13:15:05 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    67
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    68
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    69
magic_MSB
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    70
    ^ 16rCAFEBABE
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    71
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    72
    "Modified: / 7.5.1998 / 13:14:27 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    73
! !
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
    74
135
098936234135 *** empty log message ***
cg
parents: 128
diff changeset
    75
!JavaClassReader class methodsFor:'debugging'!
1
083530508d9c intitial checkin
cg
parents:
diff changeset
    76
083530508d9c intitial checkin
cg
parents:
diff changeset
    77
verbose:aBoolean
083530508d9c intitial checkin
cg
parents:
diff changeset
    78
    Verbose := aBoolean
083530508d9c intitial checkin
cg
parents:
diff changeset
    79
083530508d9c intitial checkin
cg
parents:
diff changeset
    80
    "
67
a72c949d86dd *** empty log message ***
cg
parents: 62
diff changeset
    81
     Java flushClasses.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
    82
     JavaClassReader verbose:true
083530508d9c intitial checkin
cg
parents:
diff changeset
    83
     JavaClassReader verbose:false
083530508d9c intitial checkin
cg
parents:
diff changeset
    84
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
    85
! !
083530508d9c intitial checkin
cg
parents:
diff changeset
    86
135
098936234135 *** empty log message ***
cg
parents: 128
diff changeset
    87
!JavaClassReader class methodsFor:'file reading'!
1
083530508d9c intitial checkin
cg
parents:
diff changeset
    88
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
    89
loadClass:aClassName
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
    90
    "reads a class, installs and returns it.
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
    91
     The classes string constants are resolved & <clinit> is called,
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
    92
     if it implements it."
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
    93
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    94
    |rslt loader|
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
    95
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    96
    loader := ClassLoaderQuerySignal raise.
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
    97
    loader isNil ifTrue:[
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
    98
	rslt := self loadClassLazy:aClassName ignoring:(Set new).
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
    99
	rslt notNil ifTrue:[self postLoadActions].
40
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   100
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   101
	^ rslt
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   102
    ].
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   103
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   104
    ^ loader loadClass:aClassName
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   105
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   106
    "
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   107
     JavaClassReader loadClass:'awt/Component'
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   108
     JavaClassReader loadClass:'awt/Button'
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   109
     JavaClassReader loadClass:'browser/AddButton'
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   110
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   111
     JavaClassReader loadClass:'java/lang/Object'
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   112
     JavaClassReader loadClass:'java/lang/AbstractMethodError'
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   113
     JavaClassReader loadClass:'java/lang/Thread'
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   114
    "
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   115
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   116
    "Created: / 15.4.1996 / 14:58:53 / cg"
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   117
    "Modified: / 3.1.1998 / 22:36:13 / cg"
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   118
!
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   119
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   120
loadClassLazy:aClassName ignoring:classesBeingLoaded
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   121
    "private helper:
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   122
      reads a class, installs and returns it.
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   123
      The class is searched along the ClassPath.
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   124
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   125
     This is a partial load (to load other classes):
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   126
     - The classes stringConstants are not fixed to be JavaStrings 
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   127
       (i.e they are still ST-Strings).
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   128
     - The class is NOT initialized."
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   129
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   130
    |rslt clsName cls loadedClass|
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
   131
52
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
   132
    (aClassName endsWith:';') ifTrue:[
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   133
        ('oops - loading of ' , aClassName , ' attempted') printNL.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   134
        self halt:'should not happen'.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   135
        ^ nil
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   136
    ].
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   137
    (aClassName endsWith:'[]') ifTrue:[
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   138
        ('oops - loading of ' , aClassName , ' attempted') printNL.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   139
        self halt:'should not happen'.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   140
        ^ nil
52
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
   141
    ].
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
   142
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
   143
    clsName := aClassName.
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
   144
    (clsName includes:$.) ifTrue:[
360
e3df9401df00 use #copyReplaceAll:with:
cg
parents: 357
diff changeset
   145
        clsName := clsName asString copyReplaceAll:$. with:$/
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
   146
    ].
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   147
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   148
    (classesBeingLoaded notNil and:[classesBeingLoaded includes:clsName]) ifTrue:[
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   149
        ('oops - recursive load of ' , clsName , ' attempted') printNL.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   150
        self halt:'should not happen'.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   151
        ^ JavaUnresolvedClassConstant fullName:clsName
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   152
    ].
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   153
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   154
    (cls := Java at:clsName) notNil ifTrue:[
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   155
        ('oops - ' , clsName , ' is already loaded') printNL.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   156
        self halt:clsName , ' is already loaded - should not happen'.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   157
        ^ cls
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   158
    ].
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   159
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   160
    classesBeingLoaded isNil ifTrue:[
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   161
        loadedClass := Set with:clsName
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   162
    ] ifFalse:[
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   163
        loadedClass := Set withAll:classesBeingLoaded.
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   164
        loadedClass add:clsName.
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   165
    ].
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   166
135
098936234135 *** empty log message ***
cg
parents: 128
diff changeset
   167
    Java classPath do:[:path |
365
568f3a4e4e1c checkin from browser
cg
parents: 360
diff changeset
   168
        |nm p zar entry zipFile|
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   169
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   170
        p := path.
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   171
        p asFilename isDirectory ifTrue:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   172
            (p endsWith:Filename separator) ifFalse:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   173
                p := p , (Filename separator asString)
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   174
            ].
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   175
            (Array 
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   176
                with:clsName
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   177
                with:clsName asLowercase
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   178
                with:clsName asUppercase) 
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   179
            do:[:tryName |
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   180
                (nm := p , tryName , '.class') asFilename exists ifTrue:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   181
                    (Java isExcludedFromClassPath:nm) ifFalse:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   182
                        rslt := self loadFileLazy:nm ignoring:loadedClass.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   183
                        rslt notNil ifTrue:[^ rslt].
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   184
                    ]
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   185
                ].
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   186
            ]
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   187
        ] ifFalse:[
370
2a2e5914ee22 also look for zar suffix files.
cg
parents: 366
diff changeset
   188
            ((zipFile := p asFilename withSuffix:'jar') exists 
2a2e5914ee22 also look for zar suffix files.
cg
parents: 366
diff changeset
   189
            or:[(zipFile := p asFilename withSuffix:'zip') exists]) ifTrue:[
365
568f3a4e4e1c checkin from browser
cg
parents: 360
diff changeset
   190
                zar := ZipArchive oldFileNamed:zipFile.
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   191
                (Array 
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   192
                    with:clsName
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   193
                    with:clsName asLowercase
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   194
                    with:clsName asUppercase) 
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   195
                do:[:tryName |
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   196
                    nm := tryName , '.class'.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   197
                    entry := zar extract:nm.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   198
                    entry notNil ifTrue:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   199
                        (Java isExcludedFromClassPath:nm) ifFalse:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   200
                            rslt := self loadStreamLazy:(entry readStream) ignoring:loadedClass.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   201
                            rslt notNil ifTrue:[^ rslt].
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   202
                        ]
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   203
                    ]
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   204
                ]
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   205
            ]
278
9d0ed6e743da handle classPath exclusion
cg
parents: 275
diff changeset
   206
        ]
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   207
    ].
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   208
318
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   209
    ('JAVA [info]: no file found for: ' , clsName) infoPrintCR.
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   210
    ^ nil
135
098936234135 *** empty log message ***
cg
parents: 128
diff changeset
   211
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   212
    "Modified: / 14.8.1997 / 11:38:42 / stefan"
370
2a2e5914ee22 also look for zar suffix files.
cg
parents: 366
diff changeset
   213
    "Modified: / 17.9.1998 / 20:51:25 / cg"
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   214
!
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   215
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   216
loadFile:aFilename
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   217
    "reads a class from aFilename, installs and returns it.
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   218
     The classes strings are fixed and its class-init function is called."
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   219
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   220
    self loadFileLazy:aFilename ignoring:(Set new).
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   221
    self postLoadActions
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   222
!
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   223
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   224
loadFileLazy:aFilename ignoring:classesBeingLoaded
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   225
    "reads a class from aFilename, installs and returns it.
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   226
     Strings are fixed and classrefs are fixed, 
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   227
     but NO no class-init functions are called."
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   228
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   229
    |aClass pool|
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   230
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   231
    aClass := self readFile:aFilename ignoring:classesBeingLoaded.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   232
    aClass notNil ifTrue:[
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   233
        aClass isJavaClass ifTrue:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   234
            "/ a java class
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   235
            Java at:(aClass fullName asSymbol) put:aClass.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   236
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   237
            classesBeingLoaded remove:aClass fullName ifAbsent:nil.
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   238
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   239
            JavaUnresolvedConstant resolveFor:aClass.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   240
        ] ifFalse:[    
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   241
            "/ a smalltalk class
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   242
            "/ self halt.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   243
aClass inspect.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   244
        ]
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   245
    ].
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   246
    ^ aClass
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   247
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   248
    "
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   249
     JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   250
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   251
     '/phys/ibm3/java/lib/java/lang' asFilename
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   252
        directoryContents do:[:nm |
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   253
            (nm endsWith:'.class') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   254
                ('/phys/ibm3/java/lib/java/lang/' , nm) printNL.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   255
                JavaClassReader loadFile:'/phys/ibm3/java/lib/java/lang/' , nm
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   256
            ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   257
        ].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   258
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   259
     '/phys/ibm3/java/lib/java/io' asFilename
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   260
        directoryContents do:[:nm |
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   261
            (nm endsWith:'.class') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   262
                ('/phys/ibm3/java/lib/java/io/' , nm) printNL.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   263
                JavaClassReader loadFile:'/phys/ibm3/java/lib/java/io/' , nm
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   264
            ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   265
        ].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   266
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   267
     '/phys/ibm3/java/lib/java/net' asFilename
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   268
        directoryContents do:[:nm |
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   269
            (nm endsWith:'.class') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   270
                ('/phys/ibm3/java/lib/java/net/' , nm) printNL.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   271
                JavaClassReader loadFile:'/phys/ibm3/java/lib/java/net/' , nm
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   272
            ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   273
        ].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   274
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   275
     '/phys/ibm3/java/lib/java/util' asFilename
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   276
        directoryContents do:[:nm |
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   277
            (nm endsWith:'.class') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   278
                ('/phys/ibm3/java/lib/java/util/' , nm) printNL.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   279
                JavaClassReader loadFile:'/phys/ibm3/java/lib/java/util/' , nm
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   280
            ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   281
        ].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   282
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   283
     '/phys/ibm3/java/lib/java/awt' asFilename
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   284
        directoryContents do:[:nm |
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   285
            (nm endsWith:'.class') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   286
                ('/phys/ibm3/java/lib/java/awt/' , nm) printNL.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   287
                JavaClassReader loadFile:'/phys/ibm3/java/lib/java/awt/' , nm
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   288
            ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   289
        ].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   290
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   291
     '/phys/ibm3/java/lib/java/applet' asFilename
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   292
        directoryContents do:[:nm |
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   293
            (nm endsWith:'.class') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   294
                ('/phys/ibm3/java/lib/java/applet/' , nm) printNL.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   295
                JavaClassReader loadFile:'/phys/ibm3/java/lib/java/applet/' , nm
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   296
            ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   297
        ].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   298
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   299
     JavaClassReader loadFile:'/phys/ibm3/java/lib/java/lang/AbstractMethodError.class'
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   300
     JavaClassReader loadFile:'/phys/ibm3/java/lib/java/lang/Thread.class'
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   301
    "
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   302
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   303
    "Created: / 15.4.1996 / 14:58:53 / cg"
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   304
    "Modified: / 12.5.1998 / 22:06:52 / cg"
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   305
!
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   306
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   307
loadStreamLazy:aStream ignoring:classesBeingLoaded
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   308
    "reads a class from aStream, installs and returns it.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   309
     Strings are fixed and classrefs are fixed, 
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   310
     but NO no class-init functions are called."
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   311
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   312
    |javaClass pool|
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   313
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   314
    javaClass := self readStream:aStream ignoring:classesBeingLoaded.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   315
    javaClass notNil ifTrue:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   316
        Java at:(javaClass fullName asSymbol) put:javaClass.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   317
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   318
        classesBeingLoaded remove:javaClass fullName ifAbsent:nil.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   319
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   320
        JavaUnresolvedConstant resolveFor:javaClass.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   321
    ].
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   322
    ^ javaClass
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   323
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   324
    "Created: / 30.3.1998 / 17:59:02 / cg"
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   325
!
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   326
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   327
postLoadActions
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   328
    "Resolve all classes' string constants.
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   329
     Perform all class initialization functions (of those which are not
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   330
     yet initialized)."
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   331
225
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   332
    ^ self postLoadActions:true
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   333
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   334
    "Modified: 15.8.1997 / 01:02:17 / cg"
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   335
!
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   336
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   337
postLoadActions:loadUnresolved
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   338
    "Resolve all classes' string constants.
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   339
     Perform all class initialization functions 
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   340
     (of those which are not yet initialized)."
225
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   341
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   342
    |classes prevUnresolved newUnresolved loader|
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   343
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   344
    "/ need at least java.lang.String, for valid constants
167
77dcbc4b2201 *** empty log message ***
cg
parents: 135
diff changeset
   345
    Java java_lang_String isNil ifTrue:[
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   346
        self loadClassLazy:'java.lang.String' ignoring:(Set new).
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   347
    ].
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   348
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   349
    LazyClassLoading ifFalse:[
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   350
        loader := ClassLoaderQuerySignal raise.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   351
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   352
        prevUnresolved := nil.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   353
        newUnresolved := JavaUnresolvedConstant unresolvedClassNames asArray.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   354
        loadUnresolved ifTrue:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   355
            [prevUnresolved ~= newUnresolved] whileTrue:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   356
                newUnresolved do:[:nextUnresolved |
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   357
                    |classURL|
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   358
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   359
                    (Java at:nextUnresolved) isNil ifTrue:[ "/ could have been loaded in the meantime
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   360
                        Silent ifFalse:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   361
                            'loading unresolved: ' print. nextUnresolved printCR.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   362
                        ].
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   363
                        loader isNil ifTrue:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   364
                            self
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   365
                                loadClassLazy:nextUnresolved
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   366
                                ignoring:(Set new).
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   367
                        ] ifFalse:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   368
                            "/
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   369
                            "/ the aquired loader is a javaClassLoader
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   370
                            "/ which expects an URL as arg.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   371
                            "/
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   372
                            "/ classURL := Java as_URL:('file:' , nextUnresolved asString , '.class').
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   373
                            "/ loader loadClass:classURL
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   374
                            loader
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   375
                                perform:#'loadClass(Ljava/lang/String;)Ljava/lang/Class;'
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   376
                                with:(Java as_String:(nextUnresolved asString)).
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   377
                        ]
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   378
                    ]
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   379
                ].
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   380
                prevUnresolved := newUnresolved.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   381
                newUnresolved := JavaUnresolvedConstant unresolvedClassNames asArray.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   382
            ].
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   383
        ].
229
b91c9462ac83 *** empty log message ***
cg
parents: 225
diff changeset
   384
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   385
        newUnresolved size == 0 ifTrue:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   386
            "/ nothing unresolved
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   387
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   388
            (classes := Java allClasses) notNil ifTrue:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   389
                "/ init all new classes
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   390
                "/ fetch again - there could be new ones ...
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   391
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   392
                classes := Java allClasses.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   393
                classes do:[:aJavaClass |
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   394
                    aJavaClass isInitialized ifFalse:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   395
                        Silent ifFalse:[
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   396
                            'performing class initialization of ' print. aJavaClass fullName printCR.
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   397
                        ].
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   398
                        aJavaClass classInit
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   399
                    ]
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   400
                ]
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   401
            ]
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   402
        ].
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   403
    ]
167
77dcbc4b2201 *** empty log message ***
cg
parents: 135
diff changeset
   404
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   405
    "Created: / 15.8.1997 / 01:01:44 / cg"
255
2d8b3948a08a *** empty log message ***
cg
parents: 252
diff changeset
   406
    "Modified: / 7.1.1998 / 14:13:55 / cg"
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   407
!
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   408
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   409
readFile:aFilename ignoring:classesBeingLoaded
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   410
    "reads a class from aFilename and returns it.
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   411
     The JavaClass is NOT installed as global and unresolved
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   412
     refs are NOT patched."
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   413
73
a1268823f1a4 *** empty log message ***
cg
parents: 72
diff changeset
   414
    |inStream javaClass|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   415
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   416
    Silent ifFalse:[
318
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   417
        'reading ' print. aFilename print. ' ...' printNL.
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   418
    ].
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
   419
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   420
    inStream := aFilename asFilename readStream.
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   421
    inStream isNil ifTrue:[
318
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   422
        ('JAVA [info]: no file: ' , aFilename) printCR.
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   423
        self halt.
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   424
        ^ nil
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   425
    ].
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   426
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   427
    javaClass := self new readStream:inStream ignoring:classesBeingLoaded.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   428
    (javaClass notNil and:[javaClass isJavaClass]) ifTrue:[
318
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   429
        javaClass setBinaryFilePath:(inStream pathName).
73
a1268823f1a4 *** empty log message ***
cg
parents: 72
diff changeset
   430
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   431
    inStream close.
27
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
   432
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
   433
    AbsolutelySilent ifFalse:[
318
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   434
        '  ... loaded ' print. javaClass displayString printNL.
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
   435
    ].
27
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
   436
73
a1268823f1a4 *** empty log message ***
cg
parents: 72
diff changeset
   437
    ^ javaClass
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   438
318
8720093188f7 debugPrints
cg
parents: 278
diff changeset
   439
    "Created: / 15.4.1996 / 14:58:53 / cg"
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   440
    "Modified: / 9.5.1998 / 01:44:24 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   441
!
083530508d9c intitial checkin
cg
parents:
diff changeset
   442
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
   443
readStream:aStream
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
   444
    "reads a class from aStream and returns it.
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   445
     The JavaClass is installed as global.
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   446
     If new classes are required to be loaded, a new standard loader
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   447
     is created."
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
   448
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   449
    ^ self readStream:aStream loader:nil
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
   450
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   451
    "Modified: 14.8.1997 / 19:51:50 / cg"
198
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
   452
!
5543d1079a4a *** empty log message ***
cg
parents: 193
diff changeset
   453
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   454
readStream:aStream ignoring:classesBeingLoaded
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   455
    "reads a class from aStream and returns it.
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   456
     The JavaClass is not installed as global"
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   457
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   458
    |javaClass|
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   459
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   460
    javaClass :=  self new readStream:aStream ignoring:classesBeingLoaded.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   461
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   462
    AbsolutelySilent ifFalse:[
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   463
        '  ... loaded ' print. javaClass displayString printNL.
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   464
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   465
327
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   466
    ^ javaClass
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   467
990c71581df3 support reading from zip-archives
cg
parents: 318
diff changeset
   468
    "Modified: / 30.3.1998 / 18:14:40 / cg"
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   469
!
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   470
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   471
readStream:aStream loader:aClassLoader
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   472
    "reads a class from aStream and returns it.
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   473
     The JavaClass is installed as global.
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   474
     If new classes are required to be loaded, aClassLoader is
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   475
     asked to do it. If aClassLoader is nil, a new standard loader
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   476
     is created."
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   477
225
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   478
    ^ self
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   479
	readStream:aStream 
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   480
	loader:aClassLoader 
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   481
	loadUnresolved:true
225
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   482
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   483
    "Modified: 15.8.1997 / 01:00:35 / cg"
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   484
!
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   485
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   486
readStream:aStream loader:aClassLoader loadUnresolved:loadUnresolved
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   487
    "reads a class from aStream and returns it.
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   488
     The JavaClass is installed as global.
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   489
     If new classes are required to be loaded, aClassLoader is
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   490
     asked to do it. If aClassLoader is nil, a new standard loader
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   491
     is created."
b11dde7c1df2 more classLoader hooks
cg
parents: 223
diff changeset
   492
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   493
    |javaClass|
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   494
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   495
    ClassLoaderQuerySignal answer:aClassLoader
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   496
    do:[
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   497
        javaClass := self readStream:aStream ignoring:(Set new).
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   498
        javaClass notNil ifTrue:[
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   499
            self postLoadActions:loadUnresolved.
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   500
            Java at:(javaClass fullName asSymbol) put:javaClass.
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   501
            JavaUnresolvedConstant resolveFor:javaClass.
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   502
        ].
223
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   503
    ].
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   504
    ^ javaClass
4dd38bd4f6b2 allow trampoulining back into java for sub-loads
cg
parents: 219
diff changeset
   505
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   506
    "Created: / 15.8.1997 / 00:59:24 / cg"
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   507
    "Modified: / 23.1.1998 / 17:14:09 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   508
! !
083530508d9c intitial checkin
cg
parents:
diff changeset
   509
083530508d9c intitial checkin
cg
parents:
diff changeset
   510
!JavaClassReader methodsFor:'file reading'!
083530508d9c intitial checkin
cg
parents:
diff changeset
   511
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   512
readClassFileIgnoring:classesbeingLoaded
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   513
    "reads a class from inStream and returns it.
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   514
     The JavaClass is not installed as global and its constants
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   515
     (especially strings) may not be fully resolved."
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   516
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   517
    |magic 
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   518
     access_flags this_class this_class_index super_class super_class_index
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   519
     realSuperClass this_class_ref existingSuperClass
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   520
     fields interfaces staticFields nStatic
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   521
     jSuperClass loader superClassName thisClassName existing_class
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   522
     thisMetaClass|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   523
083530508d9c intitial checkin
cg
parents:
diff changeset
   524
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   525
    "/ read magic, determine byte order
083530508d9c intitial checkin
cg
parents:
diff changeset
   526
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   527
    msb := true.
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   528
    magic := inStream nextUnsignedLongMSB:true.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   529
    magic = (self class magic_MSB) ifFalse:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   530
        magic = (self class magic_LSB) ifFalse:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   531
            InvalidClassFormatSignal raiseErrorString:'not a java class file'.
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   532
            ^ nil
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   533
        ].
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   534
        msb := false.
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   535
        Verbose ifTrue:[Transcript showCR:'file is lsb'].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   536
    ] ifTrue:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   537
        Verbose ifTrue:[Transcript showCR:'file is msb'].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   538
    ].
083530508d9c intitial checkin
cg
parents:
diff changeset
   539
083530508d9c intitial checkin
cg
parents:
diff changeset
   540
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   541
    "/ get version
083530508d9c intitial checkin
cg
parents:
diff changeset
   542
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   543
    minorVsn := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   544
    majorVsn := inStream nextUnsignedShortMSB:msb.
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   545
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   546
    (majorVsn ~~ (self class fileMajorVersion) 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   547
    or:[minorVsn ~~ (self class fileMinorVersion)]) ifTrue:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   548
        Transcript show:'warning this file has version '; show:majorVsn; show:'.'; showCR:minorVsn. 
99
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
   549
    ].
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
   550
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
   551
    Verbose ifTrue:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   552
        Transcript show:'version = '; 
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   553
                   show:(majorVsn printString); 
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   554
                   show:'.';
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   555
                   showCR:(minorVsn printString).
99
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
   556
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   557
083530508d9c intitial checkin
cg
parents:
diff changeset
   558
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   559
    "/ get constant pool
083530508d9c intitial checkin
cg
parents:
diff changeset
   560
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   561
    self readConstantPool.
083530508d9c intitial checkin
cg
parents:
diff changeset
   562
083530508d9c intitial checkin
cg
parents:
diff changeset
   563
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   564
    "/ access flags
083530508d9c intitial checkin
cg
parents:
diff changeset
   565
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   566
    access_flags := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   567
    this_class_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   568
    super_class_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   569
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   570
    super_class_index == 0 ifTrue:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   571
        super_class := nil
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   572
    ] ifFalse:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   573
        super_class := constants at:super_class_index.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   574
        superClassName := super_class fullName.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   575
        
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   576
        "/ special for ST-classes
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   577
        (superClassName startsWith:'smalltalk.') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   578
            "/ a Smalltalk class
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   579
            superClassName := superClassName copyFrom:11.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   580
            existingSuperClass := Smalltalk at:superClassName asSymbol.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   581
            existingSuperClass notNil ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   582
                super_class := existingSuperClass
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   583
            ] ifFalse:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   584
                "/ self halt - must load superclass ...
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   585
            ]
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   586
        ] ifFalse:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   587
            "/ a JAVA class
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   588
            existingSuperClass := Java classNamed:superClassName.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   589
            existingSuperClass notNil ifTrue:[
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   590
                super_class := existingSuperClass
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   591
            ] ifFalse:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   592
                (super_class isMemberOf:JavaUnresolvedClassConstant) ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   593
                    Silent ifFalse:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   594
                        'load superClass: ' print. superClassName printCR.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   595
                    ].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   596
                    loader := ClassLoaderQuerySignal raise.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   597
                    loader isNil ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   598
                        existingSuperClass := self class 
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   599
                                            loadClassLazy:superClassName
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   600
                                            ignoring:classesbeingLoaded.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   601
                    ] ifFalse:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   602
                        jSuperClass := loader
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   603
                                    perform:#'loadClass(Ljava/lang/String;)Ljava/lang/Class;'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   604
                                    with:(Java as_String:superClassName).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   605
                        existingSuperClass := JavaVM classForJavaClassObject:jSuperClass.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   606
                    ].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   607
                    existingSuperClass isNil ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   608
                        self halt:('cannot find superclass: ' , superClassName).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   609
                    ].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   610
                    super_class := existingSuperClass
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   611
                ] ifFalse:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   612
                    self halt:'oops - superclass ?'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   613
                ]
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   614
            ].
269
5a946303d451 use a helper to associate java.lang.class insts to javaClasses
cg
parents: 264
diff changeset
   615
        ].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
   616
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   617
083530508d9c intitial checkin
cg
parents:
diff changeset
   618
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   619
    "/ get interfaces
083530508d9c intitial checkin
cg
parents:
diff changeset
   620
    "/
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   621
    interfaces := self readInterfaces.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   622
083530508d9c intitial checkin
cg
parents:
diff changeset
   623
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   624
    "/ get fields
083530508d9c intitial checkin
cg
parents:
diff changeset
   625
    "/
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   626
    fields := self readFieldInfofields.
40
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   627
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   628
    "/
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   629
    "/ create the fields as instVars
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   630
    "/ static fields are created as class-InstVars
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   631
    "/
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   632
    staticFields := fields select:[:f | f isStatic].
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   633
    nStatic := staticFields size.
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   634
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   635
    this_class_ref := constants at:this_class_index.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   636
    thisClassName := this_class_ref fullName.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   637
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   638
    "/ care for smalltalk classes ...
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   639
    (thisClassName startsWith:'smalltalk.') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   640
        thisClassName := thisClassName copyFrom:11.
182
5f85fd0fec56 checkin from browser
cg
parents: 177
diff changeset
   641
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   642
        existing_class := Smalltalk at:thisClassName asSymbol.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   643
        existing_class notNil ifTrue:[
355
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   644
            self halt:('overloading existing class: ', thisClassName).
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   645
            thisClassName := (thisClassName , '_new') asSymbol.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   646
        ].
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   647
        thisMetaClass := Metaclass new.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   648
        thisMetaClass setSuperclass:super_class class.
355
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   649
        thisMetaClass instSize:(super_class class instSize + nStatic).
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   650
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   651
        this_class := thisMetaClass new.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   652
        this_class setSuperclass:super_class.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   653
        this_class setName:thisClassName asSymbol.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   654
    ] ifFalse:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   655
        "/ a java class
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   656
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   657
        this_class := JavaClass fullName:thisClassName numStatic:nStatic.
40
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   658
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   659
        nStatic ~~ 0 ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   660
            fields := fields select:[:f | f isStatic not].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   661
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   662
            JavaClass setInstanceVariableStringFromFields:staticFields in:this_class class.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   663
            this_class setStaticFields:staticFields.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   664
            this_class initializeStaticFields.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   665
        ].
40
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   666
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   667
        this_class setAccessFlags:access_flags.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   668
        this_class setSuperclass:super_class.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   669
        this_class setConstantPool:constants.
40
7f332a95e015 checkin from browser
cg
parents: 39
diff changeset
   670
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   671
        this_class setFields:fields.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   672
        this_class setInterfaces:interfaces.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   673
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   674
        constants owner:this_class.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   675
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   676
083530508d9c intitial checkin
cg
parents:
diff changeset
   677
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
   678
    "/ get methods
083530508d9c intitial checkin
cg
parents:
diff changeset
   679
    "/
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   680
    self readMethodsFor:this_class.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   681
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   682
    self readAttributesFor:this_class.
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   683
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   684
    ^ this_class
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   685
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   686
    "
355
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   687
     JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   688
     JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   689
     JavaClassReader loadFile:'foo.cls'
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   690
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   691
     JavaClassReader verbose:true.
355
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   692
     JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/java/lang/ArithmeticException.class'
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   693
     JavaClassReader loadFile:'/phys/ibm3/java/lib/java/lang/ArithmeticException.class'
1
083530508d9c intitial checkin
cg
parents:
diff changeset
   694
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
   695
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   696
    "Created: / 15.4.1996 / 15:02:47 / cg"
355
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   697
    "Modified: / 13.5.1998 / 14:35:20 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   698
!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   699
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   700
readStream:aStream ignoring:classesBeingLoaded
7
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   701
    "reads a class from aStream and returns it.
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   702
     The JavaClass is not installed as global"
de8ce26e1f2c checkin from browser
cg
parents: 5
diff changeset
   703
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   704
    inStream := aStream.
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   705
    inStream binary.
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
   706
54
f37bcefb7091 avoid loading classes twice
cg
parents: 52
diff changeset
   707
    ^ self readClassFileIgnoring:classesBeingLoaded
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   708
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   709
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   710
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   711
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   712
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   713
    "Created: 15.4.1996 / 15:00:55 / cg"
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   714
    "Modified: 15.4.1996 / 15:06:18 / cg"
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   715
! !
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   716
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   717
!JavaClassReader methodsFor:'file reading - attributes'!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   718
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   719
readAttribute:attributeName for:something
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   720
    "/ implemented ST attributes
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   721
    (attributeName = 'STLiterals') ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   722
        self readSTLiteralsAttributeFor:something.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   723
        ^ self.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   724
    ].
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   725
    (attributeName = 'ClassRevision') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   726
        self readSTClassRevisionAttributeFor:something.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   727
        ^ self.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   728
    ].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   729
    (attributeName = 'ClassPackage') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   730
        self readSTClassPackageAttributeFor:something.
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
   731
        ^ self.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
   732
    ].
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   733
    (attributeName = 'ClassCategory') ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   734
        self readSTClassCategoryAttributeFor:something.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   735
        ^ self.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   736
    ].
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   737
    (attributeName = 'ClassVarNames') ifTrue:[
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   738
        self readSTClassVarNamesAttributeFor:something.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   739
        ^ self.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   740
    ].
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   741
    (attributeName = 'ClassInstVarNames') ifTrue:[
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   742
        self readSTClassInstVarNamesAttributeFor:something.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   743
        ^ self.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   744
    ].
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   745
    (attributeName = 'InstVarNames') ifTrue:[
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   746
        self readSTInstVarNamesAttributeFor:something.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   747
        ^ self.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   748
    ].
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   749
    (attributeName = 'STCode') ifTrue:[
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
   750
        self readSTCodeAttributeFor:something.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
   751
        ^ self.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
   752
    ].
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
   753
    (attributeName = 'MethodCategory') ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
   754
        self readSTMethodCategoryAttributeFor:something.
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   755
        ^ self.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   756
    ].
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
   757
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   758
    "/ implemented JAVA attributes
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   759
    (attributeName = 'Code') ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   760
        self readCodeAttributeFor:something.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   761
        ^ self.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   762
    ].
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
   763
    (attributeName = 'Exceptions') ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   764
        self readExceptionsAttributeFor:something.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   765
        ^ self.
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
   766
    ].
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   767
    (attributeName = 'LineNumberTable') ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   768
        self readLineNumberTableAttributeFor:something.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   769
        ^ self.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   770
    ].
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   771
    (attributeName = 'LocalVariableTable') ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   772
        self readLocalVariableTableAttributeFor:something.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   773
        ^ self.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   774
    ].
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   775
    (attributeName = 'ConstantValue') ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   776
        self readConstantValueAttributeFor:something.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   777
        ^ self.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   778
    ].
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   779
    (attributeName = 'SourceFile') ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   780
        self readSourceFileAttributeFor:something.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   781
        ^ self.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   782
    ].
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   783
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
   784
    "/ ignored JAVA attributes
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   785
    (attributeName = 'Deprecated') ifTrue:[
366
42a5f6d73925 checkin from browser
cg
parents: 365
diff changeset
   786
"/        ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR.
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   787
        self skipAttribute:attributeName.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   788
        ^ self.
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   789
    ].
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   790
    (attributeName = 'AbsoluteSourcePath') ifTrue:[
335
5309d0a795b1 checkin from browser
cg
parents: 333
diff changeset
   791
        ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR.
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   792
        self skipAttribute:attributeName.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   793
        ^ self.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   794
    ].
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   795
    (attributeName = 'Synthetic') ifTrue:[
335
5309d0a795b1 checkin from browser
cg
parents: 333
diff changeset
   796
        ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR.
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   797
        self skipAttribute:attributeName.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   798
        ^ self.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   799
    ].
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   800
    (attributeName = 'InnerClasses') ifTrue:[
335
5309d0a795b1 checkin from browser
cg
parents: 333
diff changeset
   801
        ('JAVA [info]: unhandled attribute: ' , attributeName) infoPrintCR.
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   802
        self skipAttribute:attributeName.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   803
        ^ self.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   804
    ].
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
   805
355
9452f8876652 *** empty log message ***
cg
parents: 353
diff changeset
   806
    "/ unknown attributes
335
5309d0a795b1 checkin from browser
cg
parents: 333
diff changeset
   807
    ('JAVA [warning]: unrecognized attribute: ' , attributeName) infoPrintCR.
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   808
    self skipAttribute:attributeName.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   809
366
42a5f6d73925 checkin from browser
cg
parents: 365
diff changeset
   810
    "Modified: / 20.8.1998 / 03:27:24 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   811
!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   812
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   813
readAttributeFor:something
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   814
    |attribute_name_index attribute_name attribute_length attribute_info|
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   815
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
   816
    Verbose ifTrue:[Transcript show:'attrib at pos: '; showCR:inStream position].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   817
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   818
    attribute_name_index := inStream nextUnsignedShortMSB:msb.
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   819
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   820
    "/
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   821
    "/ UNDOC feature ?
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   822
    "/
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   823
    attribute_name_index > constants size ifTrue:[
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   824
        attribute_name_index == 16rb700 ifTrue:[
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   825
            self halt.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   826
        ]
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   827
    ].
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   828
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   829
    attribute_name := constants at:attribute_name_index.
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   830
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
   831
    Verbose ifTrue:[Transcript show:'attrib name: '; showCR:attribute_name].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
   832
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   833
    self readAttribute:attribute_name for:something.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   834
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   835
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   836
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   837
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   838
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   839
    "Created: / 15.4.1996 / 15:40:17 / cg"
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   840
    "Modified: / 9.4.1998 / 18:13:34 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   841
!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   842
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   843
readAttributesFor:something
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   844
    |attributes_count|
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   845
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
   846
    attributes_count := inStream nextUnsignedShortMSB:msb.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   847
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   848
    1 to:attributes_count do:[:i |
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
   849
	self readAttributeFor:something.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   850
    ].
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   851
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   852
    "Modified: 15.4.1996 / 15:33:28 / cg"
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   853
    "Created: 15.4.1996 / 15:40:17 / cg"
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   854
!
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   855
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   856
readSourceFileAttributeFor:aClass
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   857
    |attribute_length sourceFile_index sourceFile|
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   858
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   859
    attribute_length := inStream nextUnsignedLongMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   860
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   861
    sourceFile_index := inStream nextUnsignedShortMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   862
    sourceFile := constants at:sourceFile_index.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   863
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   864
    aClass isJavaClass ifTrue:[
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   865
        aClass setSourceFile:sourceFile.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   866
    ] ifFalse:[
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   867
        aClass setClassFilename:sourceFile
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   868
    ].
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   869
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   870
    Verbose ifTrue:[Transcript show:'sourceFile: '; showCR:sourceFile].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   871
    ^ true
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   872
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   873
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   874
     JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   875
     JavaClassReader loadFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   876
     JavaClassReader loadFile:'foo.cls'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   877
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   878
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   879
    "Created: / 15.4.1996 / 15:40:17 / cg"
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   880
    "Modified: / 12.5.1998 / 22:01:07 / cg"
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   881
!
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   882
333
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   883
skipAttribute:attributeName
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   884
    "dont know about this attribute - skip it here"
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   885
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   886
    |attribute_length attribute_info|
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   887
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   888
    attribute_length := inStream nextUnsignedLongMSB:msb.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   889
    attribute_info := ByteArray new:(attribute_length).
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   890
    inStream nextBytes:attribute_length into:attribute_info startingAt:1.
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   891
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   892
    Verbose ifTrue:[Transcript show:'skipped '; show:attributeName; showCR:'-attribute'].
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   893
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   894
    "Created: / 9.4.1998 / 18:12:46 / cg"
1622ff2b686b checkin from browser
cg
parents: 330
diff changeset
   895
    "Modified: / 9.4.1998 / 18:13:20 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   896
! !
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
   897
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   898
!JavaClassReader methodsFor:'file reading - attributes-ST'!
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   899
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   900
readSTClassCategoryAttributeFor:aClass
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   901
    |attribute_length categoryString_index categoryString|
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   902
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   903
    attribute_length := inStream nextUnsignedLongMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   904
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   905
    categoryString_index := inStream nextUnsignedShortMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   906
    categoryString := constants at:categoryString_index.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   907
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   908
    aClass category:categoryString.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   909
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   910
    Verbose ifTrue:[Transcript show:'categoryString: '; showCR:categoryString].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   911
    ^ true
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   912
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   913
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   914
     JavaClassReader loadFile:'foo.cls'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   915
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   916
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   917
    "Created: / 9.5.1998 / 02:33:13 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   918
    "Modified: / 9.5.1998 / 02:36:55 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   919
!
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   920
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   921
readSTClassInstVarNamesAttributeFor:aClass
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   922
    |attribute_length nameString_index nameString|
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   923
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   924
    attribute_length := inStream nextUnsignedLongMSB:msb.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   925
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   926
    nameString_index := inStream nextUnsignedShortMSB:msb.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   927
    nameString := constants at:nameString_index.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   928
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   929
    aClass class instanceVariableString:nameString.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   930
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   931
    Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString].
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   932
    ^ true
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   933
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   934
    "
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   935
     JavaClassReader loadFile:'foo.cls'
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   936
    "
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   937
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   938
    "Modified: / 12.5.1998 / 22:18:03 / cg"
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   939
    "Created: / 12.5.1998 / 22:18:24 / cg"
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   940
!
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   941
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   942
readSTClassPackageAttributeFor:aClass
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   943
    |attribute_length packageString_index packageString|
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   944
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   945
    attribute_length := inStream nextUnsignedLongMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   946
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   947
    packageString_index := inStream nextUnsignedShortMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   948
    packageString := constants at:packageString_index.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   949
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   950
    aClass package:packageString asSymbol.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   951
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   952
    Verbose ifTrue:[Transcript show:'packageString: '; showCR:packageString].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   953
    ^ true
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   954
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   955
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   956
     JavaClassReader loadFile:'foo.cls'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   957
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   958
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   959
    "Modified: / 9.5.1998 / 02:32:38 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   960
    "Created: / 9.5.1998 / 02:33:44 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   961
!
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   962
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   963
readSTClassRevisionAttributeFor:aClass
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   964
    |attribute_length revisionString_index revisionString|
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   965
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   966
    attribute_length := inStream nextUnsignedLongMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   967
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   968
    revisionString_index := inStream nextUnsignedShortMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   969
    revisionString := constants at:revisionString_index.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   970
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   971
    aClass setBinaryRevision:revisionString.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   972
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   973
    Verbose ifTrue:[Transcript show:'revisionString: '; showCR:revisionString].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   974
    ^ true
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   975
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   976
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   977
     JavaClassReader loadFile:'foo.cls'
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   978
    "
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   979
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   980
    "Created: / 9.5.1998 / 02:33:13 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
   981
    "Modified: / 9.5.1998 / 02:35:01 / cg"
353
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   982
!
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   983
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   984
readSTClassVarNamesAttributeFor:aClass
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   985
    |attribute_length nameString_index nameString|
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   986
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   987
    attribute_length := inStream nextUnsignedLongMSB:msb.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   988
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   989
    nameString_index := inStream nextUnsignedShortMSB:msb.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   990
    nameString := constants at:nameString_index.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   991
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   992
    aClass classVariableString:nameString.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   993
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   994
    Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString].
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   995
    ^ true
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   996
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   997
    "
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   998
     JavaClassReader loadFile:'foo.cls'
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
   999
    "
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1000
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1001
    "Created: / 9.5.1998 / 02:33:13 / cg"
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1002
    "Modified: / 12.5.1998 / 22:18:03 / cg"
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1003
!
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1004
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1005
readSTInstVarNamesAttributeFor:aClass
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1006
    |attribute_length nameString_index nameString|
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1007
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1008
    attribute_length := inStream nextUnsignedLongMSB:msb.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1009
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1010
    nameString_index := inStream nextUnsignedShortMSB:msb.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1011
    nameString := constants at:nameString_index.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1012
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1013
    aClass setInstanceVariableString:nameString.
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1014
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1015
    Verbose ifTrue:[Transcript show:'nameString: '; showCR:nameString].
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1016
    ^ true
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1017
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1018
    "
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1019
     JavaClassReader loadFile:'foo.cls'
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1020
    "
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1021
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1022
    "Created: / 12.5.1998 / 22:18:14 / cg"
666b33cfc98f *** empty log message ***
cg
parents: 352
diff changeset
  1023
    "Modified: / 12.5.1998 / 22:21:10 / cg"
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1024
! !
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1025
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1026
!JavaClassReader methodsFor:'file reading - constants'!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1027
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1028
readConstant
083530508d9c intitial checkin
cg
parents:
diff changeset
  1029
    |tag constReader const|
083530508d9c intitial checkin
cg
parents:
diff changeset
  1030
083530508d9c intitial checkin
cg
parents:
diff changeset
  1031
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1032
    constNeeds2Slots := false.
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1033
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1034
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
  1035
    "/ get tag
083530508d9c intitial checkin
cg
parents:
diff changeset
  1036
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1037
    tag := inStream nextByte.
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1038
    Verbose ifTrue:[Transcript show:'tag = '; showCR:tag].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1039
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1040
    tag >= 250 ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1041
        constReader := #(
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1042
                        "/ ST types
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1043
                        readConstant_ST_Large           "/ 249
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1044
                        readConstant_ST_Special         "/ 250
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1045
                        readConstant_ST_Character       "/ 251
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1046
                        readConstant_ST_ByteArray       "/ 252
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1047
                        readConstant_ST_Array           "/ 253
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1048
                        readConstant_ST_Symbol          "/ 254
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1049
                        readConstant_ST_Reserved        "/ 255
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1050
                    ) at:tag-249+1.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1051
    ] ifFalse:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1052
        constReader := #(
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1053
                        "/ JAVA types
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1054
                        readConstant_Asciz              "/ 1  - now called Utf8
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1055
                        readConstant_Unicode            "/ 2
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1056
                        readConstant_Integer            "/ 3
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1057
                        readConstant_Float              "/ 4
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1058
                        readConstant_Long               "/ 5
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1059
                        readConstant_Double             "/ 6
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1060
                        readConstant_Class              "/ 7
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1061
                        readConstant_String             "/ 8
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1062
                        readConstant_Fieldref           "/ 9
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1063
                        readConstant_Methodref          "/ 10
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1064
                        readConstant_InterfaceMethodref "/ 11
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1065
                        readConstant_NameAndType        "/ 12
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1066
                    ) at:tag ifAbsent:[#readConstant_Undef].
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1067
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1068
    ^ self perform:constReader.
083530508d9c intitial checkin
cg
parents:
diff changeset
  1069
083530508d9c intitial checkin
cg
parents:
diff changeset
  1070
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1071
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1072
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1073
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1074
    "Created: / 15.4.1996 / 15:46:32 / cg"
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1075
    "Modified: / 9.5.1998 / 01:26:05 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1076
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1077
083530508d9c intitial checkin
cg
parents:
diff changeset
  1078
readConstantPool
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1079
    |constantPoolCount const i|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1080
083530508d9c intitial checkin
cg
parents:
diff changeset
  1081
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
  1082
    "/ get constant pool
083530508d9c intitial checkin
cg
parents:
diff changeset
  1083
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1084
    constantPoolCount := inStream nextUnsignedShortMSB:msb.
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1085
    Verbose ifTrue:[Transcript show:'constantPoolCount = '; showCR:constantPoolCount].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1086
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1087
    constants := JavaConstantPool "Array" new:constantPoolCount-1.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1088
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
  1089
    constSlot := 1.
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
  1090
    [constSlot < constantPoolCount] whileTrue:[
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1091
        Verbose ifTrue:[Transcript show:'const: '; showCR:constSlot].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1092
        const := self readConstant.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1093
        constants at:constSlot put:const.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1094
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1095
        "/ long & double consts take 2 slots
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1096
        "/ (only first is used)
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1097
        constNeeds2Slots ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1098
            constSlot := constSlot + 2.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1099
        ] ifFalse:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1100
            constSlot := constSlot + 1.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1101
        ]
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1102
    ].
083530508d9c intitial checkin
cg
parents:
diff changeset
  1103
52
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1104
    constSlot := -1.
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1105
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1106
    "/ preresolve what can be (especially, strings are resolved here)
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1107
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1108
    1 to:constantPoolCount-1 do:[:i |
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1109
        |const value|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1110
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1111
        const := constants at:i.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1112
        const notNil ifTrue:[   "/ kludge for 2-slot constants (which only take 1 slot in ST/X)
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1113
            (const isKindOf:JavaUnresolvedConstant) ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1114
                value := const preResolve.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1115
                value ~~ const ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1116
                    constants at:i put:value.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1117
                ]
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1118
            ]
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1119
        ]
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1120
    ].
083530508d9c intitial checkin
cg
parents:
diff changeset
  1121
083530508d9c intitial checkin
cg
parents:
diff changeset
  1122
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1123
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1124
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1125
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1126
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1127
    "Created: / 15.4.1996 / 15:14:11 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1128
    "Modified: / 7.5.1998 / 11:44:06 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1129
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1130
083530508d9c intitial checkin
cg
parents:
diff changeset
  1131
readConstant_Asciz
083530508d9c intitial checkin
cg
parents:
diff changeset
  1132
    |len string|
083530508d9c intitial checkin
cg
parents:
diff changeset
  1133
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1134
    len := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1135
    string := String new:len.
083530508d9c intitial checkin
cg
parents:
diff changeset
  1136
    inStream nextBytes:len into:string startingAt:1.
083530508d9c intitial checkin
cg
parents:
diff changeset
  1137
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1138
    Verbose ifTrue:[Transcript show:'asciz; string= ';     showCR:string].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1139
083530508d9c intitial checkin
cg
parents:
diff changeset
  1140
    ^ string
083530508d9c intitial checkin
cg
parents:
diff changeset
  1141
083530508d9c intitial checkin
cg
parents:
diff changeset
  1142
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1143
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1144
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1145
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1146
083530508d9c intitial checkin
cg
parents:
diff changeset
  1147
    "Created: 15.4.1996 / 15:15:35 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1148
    "Modified: 15.4.1996 / 16:33:45 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1149
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1150
083530508d9c intitial checkin
cg
parents:
diff changeset
  1151
readConstant_Class
52
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1152
    |name_index name|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1153
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1154
    name_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1155
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1156
    Verbose ifTrue:[Transcript show:'class; index= '; showCR:name_index].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1157
52
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1158
    name := constants at:name_index.
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1159
    name notNil ifTrue:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1160
        Verbose ifTrue:[Transcript showCR:'name in constant_class already resolved'].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1161
        "/ self halt
52
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1162
    ].
1dc41619b6f8 checkin from browser
cg
parents: 50
diff changeset
  1163
21
b9dd73f299dd checkin from browser
cg
parents: 14
diff changeset
  1164
    ^ JavaUnresolvedClassConstant 
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1165
        pool:constants
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1166
        poolIndex:constSlot
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1167
        nameIndex:name_index
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1168
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1169
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1170
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1171
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1172
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1173
    "Created: / 15.4.1996 / 15:21:13 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1174
    "Modified: / 8.5.1998 / 21:53:16 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1175
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1176
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1177
readConstant_Double
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1178
    |high low aFloat bytes|
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1179
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1180
"/ new code - to be tested
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1181
"/    bytes := ByteArray new:8.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1182
"/
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1183
"/    inStream nextBytes:8 into:bytes startingAt:1.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1184
"/    msb ~~ UninterpretedBytes isBigEndian ifTrue:[
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1185
"/        bytes reverse
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1186
"/    ].
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1187
"/    aFloat := bytes doubleAt:1.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1188
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1189
"/ old code
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1190
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1191
    high := inStream nextUnsignedLongMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1192
    low := inStream nextUnsignedLongMSB:msb.
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1193
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1194
    aFloat := Float new.
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1195
    UninterpretedBytes isBigEndian ifTrue:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1196
        aFloat basicAt:1 put:((high bitShift:-24) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1197
        aFloat basicAt:2 put:((high bitShift:-16) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1198
        aFloat basicAt:3 put:((high bitShift:-8) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1199
        aFloat basicAt:4 put:(high bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1200
        aFloat basicAt:5 put:((low bitShift:-24) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1201
        aFloat basicAt:6 put:((low bitShift:-16) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1202
        aFloat basicAt:7 put:((low bitShift:-8) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1203
        aFloat basicAt:8 put:(low bitAnd:16rFF).
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1204
    ] ifFalse:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1205
        aFloat basicAt:1 put:(low bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1206
        aFloat basicAt:2 put:((low bitShift:-8) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1207
        aFloat basicAt:3 put:((low bitShift:-16) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1208
        aFloat basicAt:4 put:((low bitShift:-24) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1209
        aFloat basicAt:5 put:(high bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1210
        aFloat basicAt:6 put:((high bitShift:-8) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1211
        aFloat basicAt:7 put:((high bitShift:-16) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1212
        aFloat basicAt:8 put:((high bitShift:-24) bitAnd:16rFF).
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1213
    ].
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1214
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1215
    constNeeds2Slots := true.
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1216
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1217
    Verbose ifTrue:[Transcript show:'double; value= ';     showCR:aFloat].
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1218
    ^ aFloat
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1219
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1220
    "
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1221
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1222
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1223
    "
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1224
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1225
    "Created: / 15.4.1996 / 16:34:42 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1226
    "Modified: / 8.5.1998 / 22:06:07 / cg"
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1227
!
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1228
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1229
readConstant_Fieldref
083530508d9c intitial checkin
cg
parents:
diff changeset
  1230
    |class_index name_and_type_index|
083530508d9c intitial checkin
cg
parents:
diff changeset
  1231
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1232
    class_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1233
    name_and_type_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1234
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1235
    Verbose ifTrue:[Transcript show:'fieldref; classindex= ';     showCR:class_index].
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1236
    Verbose ifTrue:[Transcript show:'fieldref; name&typeindex= '; showCR:name_and_type_index].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1237
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1238
    ^ JavaUnresolvedFieldrefConstant
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1239
		pool:constants
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1240
		poolIndex:constSlot
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1241
		classIndex:class_index
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1242
		nameandTypeIndex:name_and_type_index
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1243
083530508d9c intitial checkin
cg
parents:
diff changeset
  1244
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1245
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1246
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1247
083530508d9c intitial checkin
cg
parents:
diff changeset
  1248
    "Created: 15.4.1996 / 15:22:18 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1249
    "Modified: 15.4.1996 / 16:07:01 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1250
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1251
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1252
readConstant_Float
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1253
    |high aFloat bytes|
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1254
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1255
"/ new code - to be tested ...
352
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1256
"/
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1257
"/    bytes := ByteArray new:4.
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1258
"/    inStream nextBytes:4 into:bytes startingAt:1.
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1259
"/    msb ~~ UninterpretedBytes isBigEndian ifTrue:[
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1260
"/        bytes reverse
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1261
"/    ].
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1262
"/    aFloat := bytes floatAt:1.
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1263
"/    Verbose ifTrue:[Transcript show:'float; value= ';     showCR:aFloat].
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1264
"/    ^ aFloat.
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1265
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1266
"/ old code
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1267
    high := inStream nextUnsignedLongMSB:msb.
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1268
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1269
    aFloat := ShortFloat basicNew.
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1270
    UninterpretedBytes isBigEndian ifTrue:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1271
        aFloat basicAt:1 put:((high bitShift:-24) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1272
        aFloat basicAt:2 put:((high bitShift:-16) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1273
        aFloat basicAt:3 put:((high bitShift:-8) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1274
        aFloat basicAt:4 put:(high bitAnd:16rFF).
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1275
    ] ifFalse:[
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1276
        aFloat basicAt:1 put:(high bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1277
        aFloat basicAt:2 put:((high bitShift:-8) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1278
        aFloat basicAt:3 put:((high bitShift:-16) bitAnd:16rFF).
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1279
        aFloat basicAt:4 put:((high bitShift:-24) bitAnd:16rFF).
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1280
    ].
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1281
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1282
    Verbose ifTrue:[Transcript show:'float; value= ';     showCR:aFloat].
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1283
    ^ aFloat
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1284
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1285
    "
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1286
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1287
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1288
    "
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1289
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1290
    "Created: / 15.4.1996 / 16:34:42 / cg"
352
9093171ef0a6 oops - float reading
cg
parents: 350
diff changeset
  1291
    "Modified: / 12.5.1998 / 21:36:32 / cg"
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1292
!
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1293
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1294
readConstant_Integer
083530508d9c intitial checkin
cg
parents:
diff changeset
  1295
    |value|
083530508d9c intitial checkin
cg
parents:
diff changeset
  1296
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1297
    value := inStream nextLongMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1298
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1299
    Verbose ifTrue:[Transcript show:'integer; value= ';     showCR:value].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1300
083530508d9c intitial checkin
cg
parents:
diff changeset
  1301
    ^ value
083530508d9c intitial checkin
cg
parents:
diff changeset
  1302
083530508d9c intitial checkin
cg
parents:
diff changeset
  1303
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1304
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1305
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1306
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1307
083530508d9c intitial checkin
cg
parents:
diff changeset
  1308
    "Modified: 15.4.1996 / 15:42:16 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1309
    "Created: 15.4.1996 / 16:34:42 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1310
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1311
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1312
readConstant_InterfaceMethodref
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1313
    |class_index name_and_type_index|
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1314
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1315
    class_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1316
    name_and_type_index := inStream nextUnsignedShortMSB:msb.
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1317
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1318
    Verbose ifTrue:[Transcript show:'methodref; classindex= ';     showCR:class_index].
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1319
    Verbose ifTrue:[Transcript show:'methodref; name&typeindex= '; showCR:name_and_type_index].
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1320
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1321
    ^ JavaUnresolvedInterfaceMethodrefConstant 
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1322
		pool:constants
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1323
		poolIndex:constSlot
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1324
		classIndex:class_index
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1325
		nameandTypeIndex:name_and_type_index
14
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1326
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1327
    "
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1328
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1329
    "
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1330
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1331
    "Created: 15.4.1996 / 15:22:37 / cg"
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1332
    "Modified: 15.4.1996 / 16:07:19 / cg"
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1333
!
c1d9f60eb650 can now load all java.class files (see JavaClassReader>>loadFile:)
cg
parents: 11
diff changeset
  1334
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1335
readConstant_Long
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1336
    |high low value|
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1337
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1338
    high := inStream nextUnsignedLongMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1339
    low := inStream nextUnsignedLongMSB:msb.
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1340
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1341
    value := (high bitShift:32) bitOr:low.
60
a763b1780ec0 checkin from browser
cg
parents: 59
diff changeset
  1342
    (high bitTest:16r80000000) ifTrue:[
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1343
	value := value - 16r10000000000000000.
60
a763b1780ec0 checkin from browser
cg
parents: 59
diff changeset
  1344
    ].
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1345
    constNeeds2Slots := true.
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1346
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1347
    Verbose ifTrue:[Transcript show:'long; value= ';     showCR:value].
11
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1348
    ^ value
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1349
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1350
    "
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1351
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1352
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1353
    "
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1354
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1355
    "Modified: 15.4.1996 / 15:42:16 / cg"
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1356
    "Created: 15.4.1996 / 16:34:42 / cg"
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1357
!
30997f6943a4 checkin from browser
cg
parents: 9
diff changeset
  1358
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1359
readConstant_Methodref
083530508d9c intitial checkin
cg
parents:
diff changeset
  1360
    |class_index name_and_type_index|
083530508d9c intitial checkin
cg
parents:
diff changeset
  1361
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1362
    class_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1363
    name_and_type_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1364
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1365
    Verbose ifTrue:[Transcript show:'methodref; classindex= ';     showCR:class_index].
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1366
    Verbose ifTrue:[Transcript show:'methodref; name&typeindex= '; showCR:name_and_type_index].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1367
083530508d9c intitial checkin
cg
parents:
diff changeset
  1368
    ^ JavaUnresolvedMethodrefConstant 
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1369
		pool:constants
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1370
		poolIndex:constSlot
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1371
		classIndex:class_index
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1372
		nameandTypeIndex:name_and_type_index
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1373
083530508d9c intitial checkin
cg
parents:
diff changeset
  1374
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1375
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1376
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1377
083530508d9c intitial checkin
cg
parents:
diff changeset
  1378
    "Created: 15.4.1996 / 15:22:37 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1379
    "Modified: 15.4.1996 / 16:07:19 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1380
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1381
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1382
readConstant_NameAndType
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1383
    |name_index signature_index|
083530508d9c intitial checkin
cg
parents:
diff changeset
  1384
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1385
    name_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1386
    signature_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1387
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1388
    Verbose ifTrue:[Transcript show:'methodref; nameindex= ';     showCR:name_index].
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1389
    Verbose ifTrue:[Transcript show:'methodref; signatureindex= '; showCR:signature_index].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1390
083530508d9c intitial checkin
cg
parents:
diff changeset
  1391
    ^ JavaUnresolvedNameandTypeConstant 
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1392
		pool:constants
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1393
		poolIndex:constSlot
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1394
		nameIndex:name_index
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1395
		signatureIndex:signature_index  
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1396
083530508d9c intitial checkin
cg
parents:
diff changeset
  1397
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1398
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1399
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1400
083530508d9c intitial checkin
cg
parents:
diff changeset
  1401
    "Created: 15.4.1996 / 15:23:43 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1402
    "Modified: 15.4.1996 / 16:17:16 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1403
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1404
083530508d9c intitial checkin
cg
parents:
diff changeset
  1405
readConstant_String
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1406
    |tag string_index chars jString|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1407
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1408
    string_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1409
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1410
    Verbose ifTrue:[Transcript show:'string; index= '; showCR:string_index].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1411
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1412
    "/ resolve here if possible
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1413
    string_index < constSlot ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1414
        Java java_lang_String notNil ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1415
            chars := (constants at:string_index).
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1416
            chars isString ifFalse:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1417
                self halt:'should not happen'
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1418
            ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1419
            jString := Java as_String:chars.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1420
            ^ jString.        
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1421
        ]
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1422
    ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1423
91
9b325648aa77 resolve rewritten; interpreter fixes
cg
parents: 86
diff changeset
  1424
    ^ JavaUnresolvedStringConstant 
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1425
        pool:constants 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1426
        poolIndex:constSlot
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1427
        stringIndex:string_index
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1428
083530508d9c intitial checkin
cg
parents:
diff changeset
  1429
    "
43
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
  1430
     Verbose := true.
2c4ca2eb8d07 checkin from browser
cg
parents: 40
diff changeset
  1431
     JavaClassReader readFile:'/phys/ibm3/java/lib/java/lang/System.class'
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1432
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1433
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1434
    "Created: / 15.4.1996 / 15:20:33 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1435
    "Modified: / 7.5.1998 / 11:42:45 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1436
! !
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1437
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1438
!JavaClassReader methodsFor:'file reading - constants-ST'!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1439
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1440
readConstant_ST_Array
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1441
    |aSize arr|
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1442
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1443
    aSize := inStream nextUnsignedShortMSB:msb.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1444
    arr := Array new:aSize.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1445
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1446
    1 to:aSize do:[:i |
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1447
        |element_index element|
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1448
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1449
        element_index := inStream nextUnsignedShortMSB:msb.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1450
        arr at:i put:element_index.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1451
    ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1452
    Verbose ifTrue:[Transcript show:'array; size= ';     showCR:aSize].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1453
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1454
    ^ JavaUnresolvedSTArrayConstant 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1455
                pool:constants
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1456
                poolIndex:constSlot
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1457
                array:arr
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1458
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1459
    "Created: / 7.5.1998 / 11:47:01 / cg"
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1460
    "Modified: / 9.5.1998 / 00:25:34 / cg"
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1461
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1462
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1463
readConstant_ST_ByteArray
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1464
    |aSize arr|
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1465
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1466
    aSize := inStream nextUnsignedShortMSB:msb.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1467
    arr := ByteArray new:aSize.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1468
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1469
    1 to:aSize do:[:i |
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1470
        |element_index|
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1471
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1472
        arr at:i put:(inStream nextByte).
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1473
    ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1474
    Verbose ifTrue:[Transcript show:'byteArray; size= ';     showCR:aSize].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1475
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1476
    ^ arr
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1477
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1478
    "Created: / 7.5.1998 / 11:47:12 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1479
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1480
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1481
readConstant_ST_Character
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1482
    |ascii|
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1483
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1484
    ascii := inStream nextUnsignedShortMSB:msb.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1485
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1486
    Verbose ifTrue:[Transcript show:'char; ascii= '; showCR:ascii].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1487
    ^ Character value:ascii
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1488
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1489
    "Created: / 7.5.1998 / 11:48:12 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1490
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1491
350
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1492
readConstant_ST_Special
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1493
    |type|
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1494
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1495
    type := inStream nextUnsignedShortMSB:msb.
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1496
    ^ #(
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1497
        nil
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1498
        true
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1499
        false
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1500
     ) at:(type + 1)
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1501
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1502
    "Created: / 8.5.1998 / 23:06:56 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1503
    "Modified: / 9.5.1998 / 00:40:14 / cg"
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1504
!
bf3f92fb2629 support for ST-classes
cg
parents: 348
diff changeset
  1505
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1506
readConstant_ST_String
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1507
    |tag string_index chars|
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1508
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1509
    string_index := inStream nextUnsignedShortMSB:msb.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1510
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1511
    Verbose ifTrue:[Transcript show:'string; index= '; showCR:string_index].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1512
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1513
    "/ resolve here if possible
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1514
    string_index < constSlot ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1515
        chars := (constants at:string_index).
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1516
        ^ chars
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1517
    ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1518
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1519
    ^ JavaUnresolvedSTStringConstant 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1520
        pool:constants 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1521
        poolIndex:constSlot
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1522
        stringIndex:string_index
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1523
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1524
    "Modified: / 7.5.1998 / 11:48:28 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1525
    "Created: / 7.5.1998 / 11:49:55 / cg"
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1526
!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1527
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1528
readConstant_ST_Symbol
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1529
    |tag string_index chars|
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1530
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1531
    string_index := inStream nextUnsignedShortMSB:msb.
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1532
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1533
    Verbose ifTrue:[Transcript show:'symbol; index= '; showCR:string_index].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1534
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1535
    "/ resolve here if possible
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1536
    string_index < constSlot ifTrue:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1537
        chars := (constants at:string_index).
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1538
        chars isString ifFalse:[
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1539
            self halt:'should not happen'
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1540
        ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1541
        ^ chars asSymbol
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1542
    ].
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1543
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1544
    ^ JavaUnresolvedSTSymbolConstant 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1545
        pool:constants 
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1546
        poolIndex:constSlot
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1547
        stringIndex:string_index
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1548
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1549
    "Modified: / 7.5.1998 / 11:48:28 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1550
! !
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1551
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1552
!JavaClassReader methodsFor:'file reading - fields'!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1553
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1554
readConstantValueAttributeFor:aField
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1555
    |attribute_length constantvalue_index constantValue|
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1556
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1557
    attribute_length := inStream nextUnsignedLongMSB:msb.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1558
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1559
    constantvalue_index := inStream nextUnsignedShortMSB:msb.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1560
    constantValue := constants at:constantvalue_index.
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1561
59
38114c3e3e77 checkin from browser
cg
parents: 54
diff changeset
  1562
    aField constantValue:constantValue.
38114c3e3e77 checkin from browser
cg
parents: 54
diff changeset
  1563
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1564
    Verbose ifTrue:[Transcript show:'constantValue: '; showCR:constantValue].
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1565
    ^ true
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1566
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1567
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1568
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1569
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1570
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1571
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1572
    "Modified: 15.4.1996 / 15:33:28 / cg"
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1573
    "Created: 15.4.1996 / 15:40:17 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1574
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1575
083530508d9c intitial checkin
cg
parents:
diff changeset
  1576
readFieldInfofield
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1577
    |access_flags name_index signature_index attributes_count field|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1578
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1579
    access_flags := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1580
    name_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1581
    signature_index := inStream nextUnsignedShortMSB:msb.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1582
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1583
    field := JavaField new.
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1584
    field setAccessFlags:access_flags.
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1585
    field setName:(constants at:name_index).
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1586
    field setSignature:(constants at:signature_index).
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1587
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1588
    attributes_count := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1589
99
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
  1590
    Verbose ifTrue:[Transcript show:'  field name: '; show:(constants at:name_index);
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1591
			       show:' access: '; show:access_flags;
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1592
			       show:' attrib_cnt: '; showCR:attributes_count].
99
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
  1593
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1594
    1 to:attributes_count do:[:i |
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1595
	self readAttributeFor:field.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1596
    ].
083530508d9c intitial checkin
cg
parents:
diff changeset
  1597
27
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
  1598
    ^ field
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
  1599
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1600
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1601
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1602
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1603
083530508d9c intitial checkin
cg
parents:
diff changeset
  1604
    "Modified: 15.4.1996 / 15:33:28 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1605
    "Created: 15.4.1996 / 15:38:43 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1606
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1607
083530508d9c intitial checkin
cg
parents:
diff changeset
  1608
readFieldInfofields
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1609
    |nFields fields|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1610
083530508d9c intitial checkin
cg
parents:
diff changeset
  1611
    "/
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1612
    "/ get fieldInfos
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1613
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1614
    nFields := inStream nextUnsignedShortMSB:msb.
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1615
    Verbose ifTrue:[Transcript show:'fieldsCount = '; showCR:nFields].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1616
27
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
  1617
    fields := Array new:nFields.
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
  1618
4560bb77bb36 checkin from browser
cg
parents: 21
diff changeset
  1619
    1 to:nFields do:[:i |
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1620
	Verbose ifTrue:[Transcript show:'field: '; showCR:i].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1621
	fields at:i put:(self readFieldInfofield)
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1622
    ].
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1623
    ^ fields
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1624
083530508d9c intitial checkin
cg
parents:
diff changeset
  1625
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1626
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1627
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1628
083530508d9c intitial checkin
cg
parents:
diff changeset
  1629
    "Created: 15.4.1996 / 15:34:41 / cg"
083530508d9c intitial checkin
cg
parents:
diff changeset
  1630
    "Modified: 15.4.1996 / 15:35:28 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1631
! !
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1632
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1633
!JavaClassReader methodsFor:'file reading - interfaces'!
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1634
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1635
readInterfaces
110
dfb03e2ea321 *** empty log message ***
cg
parents: 104
diff changeset
  1636
    |interfacesCount interface_index interface interfaces|
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1637
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1638
    "/
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1639
    "/ get interfaces
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1640
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1641
    interfacesCount := inStream nextUnsignedShortMSB:msb.
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1642
    Verbose ifTrue:[Transcript show:'interfacesCount = '; showCR:interfacesCount].
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1643
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1644
    interfaces := Array new:interfacesCount.
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1645
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1646
    1 to:interfacesCount do:[:i |
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1647
	Verbose ifTrue:[Transcript show:'interface: '; showCR:i].
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1648
	interface_index := inStream nextUnsignedShortMSB:msb.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1649
	interface := constants at:interface_index.
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1650
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1651
	interfaces at:i put:interface.
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1652
    ].
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1653
    ^ interfaces
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1654
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1655
    "
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1656
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1657
    "
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1658
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1659
    "Created: 15.4.1996 / 15:31:59 / cg"
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1660
    "Modified: 15.4.1996 / 15:33:28 / cg"
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1661
! !
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1662
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1663
!JavaClassReader methodsFor:'file reading - methods'!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1664
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1665
readCodeAttributeFor:aJavaMethod
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1666
    |attribute_length max_stack max_locals code_length code
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1667
     exception_table_length exception_table unknown1 unknown2|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1668
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1669
    attribute_length := inStream nextUnsignedLongMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1670
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1671
    Verbose ifTrue:[Transcript show:'code_attribute_length: 0x'; showCR:(attribute_length printStringRadix:16)].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1672
99
d1248315f589 support vsn 45.2 AND 45.3 classFile formats
cg
parents: 97
diff changeset
  1673
    minorVsn > 2 ifTrue:[
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1674
        "/ should be:
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1675
        max_stack := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1676
        max_locals := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1677
        code_length := inStream nextUnsignedLongMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1678
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1679
"/        unknown1 := inStream nextByte.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1680
"/        max_stack := inStream nextByte.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1681
"/        max_locals := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1682
"/        unknown2 := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1683
"/        code_length := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1684
"/        Verbose ifTrue:[Transcript show:'?1: '; showCR:unknown1].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1685
"/        Verbose ifTrue:[Transcript show:'?2: '; showCR:unknown2].
39
20fa5af3b873 checkin from browser
cg
parents: 38
diff changeset
  1686
    ] ifFalse:[
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1687
        max_stack := inStream nextByte.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1688
        max_locals := inStream nextByte.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1689
        code_length := inStream nextUnsignedShortMSB:msb.
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1690
    ].
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1691
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1692
    Verbose ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1693
        Transcript show:'code_length: '; showCR:(code_length printStringRadix:16).
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1694
        Transcript show:'code at pos: '; showCR:inStream position
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1695
    ].
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1696
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1697
    code_length ~~ 0 ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1698
        code := ByteArray new:code_length.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1699
        inStream nextBytes:code_length into:code startingAt:1.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1700
    ].
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1701
    Verbose ifTrue:[Transcript show:'method code: '; showCR:code.].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1702
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1703
    exception_table_length := inStream nextUnsignedShortMSB:msb.
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1704
    Verbose ifTrue:[Transcript show:'exception_table_length: '; showCR:(exception_table_length printStringRadix:16)].
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1705
    exception_table_length ~~ 0 ifTrue:[
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1706
        Verbose ifTrue:[Transcript show:'exceptionTable length:'; showCR:exception_table_length.].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1707
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1708
        exception_table := Array new:exception_table_length.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1709
        1 to:exception_table_length do:[:i |
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1710
            |start_pc end_pc handler_pc catch_type|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1711
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1712
            start_pc := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1713
            end_pc := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1714
            handler_pc := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1715
            catch_type := constants at:(inStream nextUnsignedShortMSB:msb).
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1716
            exception_table at:i put:(JavaExceptionTableEntry
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1717
                                            startPC:start_pc
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1718
                                            endPC:end_pc
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1719
                                            handlerPC:handler_pc
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1720
                                            catchType:catch_type).
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1721
        ].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1722
        aJavaMethod setExceptionHandlerTable:exception_table.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1723
    ].
083530508d9c intitial checkin
cg
parents:
diff changeset
  1724
29
eb3367f8fb9b checkin from browser
cg
parents: 27
diff changeset
  1725
    aJavaMethod 
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1726
        setCode:code 
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1727
        maxStack:max_stack 
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1728
        maxLocals:max_locals 
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1729
        u1:unknown1 
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1730
        u2:unknown2.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1731
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1732
    self readAttributesFor:aJavaMethod.
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1733
    ^ true
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1734
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1735
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1736
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1737
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/Alignable.class'
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1738
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1739
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1740
    "Created: / 15.4.1996 / 15:40:17 / cg"
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1741
    "Modified: / 16.5.1998 / 01:39:42 / cg"
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1742
!
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1743
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1744
readExceptionsAttributeFor:aJavaMethod
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1745
    |attribute_length exception_table_length exception_table|
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1746
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1747
    attribute_length := inStream nextUnsignedLongMSB:msb.
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1748
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1749
    exception_table_length := inStream nextUnsignedShortMSB:msb.
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1750
    exception_table_length ~~ 0 ifTrue:[
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1751
	exception_table := Array new:exception_table_length.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1752
	1 to:exception_table_length do:[:i |
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1753
	    |idx ex|
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1754
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1755
	    idx := inStream nextUnsignedShortMSB:msb.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1756
	    ex := constants at:idx.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1757
	    exception_table at:i put:ex.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1758
	].
83
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1759
    ].
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1760
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1761
    Verbose ifTrue:[Transcript showCR:'method has an exceptionTable'].
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1762
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1763
    aJavaMethod setExceptionTable:exception_table.
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1764
    ^ true
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1765
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1766
    "Modified: 15.4.1996 / 15:33:28 / cg"
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1767
    "Created: 15.4.1996 / 15:40:17 / cg"
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1768
!
2d61ef3579e4 *** empty log message ***
cg
parents: 73
diff changeset
  1769
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1770
readLineNumberTableAttributeFor:aJavaMethod
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1771
    |attribute_length line_number_table_length line_number_table|
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1772
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1773
    attribute_length := inStream nextUnsignedLongMSB:msb.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1774
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1775
    line_number_table_length := inStream nextUnsignedShortMSB:msb.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1776
    line_number_table_length ~~ 0 ifTrue:[
330
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1777
        line_number_table := Array new:line_number_table_length.
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1778
        1 to:line_number_table_length do:[:i |
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1779
            |start_pc line_number|
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1780
330
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1781
            start_pc := inStream nextUnsignedShortMSB:msb.
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1782
            line_number := inStream nextUnsignedShortMSB:msb.
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1783
            line_number_table at:i put:(start_pc -> line_number).
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1784
        ].
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1785
        Verbose ifTrue:[Transcript showCR:'method has a lineNumberTable'].
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1786
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1787
        aJavaMethod setLineNumberTable:line_number_table.
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1788
    ].
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1789
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1790
    ^ true
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1791
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1792
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1793
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1794
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/java/lang/Boolean.class'
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1795
    "
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1796
330
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1797
    "Created: / 15.4.1996 / 15:40:17 / cg"
c452e536a822 checkin from browser
cg
parents: 327
diff changeset
  1798
    "Modified: / 7.4.1998 / 19:08:42 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1799
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1800
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1801
readLocalVariableTableAttributeFor:aJavaMethod
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1802
    |attribute_length local_variable_table_length local_variable_table|
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1803
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1804
    attribute_length := inStream nextUnsignedLongMSB:msb.
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1805
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1806
    local_variable_table_length := inStream nextUnsignedShortMSB:msb.
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1807
    local_variable_table_length ~~ 0 ifTrue:[
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1808
	local_variable_table := JavaLocalVariableTable new:local_variable_table_length.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1809
	1 to:local_variable_table_length do:[:i |
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1810
	    |start_pc length name_index sig_index slot name signature|
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1811
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1812
	    start_pc := inStream nextUnsignedShortMSB:msb.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1813
	    length := inStream nextUnsignedShortMSB:msb.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1814
	    name_index := inStream nextUnsignedShortMSB:msb.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1815
	    name := constants at:name_index.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1816
	    sig_index := inStream nextUnsignedShortMSB:msb.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1817
	    signature := constants at:sig_index.
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1818
	    slot := inStream nextUnsignedShortMSB:msb.
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1819
252
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1820
	    local_variable_table at:i put:(JavaLocalVariableTableEntry new 
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1821
						startPC:start_pc 
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1822
						length:length
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1823
						name:name
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1824
						signature:signature
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1825
						slot:slot)
04b330744577 new javaVM stuff & back to pre-stefans changes
cg
parents: 229
diff changeset
  1826
	].
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1827
    ].
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1828
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1829
    Verbose ifTrue:[Transcript showCR:'method has a localvariableTable'].
50
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1830
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1831
    aJavaMethod setLocalVariableTable:local_variable_table.
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1832
    ^ true
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1833
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1834
    "
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1835
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1836
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/java/lang/Boolean.class'
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1837
    "
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1838
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1839
    "Modified: 15.4.1996 / 15:33:28 / cg"
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1840
    "Created: 15.4.1996 / 15:40:17 / cg"
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1841
!
458467ce0e15 checkin from browser
cg
parents: 43
diff changeset
  1842
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1843
readMethodFor:aClass
273
bcbea5ac4860 checkin from browser
cg
parents: 269
diff changeset
  1844
    |m access_flags name_index name signature_index signature
bcbea5ac4860 checkin from browser
cg
parents: 269
diff changeset
  1845
     tooManyArgs|
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1846
083530508d9c intitial checkin
cg
parents:
diff changeset
  1847
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
  1848
    "/ get a method
083530508d9c intitial checkin
cg
parents:
diff changeset
  1849
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1850
    access_flags := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1851
    name_index := inStream nextUnsignedShortMSB:msb.
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1852
    signature_index := inStream nextUnsignedShortMSB:msb.
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1853
5
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1854
    name := constants at:name_index.
f026f5d20c15 checkin from browser
cg
parents: 3
diff changeset
  1855
    signature := constants at:signature_index.
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1856
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1857
    Verbose ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1858
        Transcript show:'method name:'; showCR:name.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1859
        Transcript show:'signature:'; showCR:signature.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1860
    ].
9
bc65152d7610 can no read (undoc) 3.45 format
cg
parents: 7
diff changeset
  1861
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1862
    aClass isJavaClass ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1863
        m := JavaMethod new.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1864
        m setAccessFlags:access_flags.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1865
        tooManyArgs := false.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1866
        Method argumentSignal handle:[:ex |
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1867
            'JAVA: ***** java method has too many arguments - will fail to execute' infoPrintCR.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1868
            tooManyArgs := true.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1869
            ex proceed.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1870
        ] do:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1871
            m setName:name signature:signature.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1872
        ].
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1873
        m setJavaClass:aClass.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1874
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1875
        self readAttributesFor:m.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1876
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1877
        tooManyArgs ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1878
            m code:nil.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1879
            m byteCode:nil.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1880
        ].
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1881
        aClass addMethod:m name:name signature:signature.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1882
    ] ifFalse:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1883
        m := Method new.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1884
        self readAttributesFor:m.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1885
        (access_flags bitTest:JavaMethod A_STATIC) ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1886
            aClass class primAddSelector:name asSymbol withMethod:m.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1887
        ] ifFalse:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1888
            aClass primAddSelector:name asSymbol withMethod:m.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1889
        ]
273
bcbea5ac4860 checkin from browser
cg
parents: 269
diff changeset
  1890
    ].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1891
083530508d9c intitial checkin
cg
parents:
diff changeset
  1892
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1893
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1894
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1895
273
bcbea5ac4860 checkin from browser
cg
parents: 269
diff changeset
  1896
    "Created: / 15.4.1996 / 16:48:49 / cg"
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1897
    "Modified: / 16.5.1998 / 00:39:57 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1898
!
083530508d9c intitial checkin
cg
parents:
diff changeset
  1899
38
3f1b61722466 checkin from browser
cg
parents: 32
diff changeset
  1900
readMethodsFor:aJavaClass
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1901
    |methodsCount method|
083530508d9c intitial checkin
cg
parents:
diff changeset
  1902
083530508d9c intitial checkin
cg
parents:
diff changeset
  1903
    "/
083530508d9c intitial checkin
cg
parents:
diff changeset
  1904
    "/ get methods
083530508d9c intitial checkin
cg
parents:
diff changeset
  1905
    "/
128
acc4e8e77092 *** empty log message ***
cg
parents: 122
diff changeset
  1906
    methodsCount := inStream nextUnsignedShortMSB:msb.
61
ff1579eb825f showCr: -> showCR:
cg
parents: 60
diff changeset
  1907
    Verbose ifTrue:[Transcript show:'methodsCount = '; showCR:methodsCount].
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1908
083530508d9c intitial checkin
cg
parents:
diff changeset
  1909
    1 to:methodsCount do:[:i |
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1910
        Verbose ifTrue:[Transcript show:'method: '; showCR:i].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1911
        method := self readMethodFor:aJavaClass
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1912
    ].
083530508d9c intitial checkin
cg
parents:
diff changeset
  1913
083530508d9c intitial checkin
cg
parents:
diff changeset
  1914
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1915
     JavaClassReader readFile:'/phys/ibm3/hotjava/classes/browser/AddButton.class'
083530508d9c intitial checkin
cg
parents:
diff changeset
  1916
    "
083530508d9c intitial checkin
cg
parents:
diff changeset
  1917
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1918
    "Created: / 15.4.1996 / 16:46:30 / cg"
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1919
    "Modified: / 8.5.1998 / 21:20:59 / cg"
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  1920
! !
083530508d9c intitial checkin
cg
parents:
diff changeset
  1921
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1922
!JavaClassReader methodsFor:'file reading - methods-ST'!
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1923
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1924
readSTCodeAttributeFor:aSmalltalkMethod
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1925
    |attribute_length max_stack max_locals code_length code
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1926
     exception_table_length unknown1 unknown2|
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1927
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1928
    attribute_length := inStream nextUnsignedLongMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1929
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1930
    Verbose ifTrue:[Transcript show:'attribute_length: 0x'; showCR:(attribute_length printStringRadix:16)].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1931
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1932
    max_stack := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1933
    max_locals := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1934
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1935
    code_length := inStream nextUnsignedLongMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1936
    Verbose ifTrue:[Transcript show:'code_length: '; showCR:(code_length printStringRadix:16)].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1937
    Verbose ifTrue:[Transcript show:'code at pos: '; showCR:inStream position].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1938
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1939
    code_length ~~ 0 ifTrue:[
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1940
        code := ByteArray new:code_length.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1941
        inStream nextBytes:code_length into:code startingAt:1.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1942
    ].
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1943
    Verbose ifTrue:[Transcript show:'method code: '; showCR:code.].
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1944
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1945
    exception_table_length := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1946
    Verbose ifTrue:[Transcript show:'exception_table_length: '; showCR:(exception_table_length printStringRadix:16)].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1947
    exception_table_length ~~ 0 ifTrue:[
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1948
        self error:'unexpected exceptionTable length'.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1949
        "/ skip it.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1950
        1 to:exception_table_length do:[:i |
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1951
            "start_pc :="   inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1952
            "end_pc :="     inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1953
            "handler_pc :=" inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1954
            "catch_type :=" inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1955
        ].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1956
    ].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1957
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1958
    aSmalltalkMethod byteCode:code. 
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1959
    aSmalltalkMethod stackSize:max_stack .
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1960
    aSmalltalkMethod numberOfVars:max_locals. 
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1961
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1962
    self readAttributesFor:aSmalltalkMethod.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1963
    ^ true
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1964
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1965
    "Modified: / 16.5.1998 / 01:39:30 / cg"
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1966
!
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1967
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1968
readSTLiteralsAttributeFor:aSmalltalkMethod
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1969
    |attribute_length literal_table_length literal_table litIndex literal|
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1970
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1971
    attribute_length := inStream nextUnsignedLongMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1972
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1973
    literal_table_length := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1974
    literal_table_length ~~ 0 ifTrue:[
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1975
        literal_table := Array new:literal_table_length.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1976
        1 to:literal_table_length do:[:i |
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1977
            litIndex := inStream nextUnsignedShortMSB:msb.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1978
            literal := (constants at:litIndex).
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1979
            literal_table at:i put:literal.
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1980
        ].
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1981
    ].
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1982
    Verbose ifTrue:[Transcript show:'literals: '; showCR:literal_table storeString.].
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1983
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  1984
    "Created: / 7.5.1998 / 11:52:28 / cg"
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1985
    "Modified: / 16.5.1998 / 01:52:27 / cg"
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1986
!
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1987
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1988
readSTMethodCategoryAttributeFor:aSmalltalkMethod
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1989
    |attribute_length name_index name|
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1990
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1991
    attribute_length := inStream nextUnsignedLongMSB:msb.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1992
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1993
    name_index := inStream nextUnsignedShortMSB:msb.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1994
    name := (constants at:name_index).
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1995
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1996
    aSmalltalkMethod category:name.
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1997
348
10725e1a2aee more st-class reading
cg
parents: 344
diff changeset
  1998
    "Modified: / 8.5.1998 / 20:39:59 / cg"
357
90d866d87398 more st-class reading
cg
parents: 355
diff changeset
  1999
    "Created: / 16.5.1998 / 01:04:19 / cg"
344
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  2000
! !
e97744a854f7 code cleanup;
cg
parents: 335
diff changeset
  2001
135
098936234135 *** empty log message ***
cg
parents: 128
diff changeset
  2002
!JavaClassReader class methodsFor:'documentation'!
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  2003
083530508d9c intitial checkin
cg
parents:
diff changeset
  2004
version
370
2a2e5914ee22 also look for zar suffix files.
cg
parents: 366
diff changeset
  2005
    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaClassReader.st,v 1.71 1998/09/18 14:34:43 cg Exp $'
1
083530508d9c intitial checkin
cg
parents:
diff changeset
  2006
! !
083530508d9c intitial checkin
cg
parents:
diff changeset
  2007
JavaClassReader initialize!