Skip to content

feat(slang): lower new B(args) and bare addr.call/staticcall/delegatecall#462

Draft
hedgar2017 wants to merge 1 commit into
feat-slang-mlir-cross-contract-depsfrom
feat-slang-new-and-bare-calls
Draft

feat(slang): lower new B(args) and bare addr.call/staticcall/delegatecall#462
hedgar2017 wants to merge 1 commit into
feat-slang-mlir-cross-contract-depsfrom
feat-slang-new-and-bare-calls

Conversation

@hedgar2017
Copy link
Copy Markdown
Contributor

Adds two cross-contract lowering paths on top of the multi-contract emission and linking plumbing stack.

new B(args) (a NewExpression callee inside a FunctionCallExpression) resolves the contract from the call's binder type, emits sol.new with the contract name as obj_name and a default zero value, and records the dependency via Context::add_dependency so the linker pulls in B's deploy bytecode. Constructor value transfer (new C{value: x}()) and CREATE2 salt (new C{salt: s}()) go through CallOptionsExpression and are not yet wired.

addr.call(data), addr.staticcall(data), and addr.delegatecall(data) emit the matching sol.bare_call / sol.bare_static_call / sol.bare_delegate_call op with gasleft() for gas and a zero value default for call. The op produces (status, ret_data); statement context discards both, tuple deconstruction extracts both via a try_emit_bare_call_results helper plugged into emit_function_call_results. Call options ({gas: g, value: v}) are not yet wired.

Verified end-to-end on a two-contract source: new B() followed by (bool ok,) = address(b).call("") compiles, links, and produces valid EVM bytecode where it previously failed at the LLD step with non-ref undefined symbol: __datasize__$<hash>$__.

tests/solidity/simple -O M3B3 is 1896 passed / 3 failed / 307 invalid, identical to the linking-plumbing baseline. Every multi-contract test in that suite also needs inheritance, function pointers, try-catch, or call options — none of which are wired in the Slang pipeline yet.

@hedgar2017 hedgar2017 added the ci:slang Trigger slang unit tests on PR label May 28, 2026
…call

Adds two cross-contract lowering paths:

- `new B(args)` (a `NewExpression` callee inside a `FunctionCallExpression`)
  resolves the contract from the call's binder type, emits `sol.new` with
  the contract name as `obj_name` and a default zero value, and records
  the dependency via `Context::add_dependency` so the linker pulls in
  B's deploy bytecode. Constructor value transfer (`new C{value: x}()`)
  and CREATE2 salt (`new C{salt: s}()`) go through `CallOptionsExpression`
  and are not yet wired.

- `addr.call(data)`, `addr.staticcall(data)`, `addr.delegatecall(data)`
  emit the matching `sol.bare_call` / `sol.bare_static_call` /
  `sol.bare_delegate_call` op with `gasleft()` for gas and a zero value
  default for `call`. The op produces `(status, ret_data)`; statement
  context discards both, tuple deconstruction extracts both via
  `try_emit_bare_call_results` plugged into `emit_function_call_results`.
  Call options (`{gas: g, value: v}`) are not yet wired.

Verified end-to-end on a two-contract source: `new B()` followed by
`(bool ok,) = address(b).call("")` compiles, links, and produces valid
EVM bytecode. `tests/solidity/simple -O M3B3` is 1896/3/307 — same as
the linking-plumbing baseline. Every multi-contract test in that suite
also needs inheritance, function pointers, try-catch, or call options,
none of which are wired.
@hedgar2017 hedgar2017 force-pushed the feat-slang-new-and-bare-calls branch from a11881a to 706b394 Compare May 28, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:slang Trigger slang unit tests on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant