fn add_internal_tuple<C, Args>(
        &mut self,
        enum_item: Option<Item>,
        item: Item,
        args: usize,
        constructor: C,
    ) -> Result<(), ContextError>
    where
        C: crate::module::Function<Args>,
        C::Return: TypeOf,
    {
        let type_hash = <C::Return as TypeOf>::type_hash();
        let hash = Hash::type_hash(&item);

        let tuple = CompileMetaTuple { args, hash };

        let meta = match enum_item {
            Some(enum_item) => CompileMeta {
                item: Arc::new(item.clone().into()),
                kind: CompileMetaKind::TupleVariant {
                    type_hash,
                    enum_item,
                    tuple,
                },
                source: None,
            },
            None => CompileMeta {
                item: Arc::new(item.clone().into()),
                kind: CompileMetaKind::TupleStruct { type_hash, tuple },
                source: None,
            },
        };

        self.install_meta(meta)?;

        let constructor: Arc<Handler> =
            Arc::new(move |stack, args| constructor.fn_call(stack, args));

        self.constants.insert(
            Hash::instance_function(type_hash, Protocol::INTO_TYPE_NAME),
            ConstValue::String(item.to_string()),
        );

        let signature = ContextSignature::Function {
            type_hash,
            item,
            args: Some(args),
        };

        if let Some(old) = self.functions_info.insert(hash, signature) {
            return Err(ContextError::ConflictingFunction {
                signature: old,
                hash,
            });
        }
        self.functions.insert(hash, constructor);
        Ok(())
    }
/// Add a piece of internal tuple meta.
Add a piece of internal tuple meta.
Add a piece of internal tuple meta .
fn add_internal_tuple<C, Args>(
        &mut self,
        enum_item: Option<Item>,
        item: Item,
        args: usize,
        constructor: C,
    ) -> Result<(), ContextError>
    where
        C: crate::module::Function<Args>,
        C::Return: TypeOf,
    {
        let type_hash = <C::Return as TypeOf>::type_hash();
        let hash = Hash::type_hash(&item);
        let tuple = CompileMetaTuple { args, hash };
        let meta = match enum_item {
            Some(enum_item) => CompileMeta {
                item: Arc::new(item.clone().into()),
                kind: CompileMetaKind::TupleVariant {
                    type_hash,
                    enum_item,
                    tuple,
                },
                source: None,
            },
            None => CompileMeta {
                item: Arc::new(item.clone().into()),
                kind: CompileMetaKind::TupleStruct { type_hash, tuple },
                source: None,
            },
        };
        self.install_meta(meta)?;
        let constructor: Arc<Handler> =
            Arc::new(move |stack, args| constructor.fn_call(stack, args));
        self.constants.insert(
            Hash::instance_function(type_hash, Protocol::INTO_TYPE_NAME),
            ConstValue::String(item.to_string()),
        );
        let signature = ContextSignature::Function {
            type_hash,
            item,
            args: Some(args),
        };
        if let Some(old) = self.functions_info.insert(hash, signature) {
            return Err(ContextError::ConflictingFunction {
                signature: old,
                hash,
            });
        }
        self.functions.insert(hash, constructor);
        Ok(())
    }
fn add_internal_tuple < C , Args > ( & mut self , enum_item : Option < Item > , item : Item , args : usize , constructor : C , ) -> Result < ( ) , ContextError > where C : crate :: module :: Function < Args > , C :: Return : TypeOf , { let type_hash = < C :: Return as TypeOf > :: type_hash ( ) ; let hash = Hash :: type_hash ( & item ) ; let tuple = CompileMetaTuple { args , hash } ; let meta = match enum_item { Some ( enum_item ) => CompileMeta { item : Arc :: new ( item . clone ( ) . into ( ) ) , kind : CompileMetaKind :: TupleVariant { type_hash , enum_item , tuple , } , source : None , } , None => CompileMeta { item : Arc :: new ( item . clone ( ) . into ( ) ) , kind : CompileMetaKind :: TupleStruct { type_hash , tuple } , source : None , } , } ; self . install_meta ( meta ) ? ; let constructor : Arc < Handler > = Arc :: new ( move | stack , args | constructor . fn_call ( stack , args ) ) ; self . constants . insert ( Hash :: instance_function ( type_hash , Protocol :: INTO_TYPE_NAME ) , ConstValue :: String ( item . to_string ( ) ) , ) ; let signature = ContextSignature :: Function { type_hash , item , args : Some ( args ) , } ; if let Some ( old ) = self . functions_info . insert ( hash , signature ) { return Err ( ContextError :: ConflictingFunction { signature : old , hash , } ) ; } self . functions . insert ( hash , constructor ) ; Ok ( ( ) ) }
Add a piece of internal tuple meta.
Add a piece of internal tuple meta .
&mut self
enum_item
Option<Item>
item
Item
args
usize
constructor
C
&mut self
enum_item
Option<Item>
item
Item
args
usize
constructor
C