neo_solidity/ir/expressions/member_access/
fallback.rs1fn lower_generic_member_access(
2 expr: &Expression,
3 inner: &Expression,
4 member: &Identifier,
5 ctx: &mut LoweringContext,
6 instructions: &mut Vec<Instruction>,
7) -> bool {
8 if let Expression::Variable(base) = inner {
10 if let Some(variants) = ctx.enum_variant_map.get(&base.name) {
11 if let Some(value) = variants.get(&member.name) {
12 instructions.push(Instruction::PushLiteral(LiteralValue::Integer(
13 BigInt::from(*value),
14 )));
15 return true;
16 }
17 }
18 }
19
20 if let Some(reference) = resolve_storage_reference(expr, ctx) {
21 return emit_storage_load(&reference, ctx, instructions);
22 }
23
24 if let Some(ValueType::Struct { fields, .. }) = infer_type_from_expression(inner, ctx) {
26 if let Some(field_index) = fields
27 .iter()
28 .position(|field| field.name == member.name)
29 {
30 if !lower_expression(inner, ctx, instructions) {
31 return false;
32 }
33 instructions.push(Instruction::PushLiteral(LiteralValue::Integer(
34 BigInt::from(field_index as u64),
35 )));
36 instructions.push(Instruction::ArrayGet);
37 return true;
38 }
39 }
40
41 load_expression(inner, ctx, instructions);
42 instructions.push(Instruction::Drop(ValueType::Any));
43 instructions.push(Instruction::PushLiteral(LiteralValue::Integer(
44 BigInt::zero(),
45 )));
46 true
47}