fn load_type_kind(&mut self, kind: ast::TypeKind) -> TypeKind {
        use self::ast::TypeKind::*;

        match kind {
            // Primitives
            Boolean => TypeKind::Primitive(Primitive::Bool),
            Byte => TypeKind::Primitive(Primitive::I8),
            Octet => TypeKind::Primitive(Primitive::U8),
            SignedShort => TypeKind::Primitive(Primitive::I16),
            UnsignedShort => TypeKind::Primitive(Primitive::U16),
            SignedLong => TypeKind::Primitive(Primitive::I32),
            UnsignedLong => TypeKind::Primitive(Primitive::U32),
            SignedLongLong => TypeKind::Primitive(Primitive::I64),
            UnsignedLongLong => TypeKind::Primitive(Primitive::U64),
            RestrictedFloat | UnrestrictedFloat => TypeKind::Primitive(Primitive::F32),
            RestrictedDouble | UnrestrictedDouble => TypeKind::Primitive(Primitive::F64),

            // Strings
            DOMString | USVString => TypeKind::String,
            ByteString => unimplemented!(),

            // TypedArrays
            Int8Array => TypeKind::TypedArray(Primitive::I8),
            Uint8Array => TypeKind::TypedArray(Primitive::U8),
            Int16Array => TypeKind::TypedArray(Primitive::I16),
            Uint16Array => TypeKind::TypedArray(Primitive::U16),
            Int32Array => TypeKind::TypedArray(Primitive::I32),
            Uint32Array => TypeKind::TypedArray(Primitive::U32),
            Float32Array => TypeKind::TypedArray(Primitive::F32),
            Float64Array => TypeKind::TypedArray(Primitive::F64),

            // Sequence
            Sequence(inner) => TypeKind::Sequence(Box::new(self.load_type(*inner))),

            // Identifier
            Identifier(s) => match &*s {
                "BufferSource" => TypeKind::BufferSource,
                "HTMLCanvasElement" => TypeKind::CanvasElement,
                "ArrayBufferView" => TypeKind::ArrayBufferView,
                other => TypeKind::Named(other.into()),
            },

            // Composite
            Union(inners) => {
                if inners.len() <= 2 {
                    TypeKind::Union(
                        inners
                            .into_iter()
                            .map(|inner| self.load_type(inner))
                            .collect(),
                    )
                } else {
                    TypeKind::Any
                }
            },

            // Misc
            ArrayBuffer => TypeKind::ArrayBuffer,
            Object => TypeKind::Object,
            _ => TypeKind::Any,
        }
    }
// Convert an AST type kind into a type kind the generator can understand
Convert an AST type kind into a type kind the generator can understand
Convert an AST type kind into a type kind the generator can understand
fn load_type_kind(&mut self, kind: ast::TypeKind) -> TypeKind {
        use self::ast::TypeKind::*;
        match kind {
            // Primitives
            Boolean => TypeKind::Primitive(Primitive::Bool),
            Byte => TypeKind::Primitive(Primitive::I8),
            Octet => TypeKind::Primitive(Primitive::U8),
            SignedShort => TypeKind::Primitive(Primitive::I16),
            UnsignedShort => TypeKind::Primitive(Primitive::U16),
            SignedLong => TypeKind::Primitive(Primitive::I32),
            UnsignedLong => TypeKind::Primitive(Primitive::U32),
            SignedLongLong => TypeKind::Primitive(Primitive::I64),
            UnsignedLongLong => TypeKind::Primitive(Primitive::U64),
            RestrictedFloat | UnrestrictedFloat => TypeKind::Primitive(Primitive::F32),
            RestrictedDouble | UnrestrictedDouble => TypeKind::Primitive(Primitive::F64),
            // Strings
            DOMString | USVString => TypeKind::String,
            ByteString => unimplemented!(),
            // TypedArrays
            Int8Array => TypeKind::TypedArray(Primitive::I8),
            Uint8Array => TypeKind::TypedArray(Primitive::U8),
            Int16Array => TypeKind::TypedArray(Primitive::I16),
            Uint16Array => TypeKind::TypedArray(Primitive::U16),
            Int32Array => TypeKind::TypedArray(Primitive::I32),
            Uint32Array => TypeKind::TypedArray(Primitive::U32),
            Float32Array => TypeKind::TypedArray(Primitive::F32),
            Float64Array => TypeKind::TypedArray(Primitive::F64),
            // Sequence
            Sequence(inner) => TypeKind::Sequence(Box::new(self.load_type(*inner))),
            // Identifier
            Identifier(s) => match &*s {
                "BufferSource" => TypeKind::BufferSource,
                "HTMLCanvasElement" => TypeKind::CanvasElement,
                "ArrayBufferView" => TypeKind::ArrayBufferView,
                other => TypeKind::Named(other.into()),
            },
            // Composite
            Union(inners) => {
                if inners.len() <= 2 {
                    TypeKind::Union(
                        inners
                            .into_iter()
                            .map(|inner| self.load_type(inner))
                            .collect(),
                    )
                } else {
                    TypeKind::Any
                }
            },
            // Misc
            ArrayBuffer => TypeKind::ArrayBuffer,
            Object => TypeKind::Object,
            _ => TypeKind::Any,
        }
    }
