MCPcopy Index your code
hub / github.com/endbasic/endbasic / case_relop_instr

Function case_relop_instr

core/src/compiler/top.rs:239–280  ·  view source on GitHub ↗

Returns the bytecode opcode constructor for `relop` and operands of type `etype`.

(
    relop: &CaseRelOp,
    etype: ExprType,
)

Source from the content-addressed store, hash-verified

237
238/// Returns the bytecode opcode constructor for `relop` and operands of type `etype`.
239fn case_relop_instr(
240 relop: &CaseRelOp,
241 etype: ExprType,
242) -> Option<fn(Register, Register, Register) -> u32> {
243 match etype {
244 ExprType::Boolean => match relop {
245 CaseRelOp::Equal => Some(bytecode::make_equal_boolean),
246 CaseRelOp::NotEqual => Some(bytecode::make_not_equal_boolean),
247 CaseRelOp::Less
248 | CaseRelOp::LessEqual
249 | CaseRelOp::Greater
250 | CaseRelOp::GreaterEqual => None,
251 },
252
253 ExprType::Double => match relop {
254 CaseRelOp::Equal => Some(bytecode::make_equal_double),
255 CaseRelOp::NotEqual => Some(bytecode::make_not_equal_double),
256 CaseRelOp::Less => Some(bytecode::make_less_double),
257 CaseRelOp::LessEqual => Some(bytecode::make_less_equal_double),
258 CaseRelOp::Greater => Some(bytecode::make_greater_double),
259 CaseRelOp::GreaterEqual => Some(bytecode::make_greater_equal_double),
260 },
261
262 ExprType::Integer => match relop {
263 CaseRelOp::Equal => Some(bytecode::make_equal_integer),
264 CaseRelOp::NotEqual => Some(bytecode::make_not_equal_integer),
265 CaseRelOp::Less => Some(bytecode::make_less_integer),
266 CaseRelOp::LessEqual => Some(bytecode::make_less_equal_integer),
267 CaseRelOp::Greater => Some(bytecode::make_greater_integer),
268 CaseRelOp::GreaterEqual => Some(bytecode::make_greater_equal_integer),
269 },
270
271 ExprType::Text => match relop {
272 CaseRelOp::Equal => Some(bytecode::make_equal_text),
273 CaseRelOp::NotEqual => Some(bytecode::make_not_equal_text),
274 CaseRelOp::Less => Some(bytecode::make_less_text),
275 CaseRelOp::LessEqual => Some(bytecode::make_less_equal_text),
276 CaseRelOp::Greater => Some(bytecode::make_greater_text),
277 CaseRelOp::GreaterEqual => Some(bytecode::make_greater_equal_text),
278 },
279 }
280}
281
282/// Compiles a comparison between `test` and `rhs`, leaving the boolean result in `dest`.
283fn compile_case_relop(

Callers 1

compile_case_relopFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected