| 1013 | } |
| 1014 | |
| 1015 | function genCacheExpression(node: CacheExpression, context: CodegenContext) { |
| 1016 | const { push, helper, indent, deindent, newline } = context |
| 1017 | const { needPauseTracking, needArraySpread } = node |
| 1018 | if (needArraySpread) { |
| 1019 | push(`[...(`) |
| 1020 | } |
| 1021 | push(`_cache[${node.index}] || (`) |
| 1022 | if (needPauseTracking) { |
| 1023 | indent() |
| 1024 | push(`${helper(SET_BLOCK_TRACKING)}(-1`) |
| 1025 | if (node.inVOnce) push(`, true`) |
| 1026 | push(`),`) |
| 1027 | newline() |
| 1028 | push(`(`) |
| 1029 | } |
| 1030 | push(`_cache[${node.index}] = `) |
| 1031 | genNode(node.value, context) |
| 1032 | if (needPauseTracking) { |
| 1033 | push(`).cacheIndex = ${node.index},`) |
| 1034 | newline() |
| 1035 | push(`${helper(SET_BLOCK_TRACKING)}(1),`) |
| 1036 | newline() |
| 1037 | push(`_cache[${node.index}]`) |
| 1038 | deindent() |
| 1039 | } |
| 1040 | push(`)`) |
| 1041 | if (needArraySpread) { |
| 1042 | push(`)]`) |
| 1043 | } |
| 1044 | } |
| 1045 | |
| 1046 | function genTemplateLiteral(node: TemplateLiteral, context: CodegenContext) { |
| 1047 | const { push, indent, deindent } = context |