neo_solidity/ir/expressions/calls/builtins/
member_access.rs

1fn try_lower_member_builtin(
2    func: &Expression,
3    args: &[Expression],
4    ctx: &mut LoweringContext,
5    instructions: &mut Vec<Instruction>,
6) -> Option<bool> {
7    let Expression::MemberAccess(_, inner, member) = func else {
8        return None;
9    };
10    let Expression::Variable(base) = inner.as_ref() else {
11        return None;
12    };
13
14    if base.name == "abi"
15        && matches!(
16            member.name.as_str(),
17            "encodeWithSignature" | "encodeWithSelector"
18        )
19    {
20        // Neo N3 contracts are invoked by method name + args (manifest ABI), not by raw
21        // EVM calldata. We only support these helpers when they can be rewritten into a
22        // Neo `System.Contract.Call` (either inlined into `address.call/staticcall(...)`,
23        // or stored in a local `bytes` variable that is later passed to those calls).
24        ctx.record_error(format!(
25            "abi.{} is only supported for Neo contract calls (inline it into `address.call(...)` / `address.staticcall(...)`, or assign it to a local `bytes` variable that is later passed to those calls). Raw EVM calldata bytes are not supported on Neo N3; use `Syscalls.contractCall` / `Syscalls.contractCallWithFlags` / `NativeCalls.*` helpers when possible",
26            member.name
27        ));
28        return Some(false);
29    }
30
31    if let Some(result) = try_lower_runtime_member_builtin(base, member, args, ctx, instructions) {
32        return Some(result);
33    }
34
35    if let Some(result) = try_lower_syscalls_member_builtin(base, member, args, ctx, instructions)
36    {
37        return Some(result);
38    }
39
40    if let Some(result) = try_lower_storage_member_builtin(base, member, args, ctx, instructions) {
41        return Some(result);
42    }
43
44    if let Some(result) = try_lower_neo_member_builtin(base, member, args, ctx, instructions) {
45        return Some(result);
46    }
47
48    if let Some(result) =
49        try_lower_nativecalls_member_builtin(base, member, args, ctx, instructions)
50    {
51        return Some(result);
52    }
53
54    None
55}