pub(crate) fn new_instance_function(
        &self,
        location: Location,
        path: Item,
        type_hash: Hash,
        name: &str,
        args: usize,
        assembly: Assembly,
        call: Call,
        debug_args: Vec<String>,
    ) -> Result<(), CompileError> {
        log::trace!("instance fn: {}", path);

        let mut inner = self.inner.borrow_mut();

        let offset = inner.instructions.len();
        let instance_fn = Hash::instance_function(type_hash, name);
        let hash = Hash::type_hash(&path);

        let info = UnitFn::Offset { offset, call, args };
        let signature = DebugSignature::new(path, debug_args);

        if inner.functions.insert(instance_fn, info).is_some() {
            return Err(CompileError::new(
                location.span,
                CompileErrorKind::FunctionConflict {
                    existing: signature,
                },
            ));
        }

        if inner.functions.insert(hash, info).is_some() {
            return Err(CompileError::new(
                location.span,
                CompileErrorKind::FunctionConflict {
                    existing: signature,
                },
            ));
        }

        inner.constants.insert(
            Hash::instance_function(hash, Protocol::INTO_TYPE_NAME),
            ConstValue::String(signature.path.to_string()),
        );

        inner
            .debug_info_mut()
            .functions
            .insert(instance_fn, signature);
        inner.functions_rev.insert(offset, hash);
        inner.add_assembly(location, assembly)?;
        Ok(())
    }
/// Declare a new instance function at the current instruction pointer.
Declare a new instance function at the current instruction pointer.
Declare a new instance function at the current instruction pointer .
pub(crate) fn new_instance_function(
        &self,
        location: Location,
        path: Item,
        type_hash: Hash,
        name: &str,
        args: usize,
        assembly: Assembly,
        call: Call,
        debug_args: Vec<String>,
    ) -> Result<(), CompileError> {
        log::trace!("instance fn: {}", path);
        let mut inner = self.inner.borrow_mut();
        let offset = inner.instructions.len();
        let instance_fn = Hash::instance_function(type_hash, name);
        let hash = Hash::type_hash(&path);
        let info = UnitFn::Offset { offset, call, args };
        let signature = DebugSignature::new(path, debug_args);
        if inner.functions.insert(instance_fn, info).is_some() {
            return Err(CompileError::new(
                location.span,
                CompileErrorKind::FunctionConflict {
                    existing: signature,
                },
            ));
        }
        if inner.functions.insert(hash, info).is_some() {
            return Err(CompileError::new(
                location.span,
                CompileErrorKind::FunctionConflict {
                    existing: signature,
                },
            ));
        }
        inner.constants.insert(
            Hash::instance_function(hash, Protocol::INTO_TYPE_NAME),
            ConstValue::String(signature.path.to_string()),
        );
        inner
            .debug_info_mut()
            .functions
            .insert(instance_fn, signature);
        inner.functions_rev.insert(offset, hash);
        inner.add_assembly(location, assembly)?;
        Ok(())
    }
pub ( crate ) fn new_instance_function ( & self , location : Location , path : Item , type_hash : Hash , name : & str , args : usize , assembly : Assembly , call : Call , debug_args : Vec < String > , ) -> Result < ( ) , CompileError > { log :: trace ! ( " " path ) ; let mut inner = self . inner . borrow_mut ( ) ; let offset = inner . instructions . len ( ) ; let instance_fn = Hash :: instance_function ( type_hash , name ) ; let hash = Hash :: type_hash ( & path ) ; let info = UnitFn :: Offset { offset , call , args } ; let signature = DebugSignature :: new ( path , debug_args ) ; if inner . functions . insert ( instance_fn , info ) . is_some ( ) { return Err ( CompileError :: new ( location . span , CompileErrorKind :: FunctionConflict { existing : signature , } , ) ) ; } if inner . functions . insert ( hash , info ) . is_some ( ) { return Err ( CompileError :: new ( location . span , CompileErrorKind :: FunctionConflict { existing : signature , } , ) ) ; } inner . constants . insert ( Hash :: instance_function ( hash , Protocol :: INTO_TYPE_NAME ) , ConstValue :: String ( signature . path . to_string ( ) ) , ) ; inner . debug_info_mut ( ) . functions . insert ( instance_fn , signature ) ; inner . functions_rev . insert ( offset , hash ) ; inner . add_assembly ( location , assembly ) ? ; Ok ( ( ) ) }
Declare a new instance function at the current instruction pointer.
Declare a new instance function at the current instruction pointer .
&self
location
Location
path
Item
type_hash
Hash
name
&str
args
usize
assembly
Assembly
call
Call
debug_args
Vec<String>
&self
location
Location
path
Item
type_hash
Hash
name
&str
args
usize
assembly
Assembly
call
Call
debug_args
Vec<String>