-
Notifications
You must be signed in to change notification settings - Fork 67
/
AbstractInterpreter.class.st
64 lines (61 loc) · 2.12 KB
/
AbstractInterpreter.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Class {
#name : #AbstractInterpreter,
#superclass : #VMClass,
#category : #Melchor
}
{ #category : #initialization }
AbstractInterpreter class >> bytecodeTable: anArray from: specArray [
"SpecArray is an array of one of (index selector) or (index1
index2 selector) or (index nil) or (index1 index2 nil). If selector
then the entry is the selector, but if nil the entry is the index."
| contiguous |
contiguous := 0.
specArray do: [ : bytecodeSizeSpec |
(bytecodeSizeSpec at: 2) do: [ : spec |
(spec at: 1) = contiguous
ifFalse: [ self error: 'Non-contiguous table entry' ].
spec size = 2
ifTrue: [ anArray
at: (spec at: 1) + 1
put: ((spec at: 2) ifNil: [ spec at: 1 ] ifNotNil: [: sym | sym ]).
contiguous := contiguous + 1 ]
ifFalse: [
(spec at: 1) to: (spec at: 2) do: [ : i |
anArray
at: i + 1
put: ( (spec at: 3)
ifNil: [ i ]
ifNotNil: [ : sym | sym ]) ].
contiguous := contiguous + ((spec at: 2) - (spec at: 1)) + 1 ] ] ].
anArray doWithIndex: [ : entry : index |
entry isSymbol
ifTrue: [ (self shouldIncludeMethodForSelector: entry)
ifFalse: [ anArray at: index put: 0 ] ] ]
]
{ #category : #initialization }
AbstractInterpreter class >> table: anArray from: specArray [
"SpecArray is an array of one of (index selector) or (index1
index2 selector) or (index nil) or (index1 index2 nil). If selector
then the entry is the selector, but if nil the entry is the index."
| contiguous |
contiguous := 0.
specArray do:
[:spec |
(spec at: 1) = contiguous ifFalse:
[self error: 'Non-contiguous table entry'].
spec size = 2
ifTrue:
[anArray
at: (spec at: 1) + 1
put: ((spec at: 2) ifNil: [spec at: 1] ifNotNil: [:sym| sym]).
contiguous := contiguous + 1]
ifFalse:
[(spec at: 1) to: (spec at: 2) do:
[:i | anArray at: i + 1 put: ((spec at: 3) ifNil: [i] ifNotNil: [:sym| sym])].
contiguous := contiguous + ((spec at: 2) - (spec at: 1)) + 1]].
anArray doWithIndex:
[:entry :index|
entry isSymbol ifTrue:
[(self shouldIncludeMethodForSelector: entry) ifFalse:
[anArray at: index put: 0]]]
]