pub fn build(self) -> Function {
        debug_assert!(!self.name.is_empty(), "name must be non-0 in length");

        let function_type = self
            .context
            .get_function_type(self.return_type, &self.argument_types);

        let mut function = FunctionPayload {
            module: self.module,
            name: self.context.get_name(self.name),
            function_type,
            arguments: Vec::new(),
            blocks: Vec::new(),
            attributes: self.attributes,
            location: self.location,
        };

        for (argument_name, argument_type) in self.argument_names.iter().zip(self.argument_types) {
            let name = self.context.get_name(argument_name);

            let argument = self.context.values.insert(ValuePayload::Argument(Argument {
                name,
                ty: argument_type,
            }));
            function.arguments.push(Value(argument));
        }

        let func = Function(self.context.functions.insert(function));

        self.context.modules[self.module.0].functions.push(func);

        func
    }
/// Finalize and build the function.
///
/// # Examples
///
/// ```
/// # use yair::*;
/// # let mut context = Context::new();
/// # let module = context.create_module().build();
/// # let function_builder = module.create_function(&mut context).with_name("func");
/// let function = function_builder.build();
/// ```
Finalize and build the function.
Finalize and build the function .
pub fn build(self) -> Function {
        debug_assert!(!self.name.is_empty(), "name must be non-0 in length");
        let function_type = self
            .context
            .get_function_type(self.return_type, &self.argument_types);
        let mut function = FunctionPayload {
            module: self.module,
            name: self.context.get_name(self.name),
            function_type,
            arguments: Vec::new(),
            blocks: Vec::new(),
            attributes: self.attributes,
            location: self.location,
        };
        for (argument_name, argument_type) in self.argument_names.iter().zip(self.argument_types) {
            let name = self.context.get_name(argument_name);
            let argument = self.context.values.insert(ValuePayload::Argument(Argument {
                name,
                ty: argument_type,
            }));
            function.arguments.push(Value(argument));
        }
        let func = Function(self.context.functions.insert(function));
        self.context.modules[self.module.0].functions.push(func);
        func
    }
pub fn build ( self ) -> Function { debug_assert ! ( self name is_empty ( ) " " ) ; let function_type = self . context . get_function_type ( self . return_type , & self . argument_types ) ; let mut function = FunctionPayload { module : self . module , name : self . context . get_name ( self . name ) , function_type , arguments : Vec :: new ( ) , blocks : Vec :: new ( ) , attributes : self . attributes , location : self . location , } ; for ( argument_name , argument_type ) in self . argument_names . iter ( ) . zip ( self . argument_types ) { let name = self . context . get_name ( argument_name ) ; let argument = self . context . values . insert ( ValuePayload :: Argument ( Argument { name , ty : argument_type , } ) ) ; function . arguments . push ( Value ( argument ) ) ; } let func = Function ( self . context . functions . insert ( function ) ) ; self . context . modules [ self . module . 0 ] . functions . push ( func ) ; func }
Finalize and build the function.
Finalize and build the function .
self
self
examples
None
use yair::*;
None
let mut context = context::new();
None
let module = context.create_module().build();
None
let function_builder = module.create_function(&mut context).with_name("func");
let function = function_builder.build();
```
let function = function_builder . build () ; ` ` `