MCPcopy Create free account
hub / github.com/ForLoveOfCats/fae / generate_binary_operation

Function generate_binary_operation

src/codegen/codegen.rs:1097–1136  ·  view source on GitHub ↗
(
	context: &mut Context<'a, 'b>,
	generator: &mut G,
	operation: &'b BinaryOperation<'a>,
	debug_location: DebugLocation,
)

Source from the content-addressed store, hash-verified

1095 expression,
1096 index_expression,
1097 debug_location,
1098 )
1099 } else {
1100 generator.generate_slice_slice(
1101 context.lang_items,
1102 context.type_store,
1103 item_type,
1104 expression,
1105 index_expression,
1106 debug_location,
1107 )
1108 }
1109 }
1110 }
1111}
1112
1113fn generate_binary_operation<'a, 'b, G: Generator>(
1114 context: &mut Context<'a, 'b>,
1115 generator: &mut G,
1116 operation: &'b BinaryOperation<'a>,
1117 debug_location: DebugLocation,
1118) -> Option<G::Binding> {
1119 let left_type_id = context.specialize_type_id(operation.left.type_id);
1120 let result_type_id = context.specialize_type_id(operation.type_id);
1121
1122 let left_untyped_number = left_type_id.is_untyped_number(context.type_store);
1123 let left_has_size = left_untyped_number || context.type_store.type_layout(left_type_id).size > 0;
1124
1125 if !left_has_size {
1126 let left = generate_expression(context, generator, &operation.left);
1127 assert!(left.is_none(), "{left:#?}, {:#?}", &operation.left);
1128 let right = generate_expression(context, generator, &operation.right);
1129 assert!(right.is_none());
1130
1131 let value = match operation.op {
1132 BinaryOperator::Assign => return None,
1133
1134 BinaryOperator::Equals => true,
1135 BinaryOperator::NotEquals => false,
1136
1137 op => unreachable!("{op:?}"),
1138 };
1139

Callers 1

generate_expression_implFunction · 0.85

Calls 6

generate_expressionFunction · 0.85
specialize_type_idMethod · 0.80
is_untyped_numberMethod · 0.80
type_layoutMethod · 0.80

Tested by

no test coverage detected