Skip to main content

StatementType

Enum StatementType 

Source
pub enum StatementType {
Show 13 variants Literal(Literal), Opcode(Opcode), ImmediateOpcode { opcode: Opcode, operands: Vec<Expression>, }, Code(String), MacroInvocation(MacroInvocation), Constant(String), ArgCall(String, String), ArgMacroInvocation(String, String, Vec<MacroArg>), Label(Label), LabelCall(String), BuiltinFunctionCall(BuiltinFunctionCall), ForLoop { variable: String, start: Expression, end: Expression, step: Option<Expression>, body: Vec<Statement>, }, IfStatement { condition: Expression, then_branch: Vec<Statement>, else_if_branches: Vec<(Expression, Vec<Statement>)>, else_branch: Option<Vec<Statement>>, },
}
Expand description

The Statement Type

Variants§

§

Literal(Literal)

A Literal Statement

Example: 0x04, 0x420

§

Opcode(Opcode)

An Opcode Statement

Example: add, mstore, calldataload

§

ImmediateOpcode

An opcode followed by immediate operands that are resolved at compile time

Operands are compile-time expressions: literals, [CONSTANT], <arg>, loop variables, or parenthesized arithmetic. Example: dupn 17, swapn [DEPTH], exchange 1 <m>, push2 [SIZE]

Fields

§opcode: Opcode

The opcode

§operands: Vec<Expression>

Operand expressions in source order

§

Code(String)

A Code Statement

Raw bytecode string

§

MacroInvocation(MacroInvocation)

A Macro Invocation Statement

Example: TRANSFER(), ONLY_OWNER()

§

Constant(String)

A Constant Push

Example: [BALANCE_LOCATION], [MAX_SUPPLY]

§

ArgCall(String, String)

An Arg Call

Referencing a macro parameter. Example: <amount>, <recipient>

Macro name and argument name

§

ArgMacroInvocation(String, String, Vec<MacroArg>)

A Macro Invocation through Argument

Calling a macro passed as an argument. Example: <operation>()

Parent macro name, argument name, and arguments for the invoked macro

§

Label(Label)

A Label

Jump destination definition. Example: success:, error:

§

LabelCall(String)

A Label Reference/Call

Reference to jump to a label. Example: success, error

§

BuiltinFunctionCall(BuiltinFunctionCall)

A built-in function call

Example: __FUNC_SIG(transfer), __EVENT_HASH(Transfer)

§

ForLoop

A compile-time for loop

Example: for(i in 0..5) { <i> }

Fields

§variable: String

Loop variable name

§start: Expression

Start value (constant expression)

§end: Expression

End value (exclusive, constant expression)

§step: Option<Expression>

Optional step value (defaults to 1)

§body: Vec<Statement>

Loop body statements

§

IfStatement

A compile-time if statement

Example: if([CONST] > 5) { ... } else { ... }

Fields

§condition: Expression

Condition (constant expression that evaluates to non-zero = true)

§then_branch: Vec<Statement>

Then branch statements

§else_if_branches: Vec<(Expression, Vec<Statement>)>

Optional else if clauses (condition, body pairs)

§else_branch: Option<Vec<Statement>>

Optional else branch statements

Trait Implementations§

Source§

impl Clone for StatementType

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StatementType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for StatementType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for StatementType

Source§

impl Ord for StatementType

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for StatementType

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for StatementType

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for StatementType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 264 bytes

Size for each variant:

  • Literal: 40 bytes
  • Opcode: 9 bytes
  • ImmediateOpcode: 40 bytes
  • Code: 32 bytes
  • MacroInvocation: 80 bytes
  • Constant: 32 bytes
  • ArgCall: 56 bytes
  • ArgMacroInvocation: 80 bytes
  • Label: 80 bytes
  • LabelCall: 32 bytes
  • BuiltinFunctionCall: 64 bytes
  • ForLoop: 264 bytes
  • IfStatement: 152 bytes