@@ -47,6 +47,31 @@ extension Processor {
4747 var values : [ Any ]
4848
4949 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+ }
5075 }
5176}
5277
@@ -97,42 +122,11 @@ extension Processor.Registers {
97122}
98123
99124extension 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+ " " . startIndex
133127 }
134128
135- mutating func reset( sentinel : Input . Index ) {
129+ mutating func reset( ) {
136130 guard isDirty else {
137131 return
138132 }
@@ -151,32 +145,6 @@ extension MutableCollection {
151145 }
152146}
153147
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-
180148extension Processor . Registers : CustomStringConvertible {
181149 var description : String {
182150 func formatRegisters< T> (
0 commit comments