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

Function compile_function_node

hy/core/result_macros.py:1641–1661  ·  view source on GitHub ↗
(compiler, expr, node, decorators, tp, name, args, returns, body, scope)

Source from the content-addressed store, hash-verified

1639
1640
1641def compile_function_node(compiler, expr, node, decorators, tp, name, args, returns, body, scope):
1642 ret = Result()
1643
1644 if body.expr:
1645 # implicitly return final expression,
1646 # except for async generators
1647 enode = asty.Expr if scope.is_async and scope.has_yield else asty.Return
1648 body += enode(body.expr, value=body.expr)
1649
1650 ret += node(
1651 expr,
1652 name=name,
1653 args=args,
1654 body=body.stmts or [asty.Pass(expr)],
1655 decorator_list=decorators,
1656 returns=compiler.compile(returns).force_expr if returns is not None else None,
1657 **digest_type_params(compiler, tp),
1658 )
1659
1660 ast_name = asty.Name(expr, id=name, ctx=ast.Load())
1661 return ret + Result(temp_variables=[ast_name, ret.stmts[-1]])
1662
1663
1664@pattern_macro(

Callers 2

compile_function_lambdaFunction · 0.85
compile_function_defFunction · 0.85

Calls 3

ResultClass · 0.90
digest_type_paramsFunction · 0.85
compileMethod · 0.80

Tested by

no test coverage detected