Appearance
| 1 | namespace IR.Values is | |
| 2 | use Semantic.Types.Type | |
| 3 | ||
| 4 | // Reads an int local, decrements it, and leaves the decremented value | |
| 5 | // on the stack. Used by a fused `skip` stage: each pulled element | |
| 6 | // decrements the running counter, and the new value is compared against | |
| 7 | // zero to decide whether the element is dropped - mirroring | |
| 8 | // FilterPipeBase.have_moved followed by should_include. | |
| 9 | class PRE_DECREMENT: Value is | |
| 10 | _counter_il_name: string | |
| 11 | ||
| 12 | type: Type | |
| 13 | ||
| 14 | init(counter_il_name: string, type: Type) is | |
| 15 | super.init() | |
| 16 | ||
| 17 | _counter_il_name = counter_il_name | |
| 18 | self.type = type | |
| 19 | si | |
| 20 | ||
| 21 | gen(context: IR.CONTEXT) is | |
| 22 | let body = context.current_srm_body_emitter! | |
| 23 | body.ldloc(_counter_il_name) | |
| 24 | body.ldc_i4(1) | |
| 25 | body.op(System.Reflection.Metadata.ILOpCode.SUB) | |
| 26 | body.op(System.Reflection.Metadata.ILOpCode.DUP) | |
| 27 | body.stloc(_counter_il_name) | |
| 28 | si | |
| 29 | ||
| 30 | to_string() -> string => "pre_decrement:({_counter_il_name})" | |
| 31 | si | |
| 32 | si |