@@ -47,6 +47,31 @@ extension Processor {
47
47
var values : [ Any ]
48
48
49
49
var positions : [ Input . Index ]
50
+
51
+ init (
52
+ elements: [ Element ] ,
53
+ utf8Contents: [ [ UInt8 ] ] ,
54
+ bitsets: [ DSLTree . CustomCharacterClass . AsciiBitset ] ,
55
+ consumeFunctions: [ MEProgram . ConsumeFunction ] ,
56
+ transformFunctions: [ MEProgram . TransformFunction ] ,
57
+ matcherFunctions: [ MEProgram . MatcherFunction ] ,
58
+ isDirty: Bool = false ,
59
+ numInts: Int ,
60
+ numValues: Int ,
61
+ numPositions: Int
62
+ ) {
63
+ self . elements = elements
64
+ self . utf8Contents = utf8Contents
65
+ self . bitsets = bitsets
66
+ self . consumeFunctions = consumeFunctions
67
+ self . transformFunctions = transformFunctions
68
+ self . matcherFunctions = matcherFunctions
69
+ self . isDirty = isDirty
70
+ self . ints = Array ( repeating: 0 , count: numInts)
71
+ self . values = Array ( repeating: SentinelValue ( ) , count: numValues)
72
+ self . positions = Array (
73
+ repeating: Self . sentinelIndex, count: numPositions)
74
+ }
50
75
}
51
76
}
52
77
@@ -97,39 +122,9 @@ extension Processor.Registers {
97
122
}
98
123
99
124
extension Processor . Registers {
100
- static let sentinelIndex = " " . startIndex
101
-
102
- init (
103
- _ program: MEProgram ,
104
- _ sentinel: String . Index
105
- ) {
106
- let info = program. registerInfo
107
-
108
- self . elements = program. staticElements
109
- assert ( elements. count == info. elements)
110
-
111
- self . utf8Contents = program. staticUTF8Contents
112
- assert ( utf8Contents. count == info. utf8Contents)
113
-
114
- self . bitsets = program. staticBitsets
115
- assert ( bitsets. count == info. bitsets)
116
-
117
- self . consumeFunctions = program. staticConsumeFunctions
118
- assert ( consumeFunctions. count == info. consumeFunctions)
119
-
120
- self . transformFunctions = program. staticTransformFunctions
121
- assert ( transformFunctions. count == info. transformFunctions)
122
-
123
- self . matcherFunctions = program. staticMatcherFunctions
124
- assert ( matcherFunctions. count == info. matcherFunctions)
125
-
126
- self . ints = Array ( repeating: 0 , count: info. ints)
127
-
128
- self . values = Array (
129
- repeating: SentinelValue ( ) , count: info. values)
130
- self . positions = Array (
131
- repeating: Processor . Registers. sentinelIndex,
132
- count: info. positions)
125
+ static var sentinelIndex : String . Index {
126
+ let maxPos = 0x0000_FFFF_FFFF_FFFF
127
+ return String . Index ( encodedOffset: maxPos)
133
128
}
134
129
135
130
mutating func reset( sentinel: Input . Index ) {
@@ -151,32 +146,6 @@ extension MutableCollection {
151
146
}
152
147
}
153
148
154
- extension MEProgram {
155
- struct RegisterInfo {
156
- var elements = 0
157
- var utf8Contents = 0
158
- var bools = 0
159
- var strings = 0
160
- var bitsets = 0
161
- var consumeFunctions = 0
162
- var transformFunctions = 0
163
- var matcherFunctions = 0
164
- var ints = 0
165
- var floats = 0
166
- var positions = 0
167
- var values = 0
168
- var instructionAddresses = 0
169
- var classStackAddresses = 0
170
- var positionStackAddresses = 0
171
- var savePointAddresses = 0
172
- var captures = 0
173
-
174
- // The value register holding the whole-match value, if there
175
- // is one
176
- var wholeMatchValue : Int ? = nil
177
- }
178
- }
179
-
180
149
extension Processor . Registers : CustomStringConvertible {
181
150
var description : String {
182
151
func formatRegisters< T> (
0 commit comments