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