7 inclusion of the above copyright notice. This software may not |
7 inclusion of the above copyright notice. This software may not |
8 be provided or otherwise made available to, or used by, any |
8 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
|
13 "{ Package: 'stx:libbasic' }" |
12 "{ Package: 'stx:libbasic' }" |
14 |
13 |
15 ExecutableFunction variableSubclass:#CompiledCode |
14 ExecutableFunction variableSubclass:#CompiledCode |
16 instanceVariableNames:'flags byteCode' |
15 instanceVariableNames:'flags byteCode' |
17 classVariableNames:'' |
16 classVariableNames:'' |
319 |
318 |
320 "Modified: / 30.1.1999 / 14:51:59 / cg" |
319 "Modified: / 30.1.1999 / 14:51:59 / cg" |
321 ! |
320 ! |
322 |
321 |
323 literalAt:index |
322 literalAt:index |
324 "return the literal array" |
323 "return a literal element" |
|
324 |
|
325 ^ self literalAt:index ifAbsent:[self error:'bad literal index'] |
|
326 ! |
|
327 |
|
328 literalAt:index ifAbsent:exceptionalValue |
|
329 "return a literal element" |
325 |
330 |
326 |lits numLits "{ Class: SmallInteger }"| |
331 |lits numLits "{ Class: SmallInteger }"| |
327 |
332 |
328 numLits := self size. |
333 numLits := self size. |
329 numLits == 0 ifTrue:[ |
334 numLits == 0 ifTrue:[ |
330 self error:'bad literal index' |
335 ^ exceptionalValue value |
331 ]. |
336 ]. |
332 numLits == 1 ifTrue:[ |
337 numLits == 1 ifTrue:[ |
333 lits := self at:1. |
338 lits := self at:1. |
334 lits isArray ifFalse:[ |
339 lits isArray ifFalse:[ |
335 index == 1 ifTrue:[^ lits]. |
340 index == 1 ifTrue:[^ lits]. |
336 self error:'bad literal index' |
341 ^ exceptionalValue value |
337 ]. |
342 ]. |
338 ^ lits at:index. |
343 ^ lits at:index. |
339 ]. |
344 ]. |
340 |
345 |
341 "there may be a dummy (nil) literal to make the size > 1" |
346 "there may be a dummy (nil) literal to make the size > 1" |
342 (self at:2) isNil ifTrue:[ |
347 (self at:2) isNil ifTrue:[ |
343 index == 1 ifTrue:[^ self at:1]. |
348 index == 1 ifTrue:[^ self at:1]. |
344 self error:'bad literal index'. |
349 ^ exceptionalValue value |
345 ]. |
350 ]. |
346 |
351 |
347 ^ self at:index |
352 ^ self at:index |
348 ! |
353 ! |
349 |
354 |
350 literalAt:index put:newValue |
355 literalAt:index put:newValue |
351 "change a literal slots value - dangerous internal interface; |
356 "change a literal slots value. |
352 only for knowledgable users" |
357 WARNING: dangerous internal interface; only for knowledgable users" |
353 |
358 |
354 |lits numLits "{ Class: SmallInteger }"| |
359 |lits numLits "{ Class: SmallInteger }"| |
355 |
360 |
356 numLits := self size. |
361 numLits := self size. |
357 numLits == 0 ifTrue:[ |
362 numLits == 0 ifTrue:[ |