MCPcopy
hub / github.com/hylang/hy / compile_function_def

Function compile_function_def

hy/core/result_macros.py:1625–1638  ·  view source on GitHub ↗
(compiler, expr, root, is_async, decorators, tp, name, params, body)

Source from the content-addressed store, hash-verified

1623 lambda_list,
1624 many(FORM)])
1625def compile_function_def(compiler, expr, root, is_async, decorators, tp, name, params, body):
1626 name, returns = name
1627 node = asty.AsyncFunctionDef if is_async else asty.FunctionDef
1628 decorators, ret, _ = compiler._compile_collect(decorators[0] if decorators else [])
1629 args, ret2 = compile_lambda_list(compiler, params)
1630 ret += ret2
1631 name = mangle(compiler._nonconst(name))
1632 compiler.scope.define(name)
1633 with compiler.local_state(), compiler.scope.create(ScopeFn, args, is_async) as scope:
1634 body = compiler._compile_branch(body)
1635
1636 return ret + compile_function_node(
1637 compiler, expr, node, decorators, tp, name, args, returns, body, scope
1638 )
1639
1640
1641def compile_function_node(compiler, expr, node, decorators, tp, name, args, returns, body, scope):

Callers

nothing calls this directly

Calls 9

mangleFunction · 0.90
compile_lambda_listFunction · 0.85
compile_function_nodeFunction · 0.85
_compile_collectMethod · 0.80
_nonconstMethod · 0.80
local_stateMethod · 0.80
createMethod · 0.80
_compile_branchMethod · 0.80
defineMethod · 0.45

Tested by

no test coverage detected