(chunk: &mut SSAChunk, pos: usize, v: Val)
| 136 | } |
| 137 | |
| 138 | fn write_const_load(chunk: &mut SSAChunk, pos: usize, v: Val) -> bool { |
| 139 | let new_ins = if v.is_bool() { |
| 140 | Instruction { |
| 141 | opcode: if v.as_bool() { OpCode::LoadTrue } else { OpCode::LoadFalse }, |
| 142 | operand: 0, |
| 143 | } |
| 144 | } else if v.is_none() { |
| 145 | Instruction { opcode: OpCode::LoadNone, operand: 0 } |
| 146 | } else if let Some(idx) = find_or_push_const(chunk, v) { |
| 147 | Instruction { opcode: OpCode::LoadConst, operand: idx } |
| 148 | } else { |
| 149 | return false; |
| 150 | }; |
| 151 | chunk.instructions[pos] = new_ins; |
| 152 | true |
| 153 | } |
| 154 | |
| 155 | fn find_or_push_const(chunk: &mut SSAChunk, v: Val) -> Option<u16> { |
| 156 | let target: Value = if v.is_int() { |
no test coverage detected