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]
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
start: ExpressionStart value (constant expression)
end: ExpressionEnd value (exclusive, constant expression)
step: Option<Expression>Optional step value (defaults to 1)
IfStatement
A compile-time if statement
Example: if([CONST] > 5) { ... } else { ... }
Fields
condition: ExpressionCondition (constant expression that evaluates to non-zero = true)
else_if_branches: Vec<(Expression, Vec<Statement>)>Optional else if clauses (condition, body pairs)
Trait Implementations§
Source§impl Clone for StatementType
impl Clone for StatementType
Source§impl Debug for StatementType
impl Debug for StatementType
Source§impl Display for StatementType
impl Display for StatementType
impl Eq for StatementType
Source§impl Ord for StatementType
impl Ord for StatementType
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for StatementType
impl PartialEq for StatementType
Source§impl PartialOrd for StatementType
impl PartialOrd for StatementType
impl StructuralPartialEq for StatementType
Auto Trait Implementations§
impl Freeze for StatementType
impl RefUnwindSafe for StatementType
impl Send for StatementType
impl Sync for StatementType
impl Unpin for StatementType
impl UnsafeUnpin for StatementType
impl UnwindSafe for StatementType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<S, T> Upcast<T> for S
impl<S, T> Upcast<T> for S
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
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 bytesOpcode: 9 bytesImmediateOpcode: 40 bytesCode: 32 bytesMacroInvocation: 80 bytesConstant: 32 bytesArgCall: 56 bytesArgMacroInvocation: 80 bytesLabel: 80 bytesLabelCall: 32 bytesBuiltinFunctionCall: 64 bytesForLoop: 264 bytesIfStatement: 152 bytes