-
Notifications
You must be signed in to change notification settings - Fork 65
/
AbstractInterpreter.class.st
33 lines (32 loc) · 1.04 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
Class {
#name : #AbstractInterpreter,
#superclass : #VMClass,
#category : #Melchor
}
{ #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]]]
]