pub struct Function(pub Index);
Expand description

A wrapper around an ECS handle into the Context.

Tuple Fields

0: Index

Implementations

Return a new Function handle.

Creates a Function in the context within module and returns a handle.

name, args, return_type and is_public are the usual suspects. selector is a special value used for Sway contract calls; much like name is unique and not particularly used elsewhere in the IR.

Create and append a new Block to this function.

Create and insert a new Block into this function.

The new block is inserted before other.

Create and insert a new Block into this function.

The new block is inserted after other.

Get a new unique block label.

If hint is None then the label will be in the form "blockN" where N is an incrementing decimal.

Otherwise if the hint is already unique to this function it will be returned. If not already unique it will have N appended to it until it is unique.

Return the function name.

pub fn get_entry_block(&self, context: &Context) -> Block

Return the function entry (i.e., the first) block.

Whether this function has a valid selector.

Return the function selector, if it has one.

Get an arg value by name, if found.

Find the name of an arg by value.

Return an iterator for each of the function arguments.

Get a pointer to a local value by name, if found.

Find the name of a local value by pointer.

Add a value to the function local storage.

The name must be unique to this function else an error is returned.

Add a value to the function local storage, by forcing the name to be unique if needed.

Will use the provided name as a hint and rename to guarantee insertion.

Return an iterator to all of the values in this function’s local storage.

Merge values from another Function into this one.

The names of the merged values are guaranteed to be unique via the use of Function::new_unique_local_ptr.

Returns a map from the original pointers to the newly merged pointers.

XXX This function returns a Result but can’t actually fail?

Return an iterator to each block in this function.

Return an iterator to each instruction in each block in this function.

This is a convenience method for when all instructions in a function need to be inspected. The instruction value is returned from the iterator along with the block it belongs to.

Replace a value with another within this function.

This is a convenience method which iterates over this function’s blocks and calls Block::replace_value in turn.

starting_block is an optimisation for when the first possible reference to old_val is known.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.