Skip to content

Commit dca8240

Browse files
committed
refactor(compiler): rename force_out_of_gas to single_error
The setting collapses every failure path to a single OutOfGas constant; "single_error" reflects what it does (one merged error result) rather than the implementation detail of which result code is used as the placeholder.
1 parent 133cc49 commit dca8240

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

crates/revmc-cli/src/cmd/run.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ pub(crate) struct RunArgs {
7979
no_gas: bool,
8080
#[arg(long)]
8181
no_len_checks: bool,
82-
/// Force all return paths to yield `OutOfGas`.
82+
/// Force all failure paths to yield a single `OutOfGas`.
8383
#[arg(long)]
84-
force_out_of_gas: bool,
84+
single_error: bool,
8585
/// Inspect the stack after the function has been executed.
8686
#[arg(long)]
8787
inspect_stack: bool,
@@ -157,8 +157,8 @@ impl RunArgs {
157157
compiler.gas_metering(!self.no_gas);
158158
unsafe { compiler.stack_bound_checks(!self.no_len_checks) };
159159
compiler.debug_assertions(self.debug_assertions);
160-
if self.force_out_of_gas {
161-
compiler.force_out_of_gas(true);
160+
if self.single_error {
161+
compiler.single_error(true);
162162
}
163163

164164
compiler.set_module_name(name);

crates/revmc-codegen/src/compiler/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ impl<B: Backend> EvmCompiler<B> {
425425
/// Useful for benchmarking the cost of failure-result materialization.
426426
///
427427
/// Defaults to `false`.
428-
pub fn force_out_of_gas(&mut self, yes: bool) {
429-
self.config.force_out_of_gas = yes;
428+
pub fn single_error(&mut self, yes: bool) {
429+
self.config.single_error = yes;
430430
}
431431

432432
/// Sets custom gas parameters.

crates/revmc-codegen/src/compiler/translate/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub(super) struct FcxConfig {
3131
pub(super) inspect_stack: bool,
3232
pub(super) stack_bound_checks: bool,
3333
pub(super) gas_metering: bool,
34-
pub(super) force_out_of_gas: bool,
34+
pub(super) single_error: bool,
3535
}
3636

3737
impl Default for FcxConfig {
@@ -44,7 +44,7 @@ impl Default for FcxConfig {
4444
inspect_stack: false,
4545
stack_bound_checks: true,
4646
gas_metering: true,
47-
force_out_of_gas: true,
47+
single_error: true,
4848
}
4949
}
5050
}
@@ -439,10 +439,10 @@ impl<'a, B: Backend> FunctionCx<'a, B> {
439439
// Finalize the failure block.
440440
fx.bcx.switch_to_block(fx.failure_block.unwrap());
441441
if !fx.incoming_failures.is_empty() {
442-
// `force_out_of_gas` collapses every error path to a generic OOG; this is
442+
// `single_error` collapses every error path to a generic OOG; this is
443443
// safe because failures are semantically interchangeable for callers that
444444
// only branch on success vs failure.
445-
let failure_value = if config.force_out_of_gas {
445+
let failure_value = if config.single_error {
446446
fx.bcx.iconst(fx.i8_type, InstructionResult::OutOfGas as i64)
447447
} else {
448448
fx.bcx.phi(fx.i8_type, &fx.incoming_failures)

0 commit comments

Comments
 (0)