MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / write_const_load

Function write_const_load

compiler/src/modules/vm/optimizer.rs:138–153  ·  view source on GitHub ↗
(chunk: &mut SSAChunk, pos: usize, v: Val)

Source from the content-addressed store, hash-verified

136}
137
138fn 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
155fn find_or_push_const(chunk: &mut SSAChunk, v: Val) -> Option<u16> {
156 let target: Value = if v.is_int() {

Callers 3

try_fold_binopFunction · 0.85
try_fold_notFunction · 0.85
try_fold_negFunction · 0.85

Calls 4

find_or_push_constFunction · 0.85
is_boolMethod · 0.80
as_boolMethod · 0.80
is_noneMethod · 0.80

Tested by

no test coverage detected