feat(slang): lower new B(args) and bare addr.call/staticcall/delegatecall#462
Draft
hedgar2017 wants to merge 1 commit into
Draft
feat(slang): lower new B(args) and bare addr.call/staticcall/delegatecall#462hedgar2017 wants to merge 1 commit into
hedgar2017 wants to merge 1 commit into
Conversation
…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.
a11881a to
706b394
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two cross-contract lowering paths on top of the multi-contract emission and linking plumbing stack.
new B(args)(aNewExpressioncallee inside aFunctionCallExpression) resolves the contract from the call's binder type, emitssol.newwith the contract name asobj_nameand a default zero value, and records the dependency viaContext::add_dependencyso the linker pulls in B's deploy bytecode. Constructor value transfer (new C{value: x}()) and CREATE2 salt (new C{salt: s}()) go throughCallOptionsExpressionand are not yet wired.addr.call(data),addr.staticcall(data), andaddr.delegatecall(data)emit the matchingsol.bare_call/sol.bare_static_call/sol.bare_delegate_callop withgasleft()for gas and a zero value default forcall. The op produces(status, ret_data); statement context discards both, tuple deconstruction extracts both via atry_emit_bare_call_resultshelper plugged intoemit_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 withnon-ref undefined symbol: __datasize__$<hash>$__.tests/solidity/simple -O M3B3is 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.