@@ -17,7 +17,6 @@ extension MEProgram {
1717
1818 var elements = TypedSetVector < Input . Element , _ElementRegister > ( )
1919 var sequences = TypedSetVector < [ Input . Element ] , _SequenceRegister > ( )
20- var strings = TypedSetVector < String , _StringRegister > ( )
2120
2221 var consumeFunctions : [ ConsumeFunction ] = [ ]
2322 var assertionFunctions : [ AssertionFunction ] = [ ]
@@ -29,9 +28,7 @@ extension MEProgram {
2928 var addressFixups : [ ( InstructionAddress , AddressFixup ) ] = [ ]
3029
3130 // Registers
32- var nextBoolRegister = BoolRegister ( 0 )
3331 var nextIntRegister = IntRegister ( 0 )
34- var nextPositionRegister = PositionRegister ( 0 )
3532 var nextCaptureRegister = CaptureRegister ( 0 )
3633 var nextValueRegister = ValueRegister ( 0 )
3734
@@ -79,20 +76,6 @@ extension MEProgram.Builder {
7976 . init( instructions. endIndex - 1 )
8077 }
8178
82- mutating func buildNop( _ r: StringRegister ? = nil ) {
83- instructions. append ( . init( . nop, . init( optionalString: r) ) )
84- }
85- mutating func buildNop( _ s: String ) {
86- buildNop ( strings. store ( s) )
87- }
88-
89- mutating func buildDecrement(
90- _ i: IntRegister , nowZero: BoolRegister
91- ) {
92- instructions. append ( . init(
93- . decrement, . init( bool: nowZero, int: i) ) )
94- }
95-
9679 mutating func buildMoveImmediate(
9780 _ value: UInt64 , into: IntRegister
9881 ) {
@@ -108,24 +91,10 @@ extension MEProgram.Builder {
10891 buildMoveImmediate ( uint, into: into)
10992 }
11093
111- mutating func buildMoveCurrentPosition(
112- into: PositionRegister
113- ) {
114- instructions. append ( . init(
115- . movePosition, . init( position: into) ) )
116- }
117-
11894 mutating func buildBranch( to t: AddressToken ) {
11995 instructions. append ( . init( . branch) )
12096 fixup ( to: t)
12197 }
122- mutating func buildCondBranch(
123- _ condition: BoolRegister , to t: AddressToken
124- ) {
125- instructions. append (
126- . init( . condBranch, . init( bool: condition) ) )
127- fixup ( to: t)
128- }
12998
13099 mutating func buildCondBranch(
131100 to t: AddressToken , ifZeroElseDecrement i: IntRegister
@@ -157,27 +126,9 @@ extension MEProgram.Builder {
157126 instructions. append ( . init( . clearThrough) )
158127 fixup ( to: t)
159128 }
160- mutating func buildRestore( ) {
161- instructions. append ( . init( . restore) )
162- }
163129 mutating func buildFail( ) {
164130 instructions. append ( . init( . fail) )
165131 }
166- mutating func buildCall( _ t: AddressToken ) {
167- instructions. append ( . init( . call) )
168- fixup ( to: t)
169- }
170- mutating func buildRet( ) {
171- instructions. append ( . init( . ret) )
172- }
173-
174- mutating func buildAbort( _ s: StringRegister ? = nil ) {
175- instructions. append ( . init(
176- . abort, . init( optionalString: s) ) )
177- }
178- mutating func buildAbort( _ s: String ) {
179- buildAbort ( strings. store ( s) )
180- }
181132
182133 mutating func buildAdvance( _ n: Distance ) {
183134 instructions. append ( . init( . advance, . init( distance: n) ) )
@@ -196,14 +147,6 @@ extension MEProgram.Builder {
196147 . init( sequence: sequences. store ( . init( s) ) ) ) )
197148 }
198149
199- mutating func buildMatchSlice(
200- lower: PositionRegister , upper: PositionRegister
201- ) {
202- instructions. append ( . init(
203- . matchSlice,
204- . init( pos: lower, pos2: upper) ) )
205- }
206-
207150 mutating func buildConsume(
208151 by p: @escaping MEProgram . ConsumeFunction
209152 ) {
@@ -218,21 +161,10 @@ extension MEProgram.Builder {
218161 . assertBy, . init( assertion: makeAssertionFunction ( p) ) ) )
219162 }
220163
221- mutating func buildAssert(
222- _ e: Character , into cond: BoolRegister
223- ) {
224- instructions. append ( . init( . assertion, . init(
225- element: elements. store ( e) , bool: cond) ) )
226- }
227-
228164 mutating func buildAccept( ) {
229165 instructions. append ( . init( . accept) )
230166 }
231167
232- mutating func buildPrint( _ s: StringRegister ) {
233- instructions. append ( . init( . print, . init( string: s) ) )
234- }
235-
236168 mutating func buildBeginCapture(
237169 _ cap: CaptureRegister
238170 ) {
@@ -315,13 +247,10 @@ extension MEProgram.Builder {
315247 let payload : Instruction . Payload
316248
317249 switch inst. opcode {
318- case . condBranch:
319- payload = . init( addr: addr, bool: inst. payload. bool)
320-
321250 case . condBranchZeroElseDecrement:
322251 payload = . init( addr: addr, int: inst. payload. int)
323252
324- case . branch, . save, . saveAddress, . call , . clearThrough:
253+ case . branch, . save, . saveAddress, . clearThrough:
325254 payload = . init( addr: addr)
326255
327256 case . splitSaving:
@@ -342,10 +271,7 @@ extension MEProgram.Builder {
342271 var regInfo = MEProgram . RegisterInfo ( )
343272 regInfo. elements = elements. count
344273 regInfo. sequences = sequences. count
345- regInfo. strings = strings. count
346- regInfo. bools = nextBoolRegister. rawValue
347274 regInfo. ints = nextIntRegister. rawValue
348- regInfo. positions = nextPositionRegister. rawValue
349275 regInfo. values = nextValueRegister. rawValue
350276 regInfo. consumeFunctions = consumeFunctions. count
351277 regInfo. assertionFunctions = assertionFunctions. count
@@ -357,7 +283,6 @@ extension MEProgram.Builder {
357283 instructions: InstructionList ( instructions) ,
358284 staticElements: elements. stored,
359285 staticSequences: sequences. stored,
360- staticStrings: strings. stored,
361286 staticConsumeFunctions: consumeFunctions,
362287 staticAssertionFunctions: assertionFunctions,
363288 staticTransformFunctions: transformFunctions,
@@ -468,18 +393,10 @@ extension MEProgram.Builder {
468393 return nextCaptureRegister
469394 }
470395
471- mutating func makeBoolRegister( ) -> BoolRegister {
472- defer { nextBoolRegister. rawValue += 1 }
473- return nextBoolRegister
474- }
475396 mutating func makeIntRegister( ) -> IntRegister {
476397 defer { nextIntRegister. rawValue += 1 }
477398 return nextIntRegister
478399 }
479- mutating func makePositionRegister( ) -> PositionRegister {
480- defer { nextPositionRegister. rawValue += 1 }
481- return nextPositionRegister
482- }
483400 mutating func makeValueRegister( ) -> ValueRegister {
484401 defer { nextValueRegister. rawValue += 1 }
485402 return nextValueRegister
@@ -494,32 +411,6 @@ extension MEProgram.Builder {
494411 return r
495412 }
496413
497- // Allocate and initialize a register
498- mutating func makePositionRegister(
499- initializingWithCurrentPosition: ( )
500- ) -> PositionRegister {
501- let r = makePositionRegister ( )
502- self . buildMoveCurrentPosition ( into: r)
503- return r
504- }
505-
506- // 'kill' or release allocated registers
507- mutating func kill( _ r: IntRegister ) {
508- // TODO: Release/reuse registers, for now nop makes
509- // reading the code easier
510- buildNop ( " kill \( r) " )
511- }
512- mutating func kill( _ r: BoolRegister ) {
513- // TODO: Release/reuse registers, for now nop makes
514- // reading the code easier
515- buildNop ( " kill \( r) " )
516- }
517- mutating func kill( _ r: PositionRegister ) {
518- // TODO: Release/reuse registers, for now nop makes
519- // reading the code easier
520- buildNop ( " kill \( r) " )
521- }
522-
523414 // TODO: A register-mapping helper struct, which could release
524415 // registers without monotonicity required
525416
0 commit comments