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

Function genFunctionExpression

packages/compiler-core/src/codegen.ts:934–977  ·  view source on GitHub ↗
(
  node: FunctionExpression,
  context: CodegenContext,
)

Source from the content-addressed store, hash-verified

932}
933
934function genFunctionExpression(
935 node: FunctionExpression,
936 context: CodegenContext,
937) {
938 const { push, indent, deindent } = context
939 const { params, returns, body, newline, isSlot } = node
940 if (isSlot) {
941 // wrap slot functions with owner context
942 push(`_${helperNameMap[WITH_CTX]}(`)
943 }
944 push(`(`, NewlineType.None, node)
945 if (isArray(params)) {
946 genNodeList(params, context)
947 } else if (params) {
948 genNode(params, context)
949 }
950 push(`) => `)
951 if (newline || body) {
952 push(`{`)
953 indent()
954 }
955 if (returns) {
956 if (newline) {
957 push(`return `)
958 }
959 if (isArray(returns)) {
960 genNodeListAsArray(returns, context)
961 } else {
962 genNode(returns, context)
963 }
964 } else if (body) {
965 genNode(body, context)
966 }
967 if (newline || body) {
968 deindent()
969 push(`}`)
970 }
971 if (isSlot) {
972 if (__COMPAT__ && node.isNonScopedSlot) {
973 push(`, undefined, true`)
974 }
975 push(`)`)
976 }
977}
978
979function genConditionalExpression(
980 node: ConditionalExpression,

Callers 1

genNodeFunction · 0.85

Calls 6

genNodeListFunction · 0.85
genNodeFunction · 0.85
indentFunction · 0.85
genNodeListAsArrayFunction · 0.85
deindentFunction · 0.85
pushFunction · 0.70

Tested by

no test coverage detected