MCPcopy
hub / github.com/vuejs/core / genCacheExpression

Function genCacheExpression

packages/compiler-core/src/codegen.ts:1015–1044  ·  view source on GitHub ↗
(node: CacheExpression, context: CodegenContext)

Source from the content-addressed store, hash-verified

1013}
1014
1015function 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
1046function genTemplateLiteral(node: TemplateLiteral, context: CodegenContext) {
1047 const { push, indent, deindent } = context

Callers 1

genNodeFunction · 0.85

Calls 6

indentFunction · 0.85
newlineFunction · 0.85
genNodeFunction · 0.85
deindentFunction · 0.85
pushFunction · 0.70
helperFunction · 0.70

Tested by

no test coverage detected