fn load_type_kind ( & mut self , kind : ast :: TypeKind ) -> TypeKind { use self :: ast :: TypeKind :: * ; match kind { // Primitives Boolean => TypeKind :: Primitive ( Primitive :: Bool ) , Byte => TypeKind :: Primitive ( Primitive :: I8 ) , Octet => TypeKind :: Primitive ( Primitive :: U8 ) , SignedShort => TypeKind :: Primitive ( Primitive :: I16 ) , UnsignedShort => TypeKind :: Primitive ( Primitive :: U16 ) , SignedLong => TypeKind :: Primitive ( Primitive :: I32 ) , UnsignedLong => TypeKind :: Primitive ( Primitive :: U32 ) , SignedLongLong => TypeKind :: Primitive ( Primitive :: I64 ) , UnsignedLongLong => TypeKind :: Primitive ( Primitive :: U64 ) , RestrictedFloat | UnrestrictedFloat => TypeKind :: Primitive ( Primitive :: F32 ) , RestrictedDouble | UnrestrictedDouble => TypeKind :: Primitive ( Primitive :: F64 ) , // Strings DOMString | USVString => TypeKind :: String , ByteString => unimplemented ! ( ) , // TypedArrays Int8Array => TypeKind :: TypedArray ( Primitive :: I8 ) , Uint8Array => TypeKind :: TypedArray ( Primitive :: U8 ) , Int16Array => TypeKind :: TypedArray ( Primitive :: I16 ) , Uint16Array => TypeKind :: TypedArray ( Primitive :: U16 ) , Int32Array => TypeKind :: TypedArray ( Primitive :: I32 ) , Uint32Array => TypeKind :: TypedArray ( Primitive :: U32 ) , Float32Array => TypeKind :: TypedArray ( Primitive :: F32 ) , Float64Array => TypeKind :: TypedArray ( Primitive :: F64 ) , // Sequence Sequence ( inner ) => TypeKind :: Sequence ( Box :: new ( self . load_type ( * inner ) ) ) , // Identifier Identifier ( s ) => match & * s { " " => TypeKind :: BufferSource , " " => TypeKind :: CanvasElement , " " => TypeKind :: ArrayBufferView , other => TypeKind :: Named ( other . into ( ) ) , } , // Composite Union ( inners ) => { if inners . len ( ) <= 2 { TypeKind :: Union ( inners . into_iter ( ) . map ( | inner | self . load_type ( inner ) ) . collect ( ) , ) } else { TypeKind :: Any } } , // Misc ArrayBuffer => TypeKind :: ArrayBuffer , Object => TypeKind :: Object , _ => TypeKind :: Any , } }
Convert an AST type kind into a type kind the generator can understand
Convert an AST type kind into a type kind the generator can understand
&mut self
kind
ast::TypeKind