( node: Node, module: SourceModule, kindOfKey: KindOfKey )
| 3794 | } |
| 3795 | |
| 3796 | private transfer( |
| 3797 | node: Node, |
| 3798 | module: SourceModule, |
| 3799 | kindOfKey: KindOfKey |
| 3800 | ): KindBits { |
| 3801 | const cast = castOf(node) |
| 3802 | if (cast) { |
| 3803 | // a cast is data whatever reached it |
| 3804 | if ( |
| 3805 | this.annotatedKindOf(cast, module, () => kinds.unknown) === kinds.data |
| 3806 | ) |
| 3807 | return kinds.data |
| 3808 | return annotate( |
| 3809 | this.transfer(unwrapChain(node), module, kindOfKey), |
| 3810 | this.annotatedKindOf(cast, module, kindOfKey) |
| 3811 | ) |
| 3812 | } |
| 3813 | node = unwrapChain(node) |
| 3814 | const cached = |
| 3815 | this.bindingKindOfKeys.has(kindOfKey) ? |
| 3816 | undefined |
| 3817 | : this.kindsByNode.get(node) |
| 3818 | if (cached !== undefined) return cached |
| 3819 | switch (node.type) { |
| 3820 | case "Identifier": { |
| 3821 | const binding = module.scopes.byId.get(node)?.binding |
| 3822 | return binding ? kindOfKey(binding, module) : kinds.data |
| 3823 | } |
| 3824 | case "ArrowFunctionExpression": |
| 3825 | case "FunctionExpression": |
| 3826 | return functionKindOf(kindOfKey(node, module)) |
| 3827 | case "MemberExpression": { |
| 3828 | const exported = this.namespaceMemberOf(node, module) |
| 3829 | if (exported) return this.targetKindOf(exported, kindOfKey) |
| 3830 | return this.memberKindIn( |
| 3831 | node, |
| 3832 | { node: node.object, module, kindOfKey }, |
| 3833 | new Set() |
| 3834 | ) |
| 3835 | } |
| 3836 | case "CallExpression": |
| 3837 | case "TaggedTemplateExpression": |
| 3838 | return this.calledKindOf(node, module, kindOfKey) |
| 3839 | case "ConditionalExpression": |
| 3840 | return ( |
| 3841 | this.transfer(node.consequent, module, kindOfKey) | |
| 3842 | this.transfer(node.alternate, module, kindOfKey) |
| 3843 | ) |
| 3844 | case "LogicalExpression": |
| 3845 | return ( |
| 3846 | this.transfer(node.left, module, kindOfKey) | |
| 3847 | this.transfer(node.right, module, kindOfKey) |
| 3848 | ) |
| 3849 | case "SequenceExpression": |
| 3850 | return this.transfer( |
| 3851 | node.expressions[node.expressions.length - 1], |
| 3852 | module, |
| 3853 | kindOfKey |
no test coverage detected