partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
_ast_with_loc
Hydrate Generated Python AST nodes with line numbers and column offsets if they exist in the node environment.
src/basilisp/lang/compiler/generator.py
def _ast_with_loc( py_ast: GeneratedPyAST, env: NodeEnv, include_dependencies: bool = False ) -> GeneratedPyAST: """Hydrate Generated Python AST nodes with line numbers and column offsets if they exist in the node environment.""" if env.line is not None: py_ast.node.lineno = env.line if...
def _ast_with_loc( py_ast: GeneratedPyAST, env: NodeEnv, include_dependencies: bool = False ) -> GeneratedPyAST: """Hydrate Generated Python AST nodes with line numbers and column offsets if they exist in the node environment.""" if env.line is not None: py_ast.node.lineno = env.line if...
[ "Hydrate", "Generated", "Python", "AST", "nodes", "with", "line", "numbers", "and", "column", "offsets", "if", "they", "exist", "in", "the", "node", "environment", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L343-L362
[ "def", "_ast_with_loc", "(", "py_ast", ":", "GeneratedPyAST", ",", "env", ":", "NodeEnv", ",", "include_dependencies", ":", "bool", "=", "False", ")", "->", "GeneratedPyAST", ":", "if", "env", ".", "line", "is", "not", "None", ":", "py_ast", ".", "node", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_with_ast_loc
Wrap a generator function in a decorator to supply line and column information to the returned Python AST node. Dependency nodes will not be hydrated, functions whose returns need dependency nodes to be hydrated should use `_with_ast_loc_deps` below.
src/basilisp/lang/compiler/generator.py
def _with_ast_loc(f): """Wrap a generator function in a decorator to supply line and column information to the returned Python AST node. Dependency nodes will not be hydrated, functions whose returns need dependency nodes to be hydrated should use `_with_ast_loc_deps` below.""" @wraps(f) def wi...
def _with_ast_loc(f): """Wrap a generator function in a decorator to supply line and column information to the returned Python AST node. Dependency nodes will not be hydrated, functions whose returns need dependency nodes to be hydrated should use `_with_ast_loc_deps` below.""" @wraps(f) def wi...
[ "Wrap", "a", "generator", "function", "in", "a", "decorator", "to", "supply", "line", "and", "column", "information", "to", "the", "returned", "Python", "AST", "node", ".", "Dependency", "nodes", "will", "not", "be", "hydrated", "functions", "whose", "returns"...
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L365-L378
[ "def", "_with_ast_loc", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "with_lineno_and_col", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Node", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "GeneratedPyAST", ":", "py_ast",...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_with_ast_loc_deps
Wrap a generator function in a decorator to supply line and column information to the returned Python AST node and dependency nodes. Dependency nodes should likely only be included if they are new nodes created in the same function wrapped by this function. Otherwise, dependencies returned from e.g. ca...
src/basilisp/lang/compiler/generator.py
def _with_ast_loc_deps(f): """Wrap a generator function in a decorator to supply line and column information to the returned Python AST node and dependency nodes. Dependency nodes should likely only be included if they are new nodes created in the same function wrapped by this function. Otherwise, depe...
def _with_ast_loc_deps(f): """Wrap a generator function in a decorator to supply line and column information to the returned Python AST node and dependency nodes. Dependency nodes should likely only be included if they are new nodes created in the same function wrapped by this function. Otherwise, depe...
[ "Wrap", "a", "generator", "function", "in", "a", "decorator", "to", "supply", "line", "and", "column", "information", "to", "the", "returned", "Python", "AST", "node", "and", "dependency", "nodes", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L381-L397
[ "def", "_with_ast_loc_deps", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "with_lineno_and_col", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Node", ",", "*", "args", ",", "*", "*", "kwargs", ")", "->", "GeneratedPyAST", ":", "py_...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_is_dynamic
Return True if the Var holds a value which should be compiled to a dynamic Var access.
src/basilisp/lang/compiler/generator.py
def _is_dynamic(v: Var) -> bool: """Return True if the Var holds a value which should be compiled to a dynamic Var access.""" return ( Maybe(v.meta) .map(lambda m: m.get(SYM_DYNAMIC_META_KEY, None)) # type: ignore .or_else_get(False) )
def _is_dynamic(v: Var) -> bool: """Return True if the Var holds a value which should be compiled to a dynamic Var access.""" return ( Maybe(v.meta) .map(lambda m: m.get(SYM_DYNAMIC_META_KEY, None)) # type: ignore .or_else_get(False) )
[ "Return", "True", "if", "the", "Var", "holds", "a", "value", "which", "should", "be", "compiled", "to", "a", "dynamic", "Var", "access", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L400-L407
[ "def", "_is_dynamic", "(", "v", ":", "Var", ")", "->", "bool", ":", "return", "(", "Maybe", "(", "v", ".", "meta", ")", ".", "map", "(", "lambda", "m", ":", "m", ".", "get", "(", "SYM_DYNAMIC_META_KEY", ",", "None", ")", ")", "# type: ignore", ".",...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_is_redefable
Return True if the Var can be redefined.
src/basilisp/lang/compiler/generator.py
def _is_redefable(v: Var) -> bool: """Return True if the Var can be redefined.""" return ( Maybe(v.meta) .map(lambda m: m.get(SYM_REDEF_META_KEY, None)) # type: ignore .or_else_get(False) )
def _is_redefable(v: Var) -> bool: """Return True if the Var can be redefined.""" return ( Maybe(v.meta) .map(lambda m: m.get(SYM_REDEF_META_KEY, None)) # type: ignore .or_else_get(False) )
[ "Return", "True", "if", "the", "Var", "can", "be", "redefined", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L410-L416
[ "def", "_is_redefable", "(", "v", ":", "Var", ")", "->", "bool", ":", "return", "(", "Maybe", "(", "v", ".", "meta", ")", ".", "map", "(", "lambda", "m", ":", "m", ".", "get", "(", "SYM_REDEF_META_KEY", ",", "None", ")", ")", "# type: ignore", ".",...
3d82670ee218ec64eb066289c82766d14d18cc92
test
statementize
Transform non-statements into ast.Expr nodes so they can stand alone as statements.
src/basilisp/lang/compiler/generator.py
def statementize(e: ast.AST) -> ast.AST: """Transform non-statements into ast.Expr nodes so they can stand alone as statements.""" # noinspection PyPep8 if isinstance( e, ( ast.Assign, ast.AnnAssign, ast.AugAssign, ast.Expr, ast...
def statementize(e: ast.AST) -> ast.AST: """Transform non-statements into ast.Expr nodes so they can stand alone as statements.""" # noinspection PyPep8 if isinstance( e, ( ast.Assign, ast.AnnAssign, ast.AugAssign, ast.Expr, ast...
[ "Transform", "non", "-", "statements", "into", "ast", ".", "Expr", "nodes", "so", "they", "can", "stand", "alone", "as", "statements", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L496-L532
[ "def", "statementize", "(", "e", ":", "ast", ".", "AST", ")", "->", "ast", ".", "AST", ":", "# noinspection PyPep8", "if", "isinstance", "(", "e", ",", "(", "ast", ".", "Assign", ",", "ast", ".", "AnnAssign", ",", "ast", ".", "AugAssign", ",", "ast",...
3d82670ee218ec64eb066289c82766d14d18cc92
test
expressionize
Given a series of expression AST nodes, create a function AST node with the given name that can be called and will return the result of the final expression in the input body nodes. This helps to fix the impedance mismatch of Python, which includes statements and expressions, and Lisps, which have only...
src/basilisp/lang/compiler/generator.py
def expressionize( body: GeneratedPyAST, fn_name: str, args: Optional[Iterable[ast.arg]] = None, vargs: Optional[ast.arg] = None, ) -> ast.FunctionDef: """Given a series of expression AST nodes, create a function AST node with the given name that can be called and will return the result of t...
def expressionize( body: GeneratedPyAST, fn_name: str, args: Optional[Iterable[ast.arg]] = None, vargs: Optional[ast.arg] = None, ) -> ast.FunctionDef: """Given a series of expression AST nodes, create a function AST node with the given name that can be called and will return the result of t...
[ "Given", "a", "series", "of", "expression", "AST", "nodes", "create", "a", "function", "AST", "node", "with", "the", "given", "name", "that", "can", "be", "called", "and", "will", "return", "the", "result", "of", "the", "final", "expression", "in", "the", ...
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L535-L565
[ "def", "expressionize", "(", "body", ":", "GeneratedPyAST", ",", "fn_name", ":", "str", ",", "args", ":", "Optional", "[", "Iterable", "[", "ast", ".", "arg", "]", "]", "=", "None", ",", "vargs", ":", "Optional", "[", "ast", ".", "arg", "]", "=", "...
3d82670ee218ec64eb066289c82766d14d18cc92
test
__should_warn_on_redef
Return True if the compiler should emit a warning about this name being redefined.
src/basilisp/lang/compiler/generator.py
def __should_warn_on_redef( ctx: GeneratorContext, defsym: sym.Symbol, safe_name: str, def_meta: lmap.Map ) -> bool: """Return True if the compiler should emit a warning about this name being redefined.""" no_warn_on_redef = def_meta.entry(SYM_NO_WARN_ON_REDEF_META_KEY, False) if no_warn_on_redef: ...
def __should_warn_on_redef( ctx: GeneratorContext, defsym: sym.Symbol, safe_name: str, def_meta: lmap.Map ) -> bool: """Return True if the compiler should emit a warning about this name being redefined.""" no_warn_on_redef = def_meta.entry(SYM_NO_WARN_ON_REDEF_META_KEY, False) if no_warn_on_redef: ...
[ "Return", "True", "if", "the", "compiler", "should", "emit", "a", "warning", "about", "this", "name", "being", "redefined", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L582-L602
[ "def", "__should_warn_on_redef", "(", "ctx", ":", "GeneratorContext", ",", "defsym", ":", "sym", ".", "Symbol", ",", "safe_name", ":", "str", ",", "def_meta", ":", "lmap", ".", "Map", ")", "->", "bool", ":", "no_warn_on_redef", "=", "def_meta", ".", "entry...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_def_to_py_ast
Return a Python AST Node for a `def` expression.
src/basilisp/lang/compiler/generator.py
def _def_to_py_ast( # pylint: disable=too-many-branches ctx: GeneratorContext, node: Def ) -> GeneratedPyAST: """Return a Python AST Node for a `def` expression.""" assert node.op == NodeOp.DEF defsym = node.name is_defn = False if node.init is not None: # Since Python function defini...
def _def_to_py_ast( # pylint: disable=too-many-branches ctx: GeneratorContext, node: Def ) -> GeneratedPyAST: """Return a Python AST Node for a `def` expression.""" assert node.op == NodeOp.DEF defsym = node.name is_defn = False if node.init is not None: # Since Python function defini...
[ "Return", "a", "Python", "AST", "Node", "for", "a", "def", "expression", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L606-L704
[ "def", "_def_to_py_ast", "(", "# pylint: disable=too-many-branches", "ctx", ":", "GeneratorContext", ",", "node", ":", "Def", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "DEF", "defsym", "=", "node", ".", "name", "is_def...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_deftype_to_py_ast
Return a Python AST Node for a `deftype*` expression.
src/basilisp/lang/compiler/generator.py
def _deftype_to_py_ast( # pylint: disable=too-many-branches ctx: GeneratorContext, node: DefType ) -> GeneratedPyAST: """Return a Python AST Node for a `deftype*` expression.""" assert node.op == NodeOp.DEFTYPE type_name = munge(node.name) ctx.symbol_table.new_symbol(sym.symbol(node.name), type_nam...
def _deftype_to_py_ast( # pylint: disable=too-many-branches ctx: GeneratorContext, node: DefType ) -> GeneratedPyAST: """Return a Python AST Node for a `deftype*` expression.""" assert node.op == NodeOp.DEFTYPE type_name = munge(node.name) ctx.symbol_table.new_symbol(sym.symbol(node.name), type_nam...
[ "Return", "a", "Python", "AST", "Node", "for", "a", "deftype", "*", "expression", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L748-L808
[ "def", "_deftype_to_py_ast", "(", "# pylint: disable=too-many-branches", "ctx", ":", "GeneratorContext", ",", "node", ":", "DefType", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "DEFTYPE", "type_name", "=", "munge", "(", "...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_do_to_py_ast
Return a Python AST Node for a `do` expression.
src/basilisp/lang/compiler/generator.py
def _do_to_py_ast(ctx: GeneratorContext, node: Do) -> GeneratedPyAST: """Return a Python AST Node for a `do` expression.""" assert node.op == NodeOp.DO assert not node.is_body body_ast = GeneratedPyAST.reduce( *map(partial(gen_py_ast, ctx), chain(node.statements, [node.ret])) ) fn_body...
def _do_to_py_ast(ctx: GeneratorContext, node: Do) -> GeneratedPyAST: """Return a Python AST Node for a `do` expression.""" assert node.op == NodeOp.DO assert not node.is_body body_ast = GeneratedPyAST.reduce( *map(partial(gen_py_ast, ctx), chain(node.statements, [node.ret])) ) fn_body...
[ "Return", "a", "Python", "AST", "Node", "for", "a", "do", "expression", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L812-L832
[ "def", "_do_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Do", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "DO", "assert", "not", "node", ".", "is_body", "body_ast", "=", "GeneratedPyAST", ".", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_synthetic_do_to_py_ast
Return AST elements generated from reducing a synthetic Lisp :do node (e.g. a :do node which acts as a body for another node).
src/basilisp/lang/compiler/generator.py
def _synthetic_do_to_py_ast(ctx: GeneratorContext, node: Do) -> GeneratedPyAST: """Return AST elements generated from reducing a synthetic Lisp :do node (e.g. a :do node which acts as a body for another node).""" assert node.op == NodeOp.DO assert node.is_body # TODO: investigate how to handle recu...
def _synthetic_do_to_py_ast(ctx: GeneratorContext, node: Do) -> GeneratedPyAST: """Return AST elements generated from reducing a synthetic Lisp :do node (e.g. a :do node which acts as a body for another node).""" assert node.op == NodeOp.DO assert node.is_body # TODO: investigate how to handle recu...
[ "Return", "AST", "elements", "generated", "from", "reducing", "a", "synthetic", "Lisp", ":", "do", "node", "(", "e", ".", "g", ".", "a", ":", "do", "node", "which", "acts", "as", "a", "body", "for", "another", "node", ")", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L836-L846
[ "def", "_synthetic_do_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Do", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "DO", "assert", "node", ".", "is_body", "# TODO: investigate how to handle recur in n...
3d82670ee218ec64eb066289c82766d14d18cc92
test
__fn_name
Generate a safe Python function name from a function name symbol. If no symbol is provided, generate a name with a default prefix.
src/basilisp/lang/compiler/generator.py
def __fn_name(s: Optional[str]) -> str: """Generate a safe Python function name from a function name symbol. If no symbol is provided, generate a name with a default prefix.""" return genname("__" + munge(Maybe(s).or_else_get(_FN_PREFIX)))
def __fn_name(s: Optional[str]) -> str: """Generate a safe Python function name from a function name symbol. If no symbol is provided, generate a name with a default prefix.""" return genname("__" + munge(Maybe(s).or_else_get(_FN_PREFIX)))
[ "Generate", "a", "safe", "Python", "function", "name", "from", "a", "function", "name", "symbol", ".", "If", "no", "symbol", "is", "provided", "generate", "a", "name", "with", "a", "default", "prefix", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L852-L855
[ "def", "__fn_name", "(", "s", ":", "Optional", "[", "str", "]", ")", "->", "str", ":", "return", "genname", "(", "\"__\"", "+", "munge", "(", "Maybe", "(", "s", ")", ".", "or_else_get", "(", "_FN_PREFIX", ")", ")", ")" ]
3d82670ee218ec64eb066289c82766d14d18cc92
test
__fn_args_to_py_ast
Generate a list of Python AST nodes from function method parameters.
src/basilisp/lang/compiler/generator.py
def __fn_args_to_py_ast( ctx: GeneratorContext, params: Iterable[Binding], body: Do ) -> Tuple[List[ast.arg], Optional[ast.arg], List[ast.AST]]: """Generate a list of Python AST nodes from function method parameters.""" fn_args, varg = [], None fn_body_ast: List[ast.AST] = [] for binding in params: ...
def __fn_args_to_py_ast( ctx: GeneratorContext, params: Iterable[Binding], body: Do ) -> Tuple[List[ast.arg], Optional[ast.arg], List[ast.AST]]: """Generate a list of Python AST nodes from function method parameters.""" fn_args, varg = [], None fn_body_ast: List[ast.AST] = [] for binding in params: ...
[ "Generate", "a", "list", "of", "Python", "AST", "nodes", "from", "function", "method", "parameters", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L858-L895
[ "def", "__fn_args_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "params", ":", "Iterable", "[", "Binding", "]", ",", "body", ":", "Do", ")", "->", "Tuple", "[", "List", "[", "ast", ".", "arg", "]", ",", "Optional", "[", "ast", ".", "arg", "]"...
3d82670ee218ec64eb066289c82766d14d18cc92
test
__single_arity_fn_to_py_ast
Return a Python AST node for a function with a single arity.
src/basilisp/lang/compiler/generator.py
def __single_arity_fn_to_py_ast( ctx: GeneratorContext, node: Fn, method: FnMethod, def_name: Optional[str] = None, meta_node: Optional[MetaNode] = None, ) -> GeneratedPyAST: """Return a Python AST node for a function with a single arity.""" assert node.op == NodeOp.FN assert method.op =...
def __single_arity_fn_to_py_ast( ctx: GeneratorContext, node: Fn, method: FnMethod, def_name: Optional[str] = None, meta_node: Optional[MetaNode] = None, ) -> GeneratedPyAST: """Return a Python AST node for a function with a single arity.""" assert node.op == NodeOp.FN assert method.op =...
[ "Return", "a", "Python", "AST", "node", "for", "a", "function", "with", "a", "single", "arity", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L918-L976
[ "def", "__single_arity_fn_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Fn", ",", "method", ":", "FnMethod", ",", "def_name", ":", "Optional", "[", "str", "]", "=", "None", ",", "meta_node", ":", "Optional", "[", "MetaNode", "]", "=",...
3d82670ee218ec64eb066289c82766d14d18cc92
test
__multi_arity_dispatch_fn
Return the Python AST nodes for a argument-length dispatch function for multi-arity functions. def fn(*args): nargs = len(args) method = __fn_dispatch_map.get(nargs) if method: return method(*args) # Only if default if nargs > max_fixed_arity: ret...
src/basilisp/lang/compiler/generator.py
def __multi_arity_dispatch_fn( # pylint: disable=too-many-arguments,too-many-locals ctx: GeneratorContext, name: str, arity_map: Mapping[int, str], default_name: Optional[str] = None, max_fixed_arity: Optional[int] = None, meta_node: Optional[MetaNode] = None, is_async: bool = False, ) -> G...
def __multi_arity_dispatch_fn( # pylint: disable=too-many-arguments,too-many-locals ctx: GeneratorContext, name: str, arity_map: Mapping[int, str], default_name: Optional[str] = None, max_fixed_arity: Optional[int] = None, meta_node: Optional[MetaNode] = None, is_async: bool = False, ) -> G...
[ "Return", "the", "Python", "AST", "nodes", "for", "a", "argument", "-", "length", "dispatch", "function", "for", "multi", "-", "arity", "functions", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L987-L1135
[ "def", "__multi_arity_dispatch_fn", "(", "# pylint: disable=too-many-arguments,too-many-locals", "ctx", ":", "GeneratorContext", ",", "name", ":", "str", ",", "arity_map", ":", "Mapping", "[", "int", ",", "str", "]", ",", "default_name", ":", "Optional", "[", "str",...
3d82670ee218ec64eb066289c82766d14d18cc92
test
__multi_arity_fn_to_py_ast
Return a Python AST node for a function with multiple arities.
src/basilisp/lang/compiler/generator.py
def __multi_arity_fn_to_py_ast( # pylint: disable=too-many-locals ctx: GeneratorContext, node: Fn, methods: Collection[FnMethod], def_name: Optional[str] = None, meta_node: Optional[MetaNode] = None, ) -> GeneratedPyAST: """Return a Python AST node for a function with multiple arities.""" a...
def __multi_arity_fn_to_py_ast( # pylint: disable=too-many-locals ctx: GeneratorContext, node: Fn, methods: Collection[FnMethod], def_name: Optional[str] = None, meta_node: Optional[MetaNode] = None, ) -> GeneratedPyAST: """Return a Python AST node for a function with multiple arities.""" a...
[ "Return", "a", "Python", "AST", "node", "for", "a", "function", "with", "multiple", "arities", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1139-L1209
[ "def", "__multi_arity_fn_to_py_ast", "(", "# pylint: disable=too-many-locals", "ctx", ":", "GeneratorContext", ",", "node", ":", "Fn", ",", "methods", ":", "Collection", "[", "FnMethod", "]", ",", "def_name", ":", "Optional", "[", "str", "]", "=", "None", ",", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_fn_to_py_ast
Return a Python AST Node for a `fn` expression.
src/basilisp/lang/compiler/generator.py
def _fn_to_py_ast( ctx: GeneratorContext, node: Fn, def_name: Optional[str] = None, meta_node: Optional[MetaNode] = None, ) -> GeneratedPyAST: """Return a Python AST Node for a `fn` expression.""" assert node.op == NodeOp.FN if len(node.methods) == 1: return __single_arity_fn_to_py_a...
def _fn_to_py_ast( ctx: GeneratorContext, node: Fn, def_name: Optional[str] = None, meta_node: Optional[MetaNode] = None, ) -> GeneratedPyAST: """Return a Python AST Node for a `fn` expression.""" assert node.op == NodeOp.FN if len(node.methods) == 1: return __single_arity_fn_to_py_a...
[ "Return", "a", "Python", "AST", "Node", "for", "a", "fn", "expression", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1213-L1228
[ "def", "_fn_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Fn", ",", "def_name", ":", "Optional", "[", "str", "]", "=", "None", ",", "meta_node", ":", "Optional", "[", "MetaNode", "]", "=", "None", ",", ")", "->", "GeneratedPyAST", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
__if_body_to_py_ast
Generate custom `if` nodes to handle `recur` bodies. Recur nodes can appear in the then and else expressions of `if` forms. Recur nodes generate Python `continue` statements, which we would otherwise attempt to insert directly into an expression. Python will complain if it finds a statement in an expre...
src/basilisp/lang/compiler/generator.py
def __if_body_to_py_ast( ctx: GeneratorContext, node: Node, result_name: str ) -> GeneratedPyAST: """Generate custom `if` nodes to handle `recur` bodies. Recur nodes can appear in the then and else expressions of `if` forms. Recur nodes generate Python `continue` statements, which we would otherwise ...
def __if_body_to_py_ast( ctx: GeneratorContext, node: Node, result_name: str ) -> GeneratedPyAST: """Generate custom `if` nodes to handle `recur` bodies. Recur nodes can appear in the then and else expressions of `if` forms. Recur nodes generate Python `continue` statements, which we would otherwise ...
[ "Generate", "custom", "if", "nodes", "to", "handle", "recur", "bodies", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1232-L1261
[ "def", "__if_body_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Node", ",", "result_name", ":", "str", ")", "->", "GeneratedPyAST", ":", "if", "node", ".", "op", "==", "NodeOp", ".", "RECUR", "and", "ctx", ".", "recur_point", ".", "...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_if_to_py_ast
Generate an intermediate if statement which assigns to a temporary variable, which is returned as the expression value at the end of evaluation. Every expression in Basilisp is true if it is not the literal values nil or false. This function compiles direct checks for the test value against the Pyt...
src/basilisp/lang/compiler/generator.py
def _if_to_py_ast(ctx: GeneratorContext, node: If) -> GeneratedPyAST: """Generate an intermediate if statement which assigns to a temporary variable, which is returned as the expression value at the end of evaluation. Every expression in Basilisp is true if it is not the literal values nil or false...
def _if_to_py_ast(ctx: GeneratorContext, node: If) -> GeneratedPyAST: """Generate an intermediate if statement which assigns to a temporary variable, which is returned as the expression value at the end of evaluation. Every expression in Basilisp is true if it is not the literal values nil or false...
[ "Generate", "an", "intermediate", "if", "statement", "which", "assigns", "to", "a", "temporary", "variable", "which", "is", "returned", "as", "the", "expression", "value", "at", "the", "end", "of", "evaluation", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1265-L1314
[ "def", "_if_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "If", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "IF", "test_ast", "=", "gen_py_ast", "(", "ctx", ",", "node", ".", "test", ")", "re...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_import_to_py_ast
Return a Python AST node for a Basilisp `import*` expression.
src/basilisp/lang/compiler/generator.py
def _import_to_py_ast(ctx: GeneratorContext, node: Import) -> GeneratedPyAST: """Return a Python AST node for a Basilisp `import*` expression.""" assert node.op == NodeOp.IMPORT last = None deps: List[ast.AST] = [] for alias in node.aliases: safe_name = munge(alias.name) try: ...
def _import_to_py_ast(ctx: GeneratorContext, node: Import) -> GeneratedPyAST: """Return a Python AST node for a Basilisp `import*` expression.""" assert node.op == NodeOp.IMPORT last = None deps: List[ast.AST] = [] for alias in node.aliases: safe_name = munge(alias.name) try: ...
[ "Return", "a", "Python", "AST", "node", "for", "a", "Basilisp", "import", "*", "expression", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1318-L1374
[ "def", "_import_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Import", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "IMPORT", "last", "=", "None", "deps", ":", "List", "[", "ast", ".", "AST", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_invoke_to_py_ast
Return a Python AST Node for a Basilisp function invocation.
src/basilisp/lang/compiler/generator.py
def _invoke_to_py_ast(ctx: GeneratorContext, node: Invoke) -> GeneratedPyAST: """Return a Python AST Node for a Basilisp function invocation.""" assert node.op == NodeOp.INVOKE fn_ast = gen_py_ast(ctx, node.fn) args_deps, args_nodes = _collection_ast(ctx, node.args) return GeneratedPyAST( ...
def _invoke_to_py_ast(ctx: GeneratorContext, node: Invoke) -> GeneratedPyAST: """Return a Python AST Node for a Basilisp function invocation.""" assert node.op == NodeOp.INVOKE fn_ast = gen_py_ast(ctx, node.fn) args_deps, args_nodes = _collection_ast(ctx, node.args) return GeneratedPyAST( ...
[ "Return", "a", "Python", "AST", "Node", "for", "a", "Basilisp", "function", "invocation", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1378-L1388
[ "def", "_invoke_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Invoke", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "INVOKE", "fn_ast", "=", "gen_py_ast", "(", "ctx", ",", "node", ".", "fn", ")...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_let_to_py_ast
Return a Python AST Node for a `let*` expression.
src/basilisp/lang/compiler/generator.py
def _let_to_py_ast(ctx: GeneratorContext, node: Let) -> GeneratedPyAST: """Return a Python AST Node for a `let*` expression.""" assert node.op == NodeOp.LET with ctx.new_symbol_table("let"): let_body_ast: List[ast.AST] = [] for binding in node.bindings: init_node = binding.init ...
def _let_to_py_ast(ctx: GeneratorContext, node: Let) -> GeneratedPyAST: """Return a Python AST Node for a `let*` expression.""" assert node.op == NodeOp.LET with ctx.new_symbol_table("let"): let_body_ast: List[ast.AST] = [] for binding in node.bindings: init_node = binding.init ...
[ "Return", "a", "Python", "AST", "Node", "for", "a", "let", "*", "expression", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1392-L1426
[ "def", "_let_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Let", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "LET", "with", "ctx", ".", "new_symbol_table", "(", "\"let\"", ")", ":", "let_body_as...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_loop_to_py_ast
Return a Python AST Node for a `loop*` expression.
src/basilisp/lang/compiler/generator.py
def _loop_to_py_ast(ctx: GeneratorContext, node: Loop) -> GeneratedPyAST: """Return a Python AST Node for a `loop*` expression.""" assert node.op == NodeOp.LOOP with ctx.new_symbol_table("loop"): binding_names = [] init_bindings: List[ast.AST] = [] for binding in node.bindings: ...
def _loop_to_py_ast(ctx: GeneratorContext, node: Loop) -> GeneratedPyAST: """Return a Python AST Node for a `loop*` expression.""" assert node.op == NodeOp.LOOP with ctx.new_symbol_table("loop"): binding_names = [] init_bindings: List[ast.AST] = [] for binding in node.bindings: ...
[ "Return", "a", "Python", "AST", "Node", "for", "a", "loop", "*", "expression", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1430-L1491
[ "def", "_loop_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Loop", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "LOOP", "with", "ctx", ".", "new_symbol_table", "(", "\"loop\"", ")", ":", "binding...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_quote_to_py_ast
Return a Python AST Node for a `quote` expression.
src/basilisp/lang/compiler/generator.py
def _quote_to_py_ast(ctx: GeneratorContext, node: Quote) -> GeneratedPyAST: """Return a Python AST Node for a `quote` expression.""" assert node.op == NodeOp.QUOTE return _const_node_to_py_ast(ctx, node.expr)
def _quote_to_py_ast(ctx: GeneratorContext, node: Quote) -> GeneratedPyAST: """Return a Python AST Node for a `quote` expression.""" assert node.op == NodeOp.QUOTE return _const_node_to_py_ast(ctx, node.expr)
[ "Return", "a", "Python", "AST", "Node", "for", "a", "quote", "expression", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1495-L1498
[ "def", "_quote_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Quote", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "QUOTE", "return", "_const_node_to_py_ast", "(", "ctx", ",", "node", ".", "expr", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
__fn_recur_to_py_ast
Return a Python AST node for `recur` occurring inside a `fn*`.
src/basilisp/lang/compiler/generator.py
def __fn_recur_to_py_ast(ctx: GeneratorContext, node: Recur) -> GeneratedPyAST: """Return a Python AST node for `recur` occurring inside a `fn*`.""" assert node.op == NodeOp.RECUR assert ctx.recur_point.is_variadic is not None recur_nodes: List[ast.AST] = [] recur_deps: List[ast.AST] = [] for ex...
def __fn_recur_to_py_ast(ctx: GeneratorContext, node: Recur) -> GeneratedPyAST: """Return a Python AST node for `recur` occurring inside a `fn*`.""" assert node.op == NodeOp.RECUR assert ctx.recur_point.is_variadic is not None recur_nodes: List[ast.AST] = [] recur_deps: List[ast.AST] = [] for ex...
[ "Return", "a", "Python", "AST", "node", "for", "recur", "occurring", "inside", "a", "fn", "*", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1502-L1522
[ "def", "__fn_recur_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Recur", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "RECUR", "assert", "ctx", ".", "recur_point", ".", "is_variadic", "is", "not", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
__deftype_method_recur_to_py_ast
Return a Python AST node for `recur` occurring inside a `deftype*` method.
src/basilisp/lang/compiler/generator.py
def __deftype_method_recur_to_py_ast( ctx: GeneratorContext, node: Recur ) -> GeneratedPyAST: """Return a Python AST node for `recur` occurring inside a `deftype*` method.""" assert node.op == NodeOp.RECUR recur_nodes: List[ast.AST] = [] recur_deps: List[ast.AST] = [] for expr in node.exprs: ...
def __deftype_method_recur_to_py_ast( ctx: GeneratorContext, node: Recur ) -> GeneratedPyAST: """Return a Python AST node for `recur` occurring inside a `deftype*` method.""" assert node.op == NodeOp.RECUR recur_nodes: List[ast.AST] = [] recur_deps: List[ast.AST] = [] for expr in node.exprs: ...
[ "Return", "a", "Python", "AST", "node", "for", "recur", "occurring", "inside", "a", "deftype", "*", "method", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1526-L1556
[ "def", "__deftype_method_recur_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Recur", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "RECUR", "recur_nodes", ":", "List", "[", "ast", ".", "AST", "]", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
__loop_recur_to_py_ast
Return a Python AST node for `recur` occurring inside a `loop`.
src/basilisp/lang/compiler/generator.py
def __loop_recur_to_py_ast(ctx: GeneratorContext, node: Recur) -> GeneratedPyAST: """Return a Python AST node for `recur` occurring inside a `loop`.""" assert node.op == NodeOp.RECUR recur_deps: List[ast.AST] = [] recur_targets: List[ast.Name] = [] recur_exprs: List[ast.AST] = [] for name, expr...
def __loop_recur_to_py_ast(ctx: GeneratorContext, node: Recur) -> GeneratedPyAST: """Return a Python AST node for `recur` occurring inside a `loop`.""" assert node.op == NodeOp.RECUR recur_deps: List[ast.AST] = [] recur_targets: List[ast.Name] = [] recur_exprs: List[ast.AST] = [] for name, expr...
[ "Return", "a", "Python", "AST", "node", "for", "recur", "occurring", "inside", "a", "loop", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1560-L1585
[ "def", "__loop_recur_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Recur", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "RECUR", "recur_deps", ":", "List", "[", "ast", ".", "AST", "]", "=", "["...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_recur_to_py_ast
Return a Python AST Node for a `recur` expression. Note that `recur` nodes can only legally appear in two AST locations: (1) in :then or :else expressions in :if nodes, and (2) in :ret expressions in :do nodes As such, both of these handlers special case the recur construct, as it is the only ...
src/basilisp/lang/compiler/generator.py
def _recur_to_py_ast(ctx: GeneratorContext, node: Recur) -> GeneratedPyAST: """Return a Python AST Node for a `recur` expression. Note that `recur` nodes can only legally appear in two AST locations: (1) in :then or :else expressions in :if nodes, and (2) in :ret expressions in :do nodes As su...
def _recur_to_py_ast(ctx: GeneratorContext, node: Recur) -> GeneratedPyAST: """Return a Python AST Node for a `recur` expression. Note that `recur` nodes can only legally appear in two AST locations: (1) in :then or :else expressions in :if nodes, and (2) in :ret expressions in :do nodes As su...
[ "Return", "a", "Python", "AST", "Node", "for", "a", "recur", "expression", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1595-L1612
[ "def", "_recur_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Recur", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "RECUR", "assert", "ctx", ".", "recur_point", "is", "not", "None", ",", "\"Must h...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_set_bang_to_py_ast
Return a Python AST Node for a `set!` expression.
src/basilisp/lang/compiler/generator.py
def _set_bang_to_py_ast(ctx: GeneratorContext, node: SetBang) -> GeneratedPyAST: """Return a Python AST Node for a `set!` expression.""" assert node.op == NodeOp.SET_BANG val_temp_name = genname("set_bang_val") val_ast = gen_py_ast(ctx, node.val) target = node.target assert isinstance( ...
def _set_bang_to_py_ast(ctx: GeneratorContext, node: SetBang) -> GeneratedPyAST: """Return a Python AST Node for a `set!` expression.""" assert node.op == NodeOp.SET_BANG val_temp_name = genname("set_bang_val") val_ast = gen_py_ast(ctx, node.val) target = node.target assert isinstance( ...
[ "Return", "a", "Python", "AST", "Node", "for", "a", "set!", "expression", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1616-L1654
[ "def", "_set_bang_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "SetBang", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "SET_BANG", "val_temp_name", "=", "genname", "(", "\"set_bang_val\"", ")", "val_...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_throw_to_py_ast
Return a Python AST Node for a `throw` expression.
src/basilisp/lang/compiler/generator.py
def _throw_to_py_ast(ctx: GeneratorContext, node: Throw) -> GeneratedPyAST: """Return a Python AST Node for a `throw` expression.""" assert node.op == NodeOp.THROW throw_fn = genname(_THROW_PREFIX) exc_ast = gen_py_ast(ctx, node.exception) raise_body = ast.Raise(exc=exc_ast.node, cause=None) r...
def _throw_to_py_ast(ctx: GeneratorContext, node: Throw) -> GeneratedPyAST: """Return a Python AST Node for a `throw` expression.""" assert node.op == NodeOp.THROW throw_fn = genname(_THROW_PREFIX) exc_ast = gen_py_ast(ctx, node.exception) raise_body = ast.Raise(exc=exc_ast.node, cause=None) r...
[ "Return", "a", "Python", "AST", "Node", "for", "a", "throw", "expression", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1658-L1684
[ "def", "_throw_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Throw", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "THROW", "throw_fn", "=", "genname", "(", "_THROW_PREFIX", ")", "exc_ast", "=", "...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_try_to_py_ast
Return a Python AST Node for a `try` expression.
src/basilisp/lang/compiler/generator.py
def _try_to_py_ast(ctx: GeneratorContext, node: Try) -> GeneratedPyAST: """Return a Python AST Node for a `try` expression.""" assert node.op == NodeOp.TRY try_expr_name = genname("try_expr") body_ast = _synthetic_do_to_py_ast(ctx, node.body) catch_handlers = list( map(partial(__catch_to_p...
def _try_to_py_ast(ctx: GeneratorContext, node: Try) -> GeneratedPyAST: """Return a Python AST Node for a `try` expression.""" assert node.op == NodeOp.TRY try_expr_name = genname("try_expr") body_ast = _synthetic_do_to_py_ast(ctx, node.body) catch_handlers = list( map(partial(__catch_to_p...
[ "Return", "a", "Python", "AST", "Node", "for", "a", "try", "expression", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1726-L1763
[ "def", "_try_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Try", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "TRY", "try_expr_name", "=", "genname", "(", "\"try_expr\"", ")", "body_ast", "=", "_...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_local_sym_to_py_ast
Generate a Python AST node for accessing a locally defined Python variable.
src/basilisp/lang/compiler/generator.py
def _local_sym_to_py_ast( ctx: GeneratorContext, node: Local, is_assigning: bool = False ) -> GeneratedPyAST: """Generate a Python AST node for accessing a locally defined Python variable.""" assert node.op == NodeOp.LOCAL sym_entry = ctx.symbol_table.find_symbol(sym.symbol(node.name)) assert sym_e...
def _local_sym_to_py_ast( ctx: GeneratorContext, node: Local, is_assigning: bool = False ) -> GeneratedPyAST: """Generate a Python AST node for accessing a locally defined Python variable.""" assert node.op == NodeOp.LOCAL sym_entry = ctx.symbol_table.find_symbol(sym.symbol(node.name)) assert sym_e...
[ "Generate", "a", "Python", "AST", "node", "for", "accessing", "a", "locally", "defined", "Python", "variable", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1772-L1796
[ "def", "_local_sym_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "Local", ",", "is_assigning", ":", "bool", "=", "False", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "LOCAL", "sym_entry", "=", "c...
3d82670ee218ec64eb066289c82766d14d18cc92
test
__var_find_to_py_ast
Generate Var.find calls for the named symbol.
src/basilisp/lang/compiler/generator.py
def __var_find_to_py_ast( var_name: str, ns_name: str, py_var_ctx: ast.AST ) -> GeneratedPyAST: """Generate Var.find calls for the named symbol.""" return GeneratedPyAST( node=ast.Attribute( value=ast.Call( func=_FIND_VAR_FN_NAME, args=[ ...
def __var_find_to_py_ast( var_name: str, ns_name: str, py_var_ctx: ast.AST ) -> GeneratedPyAST: """Generate Var.find calls for the named symbol.""" return GeneratedPyAST( node=ast.Attribute( value=ast.Call( func=_FIND_VAR_FN_NAME, args=[ ...
[ "Generate", "Var", ".", "find", "calls", "for", "the", "named", "symbol", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1799-L1819
[ "def", "__var_find_to_py_ast", "(", "var_name", ":", "str", ",", "ns_name", ":", "str", ",", "py_var_ctx", ":", "ast", ".", "AST", ")", "->", "GeneratedPyAST", ":", "return", "GeneratedPyAST", "(", "node", "=", "ast", ".", "Attribute", "(", "value", "=", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_var_sym_to_py_ast
Generate a Python AST node for accessing a Var. If the Var is marked as :dynamic or :redef or the compiler option USE_VAR_INDIRECTION is active, do not compile to a direct access. If the corresponding function name is not defined in a Python module, no direct variable access is possible and Var.find in...
src/basilisp/lang/compiler/generator.py
def _var_sym_to_py_ast( ctx: GeneratorContext, node: VarRef, is_assigning: bool = False ) -> GeneratedPyAST: """Generate a Python AST node for accessing a Var. If the Var is marked as :dynamic or :redef or the compiler option USE_VAR_INDIRECTION is active, do not compile to a direct access. If the ...
def _var_sym_to_py_ast( ctx: GeneratorContext, node: VarRef, is_assigning: bool = False ) -> GeneratedPyAST: """Generate a Python AST node for accessing a Var. If the Var is marked as :dynamic or :redef or the compiler option USE_VAR_INDIRECTION is active, do not compile to a direct access. If the ...
[ "Generate", "a", "Python", "AST", "node", "for", "accessing", "a", "Var", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1823-L1878
[ "def", "_var_sym_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "VarRef", ",", "is_assigning", ":", "bool", "=", "False", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "VAR", "var", "=", "node", "...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_interop_call_to_py_ast
Generate a Python AST node for Python interop method calls.
src/basilisp/lang/compiler/generator.py
def _interop_call_to_py_ast(ctx: GeneratorContext, node: HostCall) -> GeneratedPyAST: """Generate a Python AST node for Python interop method calls.""" assert node.op == NodeOp.HOST_CALL target_ast = gen_py_ast(ctx, node.target) args_deps, args_nodes = _collection_ast(ctx, node.args) return Genera...
def _interop_call_to_py_ast(ctx: GeneratorContext, node: HostCall) -> GeneratedPyAST: """Generate a Python AST node for Python interop method calls.""" assert node.op == NodeOp.HOST_CALL target_ast = gen_py_ast(ctx, node.target) args_deps, args_nodes = _collection_ast(ctx, node.args) return Genera...
[ "Generate", "a", "Python", "AST", "node", "for", "Python", "interop", "method", "calls", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1887-L1905
[ "def", "_interop_call_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "HostCall", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "HOST_CALL", "target_ast", "=", "gen_py_ast", "(", "ctx", ",", "node", "....
3d82670ee218ec64eb066289c82766d14d18cc92
test
_interop_prop_to_py_ast
Generate a Python AST node for Python interop property access.
src/basilisp/lang/compiler/generator.py
def _interop_prop_to_py_ast( ctx: GeneratorContext, node: HostField, is_assigning: bool = False ) -> GeneratedPyAST: """Generate a Python AST node for Python interop property access.""" assert node.op == NodeOp.HOST_FIELD target_ast = gen_py_ast(ctx, node.target) return GeneratedPyAST( nod...
def _interop_prop_to_py_ast( ctx: GeneratorContext, node: HostField, is_assigning: bool = False ) -> GeneratedPyAST: """Generate a Python AST node for Python interop property access.""" assert node.op == NodeOp.HOST_FIELD target_ast = gen_py_ast(ctx, node.target) return GeneratedPyAST( nod...
[ "Generate", "a", "Python", "AST", "node", "for", "Python", "interop", "property", "access", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1909-L1924
[ "def", "_interop_prop_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "HostField", ",", "is_assigning", ":", "bool", "=", "False", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "HOST_FIELD", "target_ast"...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_maybe_class_to_py_ast
Generate a Python AST node for accessing a potential Python module variable name.
src/basilisp/lang/compiler/generator.py
def _maybe_class_to_py_ast(_: GeneratorContext, node: MaybeClass) -> GeneratedPyAST: """Generate a Python AST node for accessing a potential Python module variable name.""" assert node.op == NodeOp.MAYBE_CLASS return GeneratedPyAST( node=ast.Name( id=Maybe(_MODULE_ALIASES.get(node.cl...
def _maybe_class_to_py_ast(_: GeneratorContext, node: MaybeClass) -> GeneratedPyAST: """Generate a Python AST node for accessing a potential Python module variable name.""" assert node.op == NodeOp.MAYBE_CLASS return GeneratedPyAST( node=ast.Name( id=Maybe(_MODULE_ALIASES.get(node.cl...
[ "Generate", "a", "Python", "AST", "node", "for", "accessing", "a", "potential", "Python", "module", "variable", "name", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1928-L1937
[ "def", "_maybe_class_to_py_ast", "(", "_", ":", "GeneratorContext", ",", "node", ":", "MaybeClass", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "MAYBE_CLASS", "return", "GeneratedPyAST", "(", "node", "=", "ast", ".", "...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_maybe_host_form_to_py_ast
Generate a Python AST node for accessing a potential Python module variable name with a namespace.
src/basilisp/lang/compiler/generator.py
def _maybe_host_form_to_py_ast( _: GeneratorContext, node: MaybeHostForm ) -> GeneratedPyAST: """Generate a Python AST node for accessing a potential Python module variable name with a namespace.""" assert node.op == NodeOp.MAYBE_HOST_FORM return GeneratedPyAST( node=_load_attr( ...
def _maybe_host_form_to_py_ast( _: GeneratorContext, node: MaybeHostForm ) -> GeneratedPyAST: """Generate a Python AST node for accessing a potential Python module variable name with a namespace.""" assert node.op == NodeOp.MAYBE_HOST_FORM return GeneratedPyAST( node=_load_attr( ...
[ "Generate", "a", "Python", "AST", "node", "for", "accessing", "a", "potential", "Python", "module", "variable", "name", "with", "a", "namespace", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L1941-L1951
[ "def", "_maybe_host_form_to_py_ast", "(", "_", ":", "GeneratorContext", ",", "node", ":", "MaybeHostForm", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "MAYBE_HOST_FORM", "return", "GeneratedPyAST", "(", "node", "=", "_load...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_with_meta_to_py_ast
Generate a Python AST node for Python interop method calls.
src/basilisp/lang/compiler/generator.py
def _with_meta_to_py_ast( ctx: GeneratorContext, node: WithMeta, **kwargs ) -> GeneratedPyAST: """Generate a Python AST node for Python interop method calls.""" assert node.op == NodeOp.WITH_META handle_expr = _WITH_META_EXPR_HANDLER.get(node.expr.op) assert ( handle_expr is not None ),...
def _with_meta_to_py_ast( ctx: GeneratorContext, node: WithMeta, **kwargs ) -> GeneratedPyAST: """Generate a Python AST node for Python interop method calls.""" assert node.op == NodeOp.WITH_META handle_expr = _WITH_META_EXPR_HANDLER.get(node.expr.op) assert ( handle_expr is not None ),...
[ "Generate", "a", "Python", "AST", "node", "for", "Python", "interop", "method", "calls", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L2105-L2115
[ "def", "_with_meta_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "node", ":", "WithMeta", ",", "*", "*", "kwargs", ")", "->", "GeneratedPyAST", ":", "assert", "node", ".", "op", "==", "NodeOp", ".", "WITH_META", "handle_expr", "=", "_WITH_META_EXPR_HAN...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_const_val_to_py_ast
Generate Python AST nodes for constant Lisp forms. Nested values in collections for :const nodes are not parsed, so recursive structures need to call into this function to generate Python AST nodes for nested elements. For top-level :const Lisp AST nodes, see `_const_node_to_py_ast`.
src/basilisp/lang/compiler/generator.py
def _const_val_to_py_ast(ctx: GeneratorContext, form: LispForm) -> GeneratedPyAST: """Generate Python AST nodes for constant Lisp forms. Nested values in collections for :const nodes are not parsed, so recursive structures need to call into this function to generate Python AST nodes for nested elements...
def _const_val_to_py_ast(ctx: GeneratorContext, form: LispForm) -> GeneratedPyAST: """Generate Python AST nodes for constant Lisp forms. Nested values in collections for :const nodes are not parsed, so recursive structures need to call into this function to generate Python AST nodes for nested elements...
[ "Generate", "Python", "AST", "nodes", "for", "constant", "Lisp", "forms", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L2342-L2353
[ "def", "_const_val_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "form", ":", "LispForm", ")", "->", "GeneratedPyAST", ":", "handle_value", "=", "_CONST_VALUE_HANDLERS", ".", "get", "(", "type", "(", "form", ")", ")", "if", "handle_value", "is", "None"...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_collection_literal_to_py_ast
Turn a quoted collection literal of Lisp forms into Python AST nodes. This function can only handle constant values. It does not call back into the generic AST generators, so only constant values will be generated down this path.
src/basilisp/lang/compiler/generator.py
def _collection_literal_to_py_ast( ctx: GeneratorContext, form: Iterable[LispForm] ) -> Iterable[GeneratedPyAST]: """Turn a quoted collection literal of Lisp forms into Python AST nodes. This function can only handle constant values. It does not call back into the generic AST generators, so only consta...
def _collection_literal_to_py_ast( ctx: GeneratorContext, form: Iterable[LispForm] ) -> Iterable[GeneratedPyAST]: """Turn a quoted collection literal of Lisp forms into Python AST nodes. This function can only handle constant values. It does not call back into the generic AST generators, so only consta...
[ "Turn", "a", "quoted", "collection", "literal", "of", "Lisp", "forms", "into", "Python", "AST", "nodes", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L2356-L2364
[ "def", "_collection_literal_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "form", ":", "Iterable", "[", "LispForm", "]", ")", "->", "Iterable", "[", "GeneratedPyAST", "]", ":", "yield", "from", "map", "(", "partial", "(", "_const_val_to_py_ast", ",", "...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_const_node_to_py_ast
Generate Python AST nodes for a :const Lisp AST node. Nested values in collections for :const nodes are not parsed. Consequently, this function cannot be called recursively for those nested values. Instead, call `_const_val_to_py_ast` on nested values.
src/basilisp/lang/compiler/generator.py
def _const_node_to_py_ast(ctx: GeneratorContext, lisp_ast: Const) -> GeneratedPyAST: """Generate Python AST nodes for a :const Lisp AST node. Nested values in collections for :const nodes are not parsed. Consequently, this function cannot be called recursively for those nested values. Instead, call `_c...
def _const_node_to_py_ast(ctx: GeneratorContext, lisp_ast: Const) -> GeneratedPyAST: """Generate Python AST nodes for a :const Lisp AST node. Nested values in collections for :const nodes are not parsed. Consequently, this function cannot be called recursively for those nested values. Instead, call `_c...
[ "Generate", "Python", "AST", "nodes", "for", "a", ":", "const", "Lisp", "AST", "node", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L2391-L2402
[ "def", "_const_node_to_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "lisp_ast", ":", "Const", ")", "->", "GeneratedPyAST", ":", "assert", "lisp_ast", ".", "op", "==", "NodeOp", ".", "CONST", "node_type", "=", "lisp_ast", ".", "type", "handle_const_node", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
gen_py_ast
Take a Lisp AST node as an argument and produce zero or more Python AST nodes. This is the primary entrypoint for generating AST nodes from Lisp syntax. It may be called recursively to compile child forms.
src/basilisp/lang/compiler/generator.py
def gen_py_ast(ctx: GeneratorContext, lisp_ast: Node) -> GeneratedPyAST: """Take a Lisp AST node as an argument and produce zero or more Python AST nodes. This is the primary entrypoint for generating AST nodes from Lisp syntax. It may be called recursively to compile child forms.""" op: NodeOp = l...
def gen_py_ast(ctx: GeneratorContext, lisp_ast: Node) -> GeneratedPyAST: """Take a Lisp AST node as an argument and produce zero or more Python AST nodes. This is the primary entrypoint for generating AST nodes from Lisp syntax. It may be called recursively to compile child forms.""" op: NodeOp = l...
[ "Take", "a", "Lisp", "AST", "node", "as", "an", "argument", "and", "produce", "zero", "or", "more", "Python", "AST", "nodes", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L2445-L2457
[ "def", "gen_py_ast", "(", "ctx", ":", "GeneratorContext", ",", "lisp_ast", ":", "Node", ")", "->", "GeneratedPyAST", ":", "op", ":", "NodeOp", "=", "lisp_ast", ".", "op", "assert", "op", "is", "not", "None", ",", "\"Lisp AST nodes must have an :op key\"", "han...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_module_imports
Generate the Python Import AST node for importing all required language support modules.
src/basilisp/lang/compiler/generator.py
def _module_imports(ctx: GeneratorContext) -> Iterable[ast.Import]: """Generate the Python Import AST node for importing all required language support modules.""" # Yield `import basilisp` so code attempting to call fully qualified # `basilisp.lang...` modules don't result in compiler errors yield a...
def _module_imports(ctx: GeneratorContext) -> Iterable[ast.Import]: """Generate the Python Import AST node for importing all required language support modules.""" # Yield `import basilisp` so code attempting to call fully qualified # `basilisp.lang...` modules don't result in compiler errors yield a...
[ "Generate", "the", "Python", "Import", "AST", "node", "for", "importing", "all", "required", "language", "support", "modules", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L2465-L2474
[ "def", "_module_imports", "(", "ctx", ":", "GeneratorContext", ")", "->", "Iterable", "[", "ast", ".", "Import", "]", ":", "# Yield `import basilisp` so code attempting to call fully qualified", "# `basilisp.lang...` modules don't result in compiler errors", "yield", "ast", "."...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_from_module_import
Generate the Python From ... Import AST node for importing language support modules.
src/basilisp/lang/compiler/generator.py
def _from_module_import() -> ast.ImportFrom: """Generate the Python From ... Import AST node for importing language support modules.""" return ast.ImportFrom( module="basilisp.lang.runtime", names=[ast.alias(name="Var", asname=_VAR_ALIAS)], level=0, )
def _from_module_import() -> ast.ImportFrom: """Generate the Python From ... Import AST node for importing language support modules.""" return ast.ImportFrom( module="basilisp.lang.runtime", names=[ast.alias(name="Var", asname=_VAR_ALIAS)], level=0, )
[ "Generate", "the", "Python", "From", "...", "Import", "AST", "node", "for", "importing", "language", "support", "modules", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L2477-L2484
[ "def", "_from_module_import", "(", ")", "->", "ast", ".", "ImportFrom", ":", "return", "ast", ".", "ImportFrom", "(", "module", "=", "\"basilisp.lang.runtime\"", ",", "names", "=", "[", "ast", ".", "alias", "(", "name", "=", "\"Var\"", ",", "asname", "=", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_ns_var
Assign a Python variable named `ns_var` to the value of the current namespace.
src/basilisp/lang/compiler/generator.py
def _ns_var( py_ns_var: str = _NS_VAR, lisp_ns_var: str = LISP_NS_VAR, lisp_ns_ns: str = CORE_NS ) -> ast.Assign: """Assign a Python variable named `ns_var` to the value of the current namespace.""" return ast.Assign( targets=[ast.Name(id=py_ns_var, ctx=ast.Store())], value=ast.Call( ...
def _ns_var( py_ns_var: str = _NS_VAR, lisp_ns_var: str = LISP_NS_VAR, lisp_ns_ns: str = CORE_NS ) -> ast.Assign: """Assign a Python variable named `ns_var` to the value of the current namespace.""" return ast.Assign( targets=[ast.Name(id=py_ns_var, ctx=ast.Store())], value=ast.Call( ...
[ "Assign", "a", "Python", "variable", "named", "ns_var", "to", "the", "value", "of", "the", "current", "namespace", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L2487-L2505
[ "def", "_ns_var", "(", "py_ns_var", ":", "str", "=", "_NS_VAR", ",", "lisp_ns_var", ":", "str", "=", "LISP_NS_VAR", ",", "lisp_ns_ns", ":", "str", "=", "CORE_NS", ")", "->", "ast", ".", "Assign", ":", "return", "ast", ".", "Assign", "(", "targets", "="...
3d82670ee218ec64eb066289c82766d14d18cc92
test
py_module_preamble
Bootstrap a new module with imports and other boilerplate.
src/basilisp/lang/compiler/generator.py
def py_module_preamble(ctx: GeneratorContext,) -> GeneratedPyAST: """Bootstrap a new module with imports and other boilerplate.""" preamble: List[ast.AST] = [] preamble.extend(_module_imports(ctx)) preamble.append(_from_module_import()) preamble.append(_ns_var()) return GeneratedPyAST(node=ast.N...
def py_module_preamble(ctx: GeneratorContext,) -> GeneratedPyAST: """Bootstrap a new module with imports and other boilerplate.""" preamble: List[ast.AST] = [] preamble.extend(_module_imports(ctx)) preamble.append(_from_module_import()) preamble.append(_ns_var()) return GeneratedPyAST(node=ast.N...
[ "Bootstrap", "a", "new", "module", "with", "imports", "and", "other", "boilerplate", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L2508-L2514
[ "def", "py_module_preamble", "(", "ctx", ":", "GeneratorContext", ",", ")", "->", "GeneratedPyAST", ":", "preamble", ":", "List", "[", "ast", ".", "AST", "]", "=", "[", "]", "preamble", ".", "extend", "(", "_module_imports", "(", "ctx", ")", ")", "preamb...
3d82670ee218ec64eb066289c82766d14d18cc92
test
GeneratorContext.warn_on_var_indirection
If True, warn when a Var reference cannot be direct linked (iff use_var_indirection is False)..
src/basilisp/lang/compiler/generator.py
def warn_on_var_indirection(self) -> bool: """If True, warn when a Var reference cannot be direct linked (iff use_var_indirection is False)..""" return not self.use_var_indirection and self._opts.entry( WARN_ON_VAR_INDIRECTION, True )
def warn_on_var_indirection(self) -> bool: """If True, warn when a Var reference cannot be direct linked (iff use_var_indirection is False)..""" return not self.use_var_indirection and self._opts.entry( WARN_ON_VAR_INDIRECTION, True )
[ "If", "True", "warn", "when", "a", "Var", "reference", "cannot", "be", "direct", "linked", "(", "iff", "use_var_indirection", "is", "False", ")", ".." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/generator.py#L212-L217
[ "def", "warn_on_var_indirection", "(", "self", ")", "->", "bool", ":", "return", "not", "self", ".", "use_var_indirection", "and", "self", ".", "_opts", ".", "entry", "(", "WARN_ON_VAR_INDIRECTION", ",", "True", ")" ]
3d82670ee218ec64eb066289c82766d14d18cc92
test
set
Creates a new set.
src/basilisp/lang/set.py
def set(members: Iterable[T], meta=None) -> Set[T]: # pylint:disable=redefined-builtin """Creates a new set.""" return Set(pset(members), meta=meta)
def set(members: Iterable[T], meta=None) -> Set[T]: # pylint:disable=redefined-builtin """Creates a new set.""" return Set(pset(members), meta=meta)
[ "Creates", "a", "new", "set", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/set.py#L129-L131
[ "def", "set", "(", "members", ":", "Iterable", "[", "T", "]", ",", "meta", "=", "None", ")", "->", "Set", "[", "T", "]", ":", "# pylint:disable=redefined-builtin", "return", "Set", "(", "pset", "(", "members", ")", ",", "meta", "=", "meta", ")" ]
3d82670ee218ec64eb066289c82766d14d18cc92
test
s
Creates a new set from members.
src/basilisp/lang/set.py
def s(*members: T, meta=None) -> Set[T]: """Creates a new set from members.""" return Set(pset(members), meta=meta)
def s(*members: T, meta=None) -> Set[T]: """Creates a new set from members.""" return Set(pset(members), meta=meta)
[ "Creates", "a", "new", "set", "from", "members", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/set.py#L134-L136
[ "def", "s", "(", "*", "members", ":", "T", ",", "meta", "=", "None", ")", "->", "Set", "[", "T", "]", ":", "return", "Set", "(", "pset", "(", "members", ")", ",", "meta", "=", "meta", ")" ]
3d82670ee218ec64eb066289c82766d14d18cc92
test
_filter_dead_code
Return a list of body nodes, trimming out unreachable code (any statements appearing after `break`, `continue`, and `return` nodes).
src/basilisp/lang/compiler/optimizer.py
def _filter_dead_code(nodes: Iterable[ast.AST]) -> List[ast.AST]: """Return a list of body nodes, trimming out unreachable code (any statements appearing after `break`, `continue`, and `return` nodes).""" new_nodes: List[ast.AST] = [] for node in nodes: if isinstance(node, (ast.Break, ast.Contin...
def _filter_dead_code(nodes: Iterable[ast.AST]) -> List[ast.AST]: """Return a list of body nodes, trimming out unreachable code (any statements appearing after `break`, `continue`, and `return` nodes).""" new_nodes: List[ast.AST] = [] for node in nodes: if isinstance(node, (ast.Break, ast.Contin...
[ "Return", "a", "list", "of", "body", "nodes", "trimming", "out", "unreachable", "code", "(", "any", "statements", "appearing", "after", "break", "continue", "and", "return", "nodes", ")", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/optimizer.py#L5-L14
[ "def", "_filter_dead_code", "(", "nodes", ":", "Iterable", "[", "ast", ".", "AST", "]", ")", "->", "List", "[", "ast", ".", "AST", "]", ":", "new_nodes", ":", "List", "[", "ast", ".", "AST", "]", "=", "[", "]", "for", "node", "in", "nodes", ":", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
PythonASTOptimizer.visit_ExceptHandler
Eliminate dead code from except handler bodies.
src/basilisp/lang/compiler/optimizer.py
def visit_ExceptHandler(self, node: ast.ExceptHandler) -> Optional[ast.AST]: """Eliminate dead code from except handler bodies.""" new_node = self.generic_visit(node) assert isinstance(new_node, ast.ExceptHandler) return ast.copy_location( ast.ExceptHandler( t...
def visit_ExceptHandler(self, node: ast.ExceptHandler) -> Optional[ast.AST]: """Eliminate dead code from except handler bodies.""" new_node = self.generic_visit(node) assert isinstance(new_node, ast.ExceptHandler) return ast.copy_location( ast.ExceptHandler( t...
[ "Eliminate", "dead", "code", "from", "except", "handler", "bodies", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/optimizer.py#L18-L29
[ "def", "visit_ExceptHandler", "(", "self", ",", "node", ":", "ast", ".", "ExceptHandler", ")", "->", "Optional", "[", "ast", ".", "AST", "]", ":", "new_node", "=", "self", ".", "generic_visit", "(", "node", ")", "assert", "isinstance", "(", "new_node", "...
3d82670ee218ec64eb066289c82766d14d18cc92
test
PythonASTOptimizer.visit_Expr
Eliminate no-op constant expressions which are in the tree as standalone statements.
src/basilisp/lang/compiler/optimizer.py
def visit_Expr(self, node: ast.Expr) -> Optional[ast.Expr]: """Eliminate no-op constant expressions which are in the tree as standalone statements.""" if isinstance( node.value, ( ast.Constant, # type: ignore ast.Name, ast....
def visit_Expr(self, node: ast.Expr) -> Optional[ast.Expr]: """Eliminate no-op constant expressions which are in the tree as standalone statements.""" if isinstance( node.value, ( ast.Constant, # type: ignore ast.Name, ast....
[ "Eliminate", "no", "-", "op", "constant", "expressions", "which", "are", "in", "the", "tree", "as", "standalone", "statements", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/optimizer.py#L31-L45
[ "def", "visit_Expr", "(", "self", ",", "node", ":", "ast", ".", "Expr", ")", "->", "Optional", "[", "ast", ".", "Expr", "]", ":", "if", "isinstance", "(", "node", ".", "value", ",", "(", "ast", ".", "Constant", ",", "# type: ignore", "ast", ".", "N...
3d82670ee218ec64eb066289c82766d14d18cc92
test
PythonASTOptimizer.visit_FunctionDef
Eliminate dead code from function bodies.
src/basilisp/lang/compiler/optimizer.py
def visit_FunctionDef(self, node: ast.FunctionDef) -> Optional[ast.AST]: """Eliminate dead code from function bodies.""" new_node = self.generic_visit(node) assert isinstance(new_node, ast.FunctionDef) return ast.copy_location( ast.FunctionDef( name=new_node.n...
def visit_FunctionDef(self, node: ast.FunctionDef) -> Optional[ast.AST]: """Eliminate dead code from function bodies.""" new_node = self.generic_visit(node) assert isinstance(new_node, ast.FunctionDef) return ast.copy_location( ast.FunctionDef( name=new_node.n...
[ "Eliminate", "dead", "code", "from", "function", "bodies", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/optimizer.py#L47-L60
[ "def", "visit_FunctionDef", "(", "self", ",", "node", ":", "ast", ".", "FunctionDef", ")", "->", "Optional", "[", "ast", ".", "AST", "]", ":", "new_node", "=", "self", ".", "generic_visit", "(", "node", ")", "assert", "isinstance", "(", "new_node", ",", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
PythonASTOptimizer.visit_If
Eliminate dead code from if/elif bodies.
src/basilisp/lang/compiler/optimizer.py
def visit_If(self, node: ast.If) -> Optional[ast.AST]: """Eliminate dead code from if/elif bodies.""" new_node = self.generic_visit(node) assert isinstance(new_node, ast.If) return ast.copy_location( ast.If( test=new_node.test, body=_filter_dea...
def visit_If(self, node: ast.If) -> Optional[ast.AST]: """Eliminate dead code from if/elif bodies.""" new_node = self.generic_visit(node) assert isinstance(new_node, ast.If) return ast.copy_location( ast.If( test=new_node.test, body=_filter_dea...
[ "Eliminate", "dead", "code", "from", "if", "/", "elif", "bodies", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/optimizer.py#L62-L73
[ "def", "visit_If", "(", "self", ",", "node", ":", "ast", ".", "If", ")", "->", "Optional", "[", "ast", ".", "AST", "]", ":", "new_node", "=", "self", ".", "generic_visit", "(", "node", ")", "assert", "isinstance", "(", "new_node", ",", "ast", ".", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
PythonASTOptimizer.visit_While
Eliminate dead code from while bodies.
src/basilisp/lang/compiler/optimizer.py
def visit_While(self, node: ast.While) -> Optional[ast.AST]: """Eliminate dead code from while bodies.""" new_node = self.generic_visit(node) assert isinstance(new_node, ast.While) return ast.copy_location( ast.While( test=new_node.test, body=_...
def visit_While(self, node: ast.While) -> Optional[ast.AST]: """Eliminate dead code from while bodies.""" new_node = self.generic_visit(node) assert isinstance(new_node, ast.While) return ast.copy_location( ast.While( test=new_node.test, body=_...
[ "Eliminate", "dead", "code", "from", "while", "bodies", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/optimizer.py#L75-L86
[ "def", "visit_While", "(", "self", ",", "node", ":", "ast", ".", "While", ")", "->", "Optional", "[", "ast", ".", "AST", "]", ":", "new_node", "=", "self", ".", "generic_visit", "(", "node", ")", "assert", "isinstance", "(", "new_node", ",", "ast", "...
3d82670ee218ec64eb066289c82766d14d18cc92
test
PythonASTOptimizer.visit_Try
Eliminate dead code from except try bodies.
src/basilisp/lang/compiler/optimizer.py
def visit_Try(self, node: ast.Try) -> Optional[ast.AST]: """Eliminate dead code from except try bodies.""" new_node = self.generic_visit(node) assert isinstance(new_node, ast.Try) return ast.copy_location( ast.Try( body=_filter_dead_code(new_node.body), ...
def visit_Try(self, node: ast.Try) -> Optional[ast.AST]: """Eliminate dead code from except try bodies.""" new_node = self.generic_visit(node) assert isinstance(new_node, ast.Try) return ast.copy_location( ast.Try( body=_filter_dead_code(new_node.body), ...
[ "Eliminate", "dead", "code", "from", "except", "try", "bodies", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/compiler/optimizer.py#L88-L100
[ "def", "visit_Try", "(", "self", ",", "node", ":", "ast", ".", "Try", ")", "->", "Optional", "[", "ast", ".", "AST", "]", ":", "new_node", "=", "self", ".", "generic_visit", "(", "node", ")", "assert", "isinstance", "(", "new_node", ",", "ast", ".", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_new_module
Create a new empty Basilisp Python module. Modules are created for each Namespace when it is created.
src/basilisp/lang/runtime.py
def _new_module(name: str, doc=None) -> types.ModuleType: """Create a new empty Basilisp Python module. Modules are created for each Namespace when it is created.""" mod = types.ModuleType(name, doc=doc) mod.__loader__ = None mod.__package__ = None mod.__spec__ = None mod.__basilisp_bootstra...
def _new_module(name: str, doc=None) -> types.ModuleType: """Create a new empty Basilisp Python module. Modules are created for each Namespace when it is created.""" mod = types.ModuleType(name, doc=doc) mod.__loader__ = None mod.__package__ = None mod.__spec__ = None mod.__basilisp_bootstra...
[ "Create", "a", "new", "empty", "Basilisp", "Python", "module", ".", "Modules", "are", "created", "for", "each", "Namespace", "when", "it", "is", "created", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L118-L126
[ "def", "_new_module", "(", "name", ":", "str", ",", "doc", "=", "None", ")", "->", "types", ".", "ModuleType", ":", "mod", "=", "types", ".", "ModuleType", "(", "name", ",", "doc", "=", "doc", ")", "mod", ".", "__loader__", "=", "None", "mod", ".",...
3d82670ee218ec64eb066289c82766d14d18cc92
test
first
If o is a ISeq, return the first element from o. If o is None, return None. Otherwise, coerces o to a Seq and returns the first.
src/basilisp/lang/runtime.py
def first(o): """If o is a ISeq, return the first element from o. If o is None, return None. Otherwise, coerces o to a Seq and returns the first.""" if o is None: return None if isinstance(o, ISeq): return o.first s = to_seq(o) if s is None: return None return s.first
def first(o): """If o is a ISeq, return the first element from o. If o is None, return None. Otherwise, coerces o to a Seq and returns the first.""" if o is None: return None if isinstance(o, ISeq): return o.first s = to_seq(o) if s is None: return None return s.first
[ "If", "o", "is", "a", "ISeq", "return", "the", "first", "element", "from", "o", ".", "If", "o", "is", "None", "return", "None", ".", "Otherwise", "coerces", "o", "to", "a", "Seq", "and", "returns", "the", "first", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L699-L709
[ "def", "first", "(", "o", ")", ":", "if", "o", "is", "None", ":", "return", "None", "if", "isinstance", "(", "o", ",", "ISeq", ")", ":", "return", "o", ".", "first", "s", "=", "to_seq", "(", "o", ")", "if", "s", "is", "None", ":", "return", "...
3d82670ee218ec64eb066289c82766d14d18cc92
test
rest
If o is a ISeq, return the elements after the first in o. If o is None, returns an empty seq. Otherwise, coerces o to a seq and returns the rest.
src/basilisp/lang/runtime.py
def rest(o) -> Optional[ISeq]: """If o is a ISeq, return the elements after the first in o. If o is None, returns an empty seq. Otherwise, coerces o to a seq and returns the rest.""" if o is None: return None if isinstance(o, ISeq): s = o.rest if s is None: return lse...
def rest(o) -> Optional[ISeq]: """If o is a ISeq, return the elements after the first in o. If o is None, returns an empty seq. Otherwise, coerces o to a seq and returns the rest.""" if o is None: return None if isinstance(o, ISeq): s = o.rest if s is None: return lse...
[ "If", "o", "is", "a", "ISeq", "return", "the", "elements", "after", "the", "first", "in", "o", ".", "If", "o", "is", "None", "returns", "an", "empty", "seq", ".", "Otherwise", "coerces", "o", "to", "a", "seq", "and", "returns", "the", "rest", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L712-L725
[ "def", "rest", "(", "o", ")", "->", "Optional", "[", "ISeq", "]", ":", "if", "o", "is", "None", ":", "return", "None", "if", "isinstance", "(", "o", ",", "ISeq", ")", ":", "s", "=", "o", ".", "rest", "if", "s", "is", "None", ":", "return", "l...
3d82670ee218ec64eb066289c82766d14d18cc92
test
nthrest
Returns the nth rest sequence of coll, or coll if i is 0.
src/basilisp/lang/runtime.py
def nthrest(coll, i: int): """Returns the nth rest sequence of coll, or coll if i is 0.""" while True: if coll is None: return None if i == 0: return coll i -= 1 coll = rest(coll)
def nthrest(coll, i: int): """Returns the nth rest sequence of coll, or coll if i is 0.""" while True: if coll is None: return None if i == 0: return coll i -= 1 coll = rest(coll)
[ "Returns", "the", "nth", "rest", "sequence", "of", "coll", "or", "coll", "if", "i", "is", "0", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L728-L736
[ "def", "nthrest", "(", "coll", ",", "i", ":", "int", ")", ":", "while", "True", ":", "if", "coll", "is", "None", ":", "return", "None", "if", "i", "==", "0", ":", "return", "coll", "i", "-=", "1", "coll", "=", "rest", "(", "coll", ")" ]
3d82670ee218ec64eb066289c82766d14d18cc92
test
nthnext
Returns the nth next sequence of coll.
src/basilisp/lang/runtime.py
def nthnext(coll, i: int) -> Optional[ISeq]: """Returns the nth next sequence of coll.""" while True: if coll is None: return None if i == 0: return to_seq(coll) i -= 1 coll = next_(coll)
def nthnext(coll, i: int) -> Optional[ISeq]: """Returns the nth next sequence of coll.""" while True: if coll is None: return None if i == 0: return to_seq(coll) i -= 1 coll = next_(coll)
[ "Returns", "the", "nth", "next", "sequence", "of", "coll", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L748-L756
[ "def", "nthnext", "(", "coll", ",", "i", ":", "int", ")", "->", "Optional", "[", "ISeq", "]", ":", "while", "True", ":", "if", "coll", "is", "None", ":", "return", "None", "if", "i", "==", "0", ":", "return", "to_seq", "(", "coll", ")", "i", "-...
3d82670ee218ec64eb066289c82766d14d18cc92
test
cons
Creates a new sequence where o is the first element and seq is the rest. If seq is None, return a list containing o. If seq is not a ISeq, attempt to coerce it to a ISeq and then cons o onto the resulting sequence.
src/basilisp/lang/runtime.py
def cons(o, seq) -> ISeq: """Creates a new sequence where o is the first element and seq is the rest. If seq is None, return a list containing o. If seq is not a ISeq, attempt to coerce it to a ISeq and then cons o onto the resulting sequence.""" if seq is None: return llist.l(o) if isinstan...
def cons(o, seq) -> ISeq: """Creates a new sequence where o is the first element and seq is the rest. If seq is None, return a list containing o. If seq is not a ISeq, attempt to coerce it to a ISeq and then cons o onto the resulting sequence.""" if seq is None: return llist.l(o) if isinstan...
[ "Creates", "a", "new", "sequence", "where", "o", "is", "the", "first", "element", "and", "seq", "is", "the", "rest", ".", "If", "seq", "is", "None", "return", "a", "list", "containing", "o", ".", "If", "seq", "is", "not", "a", "ISeq", "attempt", "to"...
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L759-L767
[ "def", "cons", "(", "o", ",", "seq", ")", "->", "ISeq", ":", "if", "seq", "is", "None", ":", "return", "llist", ".", "l", "(", "o", ")", "if", "isinstance", "(", "seq", ",", "ISeq", ")", ":", "return", "seq", ".", "cons", "(", "o", ")", "retu...
3d82670ee218ec64eb066289c82766d14d18cc92
test
to_seq
Coerce the argument o to a ISeq. If o is None, return None.
src/basilisp/lang/runtime.py
def to_seq(o) -> Optional[ISeq]: """Coerce the argument o to a ISeq. If o is None, return None.""" if o is None: return None if isinstance(o, ISeq): return _seq_or_nil(o) if isinstance(o, ISeqable): return _seq_or_nil(o.seq()) return _seq_or_nil(lseq.sequence(o))
def to_seq(o) -> Optional[ISeq]: """Coerce the argument o to a ISeq. If o is None, return None.""" if o is None: return None if isinstance(o, ISeq): return _seq_or_nil(o) if isinstance(o, ISeqable): return _seq_or_nil(o.seq()) return _seq_or_nil(lseq.sequence(o))
[ "Coerce", "the", "argument", "o", "to", "a", "ISeq", ".", "If", "o", "is", "None", "return", "None", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L777-L785
[ "def", "to_seq", "(", "o", ")", "->", "Optional", "[", "ISeq", "]", ":", "if", "o", "is", "None", ":", "return", "None", "if", "isinstance", "(", "o", ",", "ISeq", ")", ":", "return", "_seq_or_nil", "(", "o", ")", "if", "isinstance", "(", "o", ",...
3d82670ee218ec64eb066289c82766d14d18cc92
test
concat
Concatenate the sequences given by seqs into a single ISeq.
src/basilisp/lang/runtime.py
def concat(*seqs) -> ISeq: """Concatenate the sequences given by seqs into a single ISeq.""" allseqs = lseq.sequence(itertools.chain(*filter(None, map(to_seq, seqs)))) if allseqs is None: return lseq.EMPTY return allseqs
def concat(*seqs) -> ISeq: """Concatenate the sequences given by seqs into a single ISeq.""" allseqs = lseq.sequence(itertools.chain(*filter(None, map(to_seq, seqs)))) if allseqs is None: return lseq.EMPTY return allseqs
[ "Concatenate", "the", "sequences", "given", "by", "seqs", "into", "a", "single", "ISeq", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L788-L793
[ "def", "concat", "(", "*", "seqs", ")", "->", "ISeq", ":", "allseqs", "=", "lseq", ".", "sequence", "(", "itertools", ".", "chain", "(", "*", "filter", "(", "None", ",", "map", "(", "to_seq", ",", "seqs", ")", ")", ")", ")", "if", "allseqs", "is"...
3d82670ee218ec64eb066289c82766d14d18cc92
test
apply
Apply function f to the arguments provided. The last argument must always be coercible to a Seq. Intermediate arguments are not modified. For example: (apply max [1 2 3]) ;=> 3 (apply max 4 [1 2 3]) ;=> 4
src/basilisp/lang/runtime.py
def apply(f, args): """Apply function f to the arguments provided. The last argument must always be coercible to a Seq. Intermediate arguments are not modified. For example: (apply max [1 2 3]) ;=> 3 (apply max 4 [1 2 3]) ;=> 4""" final = list(args[:-1]) try: last = ar...
def apply(f, args): """Apply function f to the arguments provided. The last argument must always be coercible to a Seq. Intermediate arguments are not modified. For example: (apply max [1 2 3]) ;=> 3 (apply max 4 [1 2 3]) ;=> 4""" final = list(args[:-1]) try: last = ar...
[ "Apply", "function", "f", "to", "the", "arguments", "provided", ".", "The", "last", "argument", "must", "always", "be", "coercible", "to", "a", "Seq", ".", "Intermediate", "arguments", "are", "not", "modified", ".", "For", "example", ":", "(", "apply", "ma...
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L796-L814
[ "def", "apply", "(", "f", ",", "args", ")", ":", "final", "=", "list", "(", "args", "[", ":", "-", "1", "]", ")", "try", ":", "last", "=", "args", "[", "-", "1", "]", "except", "TypeError", "as", "e", ":", "logger", ".", "debug", "(", "\"Igno...
3d82670ee218ec64eb066289c82766d14d18cc92
test
apply_kw
Apply function f to the arguments provided. The last argument must always be coercible to a Mapping. Intermediate arguments are not modified. For example: (apply builtins/dict {:a 1} {:b 2}) ;=> #py {:a 1 :b 2} (apply builtins/dict {:a 1} {:a 2}) ;=> #py {:a 2}
src/basilisp/lang/runtime.py
def apply_kw(f, args): """Apply function f to the arguments provided. The last argument must always be coercible to a Mapping. Intermediate arguments are not modified. For example: (apply builtins/dict {:a 1} {:b 2}) ;=> #py {:a 1 :b 2} (apply builtins/dict {:a 1} {:a 2}) ;=> #py {:a...
def apply_kw(f, args): """Apply function f to the arguments provided. The last argument must always be coercible to a Mapping. Intermediate arguments are not modified. For example: (apply builtins/dict {:a 1} {:b 2}) ;=> #py {:a 1 :b 2} (apply builtins/dict {:a 1} {:a 2}) ;=> #py {:a...
[ "Apply", "function", "f", "to", "the", "arguments", "provided", ".", "The", "last", "argument", "must", "always", "be", "coercible", "to", "a", "Mapping", ".", "Intermediate", "arguments", "are", "not", "modified", ".", "For", "example", ":", "(", "apply", ...
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L817-L832
[ "def", "apply_kw", "(", "f", ",", "args", ")", ":", "final", "=", "list", "(", "args", "[", ":", "-", "1", "]", ")", "try", ":", "last", "=", "args", "[", "-", "1", "]", "except", "TypeError", "as", "e", ":", "logger", ".", "debug", "(", "\"I...
3d82670ee218ec64eb066289c82766d14d18cc92
test
nth
Returns the ith element of coll (0-indexed), if it exists. None otherwise. If i is out of bounds, throws an IndexError unless notfound is specified.
src/basilisp/lang/runtime.py
def nth(coll, i, notfound=__nth_sentinel): """Returns the ith element of coll (0-indexed), if it exists. None otherwise. If i is out of bounds, throws an IndexError unless notfound is specified.""" if coll is None: return None try: return coll[i] except IndexError as ex: ...
def nth(coll, i, notfound=__nth_sentinel): """Returns the ith element of coll (0-indexed), if it exists. None otherwise. If i is out of bounds, throws an IndexError unless notfound is specified.""" if coll is None: return None try: return coll[i] except IndexError as ex: ...
[ "Returns", "the", "ith", "element", "of", "coll", "(", "0", "-", "indexed", ")", "if", "it", "exists", ".", "None", "otherwise", ".", "If", "i", "is", "out", "of", "bounds", "throws", "an", "IndexError", "unless", "notfound", "is", "specified", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L838-L866
[ "def", "nth", "(", "coll", ",", "i", ",", "notfound", "=", "__nth_sentinel", ")", ":", "if", "coll", "is", "None", ":", "return", "None", "try", ":", "return", "coll", "[", "i", "]", "except", "IndexError", "as", "ex", ":", "if", "notfound", "is", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
assoc
Associate keys to values in associative data structure m. If m is None, returns a new Map with key-values kvs.
src/basilisp/lang/runtime.py
def assoc(m, *kvs): """Associate keys to values in associative data structure m. If m is None, returns a new Map with key-values kvs.""" if m is None: return lmap.Map.empty().assoc(*kvs) if isinstance(m, IAssociative): return m.assoc(*kvs) raise TypeError( f"Object of type {t...
def assoc(m, *kvs): """Associate keys to values in associative data structure m. If m is None, returns a new Map with key-values kvs.""" if m is None: return lmap.Map.empty().assoc(*kvs) if isinstance(m, IAssociative): return m.assoc(*kvs) raise TypeError( f"Object of type {t...
[ "Associate", "keys", "to", "values", "in", "associative", "data", "structure", "m", ".", "If", "m", "is", "None", "returns", "a", "new", "Map", "with", "key", "-", "values", "kvs", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L869-L878
[ "def", "assoc", "(", "m", ",", "*", "kvs", ")", ":", "if", "m", "is", "None", ":", "return", "lmap", ".", "Map", ".", "empty", "(", ")", ".", "assoc", "(", "*", "kvs", ")", "if", "isinstance", "(", "m", ",", "IAssociative", ")", ":", "return", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
update
Updates the value for key k in associative data structure m with the return value from calling f(old_v, *args). If m is None, use an empty map. If k is not in m, old_v will be None.
src/basilisp/lang/runtime.py
def update(m, k, f, *args): """Updates the value for key k in associative data structure m with the return value from calling f(old_v, *args). If m is None, use an empty map. If k is not in m, old_v will be None.""" if m is None: return lmap.Map.empty().assoc(k, f(None, *args)) if isinstance...
def update(m, k, f, *args): """Updates the value for key k in associative data structure m with the return value from calling f(old_v, *args). If m is None, use an empty map. If k is not in m, old_v will be None.""" if m is None: return lmap.Map.empty().assoc(k, f(None, *args)) if isinstance...
[ "Updates", "the", "value", "for", "key", "k", "in", "associative", "data", "structure", "m", "with", "the", "return", "value", "from", "calling", "f", "(", "old_v", "*", "args", ")", ".", "If", "m", "is", "None", "use", "an", "empty", "map", ".", "If...
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L881-L893
[ "def", "update", "(", "m", ",", "k", ",", "f", ",", "*", "args", ")", ":", "if", "m", "is", "None", ":", "return", "lmap", ".", "Map", ".", "empty", "(", ")", ".", "assoc", "(", "k", ",", "f", "(", "None", ",", "*", "args", ")", ")", "if"...
3d82670ee218ec64eb066289c82766d14d18cc92
test
conj
Conjoin xs to collection. New elements may be added in different positions depending on the type of coll. conj returns the same type as coll. If coll is None, return a list with xs conjoined.
src/basilisp/lang/runtime.py
def conj(coll, *xs): """Conjoin xs to collection. New elements may be added in different positions depending on the type of coll. conj returns the same type as coll. If coll is None, return a list with xs conjoined.""" if coll is None: l = llist.List.empty() return l.cons(*xs) if isi...
def conj(coll, *xs): """Conjoin xs to collection. New elements may be added in different positions depending on the type of coll. conj returns the same type as coll. If coll is None, return a list with xs conjoined.""" if coll is None: l = llist.List.empty() return l.cons(*xs) if isi...
[ "Conjoin", "xs", "to", "collection", ".", "New", "elements", "may", "be", "added", "in", "different", "positions", "depending", "on", "the", "type", "of", "coll", ".", "conj", "returns", "the", "same", "type", "as", "coll", ".", "If", "coll", "is", "None...
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L896-L907
[ "def", "conj", "(", "coll", ",", "*", "xs", ")", ":", "if", "coll", "is", "None", ":", "l", "=", "llist", ".", "List", ".", "empty", "(", ")", "return", "l", ".", "cons", "(", "*", "xs", ")", "if", "isinstance", "(", "coll", ",", "IPersistentCo...
3d82670ee218ec64eb066289c82766d14d18cc92
test
partial
Return a function which is the partial application of f with args.
src/basilisp/lang/runtime.py
def partial(f, *args): """Return a function which is the partial application of f with args.""" @functools.wraps(f) def partial_f(*inner_args): return f(*itertools.chain(args, inner_args)) return partial_f
def partial(f, *args): """Return a function which is the partial application of f with args.""" @functools.wraps(f) def partial_f(*inner_args): return f(*itertools.chain(args, inner_args)) return partial_f
[ "Return", "a", "function", "which", "is", "the", "partial", "application", "of", "f", "with", "args", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L910-L917
[ "def", "partial", "(", "f", ",", "*", "args", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "partial_f", "(", "*", "inner_args", ")", ":", "return", "f", "(", "*", "itertools", ".", "chain", "(", "args", ",", "inner_args", ")", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
deref
Dereference a Deref object and return its contents. If o is an object implementing IBlockingDeref and timeout_s and timeout_val are supplied, deref will wait at most timeout_s seconds, returning timeout_val if timeout_s seconds elapse and o has not returned.
src/basilisp/lang/runtime.py
def deref(o, timeout_s=None, timeout_val=None): """Dereference a Deref object and return its contents. If o is an object implementing IBlockingDeref and timeout_s and timeout_val are supplied, deref will wait at most timeout_s seconds, returning timeout_val if timeout_s seconds elapse and o has not ...
def deref(o, timeout_s=None, timeout_val=None): """Dereference a Deref object and return its contents. If o is an object implementing IBlockingDeref and timeout_s and timeout_val are supplied, deref will wait at most timeout_s seconds, returning timeout_val if timeout_s seconds elapse and o has not ...
[ "Dereference", "a", "Deref", "object", "and", "return", "its", "contents", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L920-L931
[ "def", "deref", "(", "o", ",", "timeout_s", "=", "None", ",", "timeout_val", "=", "None", ")", ":", "if", "isinstance", "(", "o", ",", "IDeref", ")", ":", "return", "o", ".", "deref", "(", ")", "elif", "isinstance", "(", "o", ",", "IBlockingDeref", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
equals
Compare two objects by value. Unlike the standard Python equality operator, this function does not consider 1 == True or 0 == False. All other equality operations are the same and performed using Python's equality operator.
src/basilisp/lang/runtime.py
def equals(v1, v2) -> bool: """Compare two objects by value. Unlike the standard Python equality operator, this function does not consider 1 == True or 0 == False. All other equality operations are the same and performed using Python's equality operator.""" if isinstance(v1, (bool, type(None))) or isins...
def equals(v1, v2) -> bool: """Compare two objects by value. Unlike the standard Python equality operator, this function does not consider 1 == True or 0 == False. All other equality operations are the same and performed using Python's equality operator.""" if isinstance(v1, (bool, type(None))) or isins...
[ "Compare", "two", "objects", "by", "value", ".", "Unlike", "the", "standard", "Python", "equality", "operator", "this", "function", "does", "not", "consider", "1", "==", "True", "or", "0", "==", "False", ".", "All", "other", "equality", "operations", "are", ...
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L941-L947
[ "def", "equals", "(", "v1", ",", "v2", ")", "->", "bool", ":", "if", "isinstance", "(", "v1", ",", "(", "bool", ",", "type", "(", "None", ")", ")", ")", "or", "isinstance", "(", "v2", ",", "(", "bool", ",", "type", "(", "None", ")", ")", ")",...
3d82670ee218ec64eb066289c82766d14d18cc92
test
divide
Division reducer. If both arguments are integers, return a Fraction. Otherwise, return the true division of x and y.
src/basilisp/lang/runtime.py
def divide(x: LispNumber, y: LispNumber) -> LispNumber: """Division reducer. If both arguments are integers, return a Fraction. Otherwise, return the true division of x and y.""" if isinstance(x, int) and isinstance(y, int): return Fraction(x, y) return x / y
def divide(x: LispNumber, y: LispNumber) -> LispNumber: """Division reducer. If both arguments are integers, return a Fraction. Otherwise, return the true division of x and y.""" if isinstance(x, int) and isinstance(y, int): return Fraction(x, y) return x / y
[ "Division", "reducer", ".", "If", "both", "arguments", "are", "integers", "return", "a", "Fraction", ".", "Otherwise", "return", "the", "true", "division", "of", "x", "and", "y", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L950-L955
[ "def", "divide", "(", "x", ":", "LispNumber", ",", "y", ":", "LispNumber", ")", "->", "LispNumber", ":", "if", "isinstance", "(", "x", ",", "int", ")", "and", "isinstance", "(", "y", ",", "int", ")", ":", "return", "Fraction", "(", "x", ",", "y", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
sort
Return a sorted sequence of the elements in coll. If a comparator function f is provided, compare elements in coll using f.
src/basilisp/lang/runtime.py
def sort(coll, f=None) -> Optional[ISeq]: """Return a sorted sequence of the elements in coll. If a comparator function f is provided, compare elements in coll using f.""" return to_seq(sorted(coll, key=Maybe(f).map(functools.cmp_to_key).value))
def sort(coll, f=None) -> Optional[ISeq]: """Return a sorted sequence of the elements in coll. If a comparator function f is provided, compare elements in coll using f.""" return to_seq(sorted(coll, key=Maybe(f).map(functools.cmp_to_key).value))
[ "Return", "a", "sorted", "sequence", "of", "the", "elements", "in", "coll", ".", "If", "a", "comparator", "function", "f", "is", "provided", "compare", "elements", "in", "coll", "using", "f", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L963-L966
[ "def", "sort", "(", "coll", ",", "f", "=", "None", ")", "->", "Optional", "[", "ISeq", "]", ":", "return", "to_seq", "(", "sorted", "(", "coll", ",", "key", "=", "Maybe", "(", "f", ")", ".", "map", "(", "functools", ".", "cmp_to_key", ")", ".", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
contains
Return true if o contains the key k.
src/basilisp/lang/runtime.py
def contains(coll, k): """Return true if o contains the key k.""" if isinstance(coll, IAssociative): return coll.contains(k) return k in coll
def contains(coll, k): """Return true if o contains the key k.""" if isinstance(coll, IAssociative): return coll.contains(k) return k in coll
[ "Return", "true", "if", "o", "contains", "the", "key", "k", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L969-L973
[ "def", "contains", "(", "coll", ",", "k", ")", ":", "if", "isinstance", "(", "coll", ",", "IAssociative", ")", ":", "return", "coll", ".", "contains", "(", "k", ")", "return", "k", "in", "coll" ]
3d82670ee218ec64eb066289c82766d14d18cc92
test
get
Return the value of k in m. Return default if k not found in m.
src/basilisp/lang/runtime.py
def get(m, k, default=None): """Return the value of k in m. Return default if k not found in m.""" if isinstance(m, IAssociative): return m.entry(k, default=default) try: return m[k] except (KeyError, IndexError, TypeError) as e: logger.debug("Ignored %s: %s", type(e).__name__, ...
def get(m, k, default=None): """Return the value of k in m. Return default if k not found in m.""" if isinstance(m, IAssociative): return m.entry(k, default=default) try: return m[k] except (KeyError, IndexError, TypeError) as e: logger.debug("Ignored %s: %s", type(e).__name__, ...
[ "Return", "the", "value", "of", "k", "in", "m", ".", "Return", "default", "if", "k", "not", "found", "in", "m", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L976-L985
[ "def", "get", "(", "m", ",", "k", ",", "default", "=", "None", ")", ":", "if", "isinstance", "(", "m", ",", "IAssociative", ")", ":", "return", "m", ".", "entry", "(", "k", ",", "default", "=", "default", ")", "try", ":", "return", "m", "[", "k...
3d82670ee218ec64eb066289c82766d14d18cc92
test
to_lisp
Recursively convert Python collections into Lisp collections.
src/basilisp/lang/runtime.py
def to_lisp(o, keywordize_keys: bool = True): """Recursively convert Python collections into Lisp collections.""" if not isinstance(o, (dict, frozenset, list, set, tuple)): return o else: # pragma: no cover return _to_lisp_backup(o, keywordize_keys=keywordize_keys)
def to_lisp(o, keywordize_keys: bool = True): """Recursively convert Python collections into Lisp collections.""" if not isinstance(o, (dict, frozenset, list, set, tuple)): return o else: # pragma: no cover return _to_lisp_backup(o, keywordize_keys=keywordize_keys)
[ "Recursively", "convert", "Python", "collections", "into", "Lisp", "collections", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L994-L999
[ "def", "to_lisp", "(", "o", ",", "keywordize_keys", ":", "bool", "=", "True", ")", ":", "if", "not", "isinstance", "(", "o", ",", "(", "dict", ",", "frozenset", ",", "list", ",", "set", ",", "tuple", ")", ")", ":", "return", "o", "else", ":", "# ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
to_py
Recursively convert Lisp collections into Python collections.
src/basilisp/lang/runtime.py
def to_py(o, keyword_fn: Callable[[kw.Keyword], Any] = _kw_name): """Recursively convert Lisp collections into Python collections.""" if isinstance(o, ISeq): return _to_py_list(o, keyword_fn=keyword_fn) elif not isinstance( o, (IPersistentList, IPersistentMap, IPersistentSet, IPersistentVect...
def to_py(o, keyword_fn: Callable[[kw.Keyword], Any] = _kw_name): """Recursively convert Lisp collections into Python collections.""" if isinstance(o, ISeq): return _to_py_list(o, keyword_fn=keyword_fn) elif not isinstance( o, (IPersistentList, IPersistentMap, IPersistentSet, IPersistentVect...
[ "Recursively", "convert", "Lisp", "collections", "into", "Python", "collections", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1045-L1054
[ "def", "to_py", "(", "o", ",", "keyword_fn", ":", "Callable", "[", "[", "kw", ".", "Keyword", "]", ",", "Any", "]", "=", "_kw_name", ")", ":", "if", "isinstance", "(", "o", ",", "ISeq", ")", ":", "return", "_to_py_list", "(", "o", ",", "keyword_fn"...
3d82670ee218ec64eb066289c82766d14d18cc92
test
lrepr
Produce a string representation of an object. If human_readable is False, the string representation of Lisp objects is something that can be read back in by the reader as the same object.
src/basilisp/lang/runtime.py
def lrepr(o, human_readable: bool = False) -> str: """Produce a string representation of an object. If human_readable is False, the string representation of Lisp objects is something that can be read back in by the reader as the same object.""" core_ns = Namespace.get(sym.symbol(CORE_NS)) assert cor...
def lrepr(o, human_readable: bool = False) -> str: """Produce a string representation of an object. If human_readable is False, the string representation of Lisp objects is something that can be read back in by the reader as the same object.""" core_ns = Namespace.get(sym.symbol(CORE_NS)) assert cor...
[ "Produce", "a", "string", "representation", "of", "an", "object", ".", "If", "human_readable", "is", "False", "the", "string", "representation", "of", "Lisp", "objects", "is", "something", "that", "can", "be", "read", "back", "in", "by", "the", "reader", "as...
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1102-L1122
[ "def", "lrepr", "(", "o", ",", "human_readable", ":", "bool", "=", "False", ")", "->", "str", ":", "core_ns", "=", "Namespace", ".", "get", "(", "sym", ".", "symbol", "(", "CORE_NS", ")", ")", "assert", "core_ns", "is", "not", "None", "return", "lobj...
3d82670ee218ec64eb066289c82766d14d18cc92
test
repl_complete
Completer function for Python's readline/libedit implementation.
src/basilisp/lang/runtime.py
def repl_complete(text: str, state: int) -> Optional[str]: """Completer function for Python's readline/libedit implementation.""" # Can't complete Keywords, Numerals if __NOT_COMPLETEABLE.match(text): return None elif text.startswith(":"): completions = kw.complete(text) else: ...
def repl_complete(text: str, state: int) -> Optional[str]: """Completer function for Python's readline/libedit implementation.""" # Can't complete Keywords, Numerals if __NOT_COMPLETEABLE.match(text): return None elif text.startswith(":"): completions = kw.complete(text) else: ...
[ "Completer", "function", "for", "Python", "s", "readline", "/", "libedit", "implementation", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1133-L1144
[ "def", "repl_complete", "(", "text", ":", "str", ",", "state", ":", "int", ")", "->", "Optional", "[", "str", "]", ":", "# Can't complete Keywords, Numerals", "if", "__NOT_COMPLETEABLE", ".", "match", "(", "text", ")", ":", "return", "None", "elif", "text", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_collect_args
Collect Python starred arguments into a Basilisp list.
src/basilisp/lang/runtime.py
def _collect_args(args) -> ISeq: """Collect Python starred arguments into a Basilisp list.""" if isinstance(args, tuple): return llist.list(args) raise TypeError("Python variadic arguments should always be a tuple")
def _collect_args(args) -> ISeq: """Collect Python starred arguments into a Basilisp list.""" if isinstance(args, tuple): return llist.list(args) raise TypeError("Python variadic arguments should always be a tuple")
[ "Collect", "Python", "starred", "arguments", "into", "a", "Basilisp", "list", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1152-L1156
[ "def", "_collect_args", "(", "args", ")", "->", "ISeq", ":", "if", "isinstance", "(", "args", ",", "tuple", ")", ":", "return", "llist", ".", "list", "(", "args", ")", "raise", "TypeError", "(", "\"Python variadic arguments should always be a tuple\"", ")" ]
3d82670ee218ec64eb066289c82766d14d18cc92
test
_trampoline
Trampoline a function repeatedly until it is finished recurring to help avoid stack growth.
src/basilisp/lang/runtime.py
def _trampoline(f): """Trampoline a function repeatedly until it is finished recurring to help avoid stack growth.""" @functools.wraps(f) def trampoline(*args, **kwargs): while True: ret = f(*args, **kwargs) if isinstance(ret, _TrampolineArgs): args = ret...
def _trampoline(f): """Trampoline a function repeatedly until it is finished recurring to help avoid stack growth.""" @functools.wraps(f) def trampoline(*args, **kwargs): while True: ret = f(*args, **kwargs) if isinstance(ret, _TrampolineArgs): args = ret...
[ "Trampoline", "a", "function", "repeatedly", "until", "it", "is", "finished", "recurring", "to", "help", "avoid", "stack", "growth", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1189-L1203
[ "def", "_trampoline", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "trampoline", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "while", "True", ":", "ret", "=", "f", "(", "*", "args", ",", "*", "*", "kwargs",...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_with_attrs
Decorator to set attributes on a function. Returns the original function after setting the attributes named by the keyword arguments.
src/basilisp/lang/runtime.py
def _with_attrs(**kwargs): """Decorator to set attributes on a function. Returns the original function after setting the attributes named by the keyword arguments.""" def decorator(f): for k, v in kwargs.items(): setattr(f, k, v) return f return decorator
def _with_attrs(**kwargs): """Decorator to set attributes on a function. Returns the original function after setting the attributes named by the keyword arguments.""" def decorator(f): for k, v in kwargs.items(): setattr(f, k, v) return f return decorator
[ "Decorator", "to", "set", "attributes", "on", "a", "function", ".", "Returns", "the", "original", "function", "after", "setting", "the", "attributes", "named", "by", "the", "keyword", "arguments", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1206-L1215
[ "def", "_with_attrs", "(", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "f", ")", ":", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "setattr", "(", "f", ",", "k", ",", "v", ")", "return", "f", "return", "decorato...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_fn_with_meta
Return a new function with the given meta. If the function f already has a meta map, then merge the
src/basilisp/lang/runtime.py
def _fn_with_meta(f, meta: Optional[lmap.Map]): """Return a new function with the given meta. If the function f already has a meta map, then merge the """ if not isinstance(meta, lmap.Map): raise TypeError("meta must be a map") if inspect.iscoroutinefunction(f): @functools.wraps(f) ...
def _fn_with_meta(f, meta: Optional[lmap.Map]): """Return a new function with the given meta. If the function f already has a meta map, then merge the """ if not isinstance(meta, lmap.Map): raise TypeError("meta must be a map") if inspect.iscoroutinefunction(f): @functools.wraps(f) ...
[ "Return", "a", "new", "function", "with", "the", "given", "meta", ".", "If", "the", "function", "f", "already", "has", "a", "meta", "map", "then", "merge", "the" ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1218-L1243
[ "def", "_fn_with_meta", "(", "f", ",", "meta", ":", "Optional", "[", "lmap", ".", "Map", "]", ")", ":", "if", "not", "isinstance", "(", "meta", ",", "lmap", ".", "Map", ")", ":", "raise", "TypeError", "(", "\"meta must be a map\"", ")", "if", "inspect"...
3d82670ee218ec64eb066289c82766d14d18cc92
test
_basilisp_fn
Create a Basilisp function, setting meta and supplying a with_meta method implementation.
src/basilisp/lang/runtime.py
def _basilisp_fn(f): """Create a Basilisp function, setting meta and supplying a with_meta method implementation.""" assert not hasattr(f, "meta") f._basilisp_fn = True f.meta = None f.with_meta = partial(_fn_with_meta, f) return f
def _basilisp_fn(f): """Create a Basilisp function, setting meta and supplying a with_meta method implementation.""" assert not hasattr(f, "meta") f._basilisp_fn = True f.meta = None f.with_meta = partial(_fn_with_meta, f) return f
[ "Create", "a", "Basilisp", "function", "setting", "meta", "and", "supplying", "a", "with_meta", "method", "implementation", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1246-L1253
[ "def", "_basilisp_fn", "(", "f", ")", ":", "assert", "not", "hasattr", "(", "f", ",", "\"meta\"", ")", "f", ".", "_basilisp_fn", "=", "True", "f", ".", "meta", "=", "None", "f", ".", "with_meta", "=", "partial", "(", "_fn_with_meta", ",", "f", ")", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
init_ns_var
Initialize the dynamic `*ns*` variable in the Namespace `which_ns`.
src/basilisp/lang/runtime.py
def init_ns_var(which_ns: str = CORE_NS, ns_var_name: str = NS_VAR_NAME) -> Var: """Initialize the dynamic `*ns*` variable in the Namespace `which_ns`.""" core_sym = sym.Symbol(which_ns) core_ns = Namespace.get_or_create(core_sym) ns_var = Var.intern(core_sym, sym.Symbol(ns_var_name), core_ns, dynamic=T...
def init_ns_var(which_ns: str = CORE_NS, ns_var_name: str = NS_VAR_NAME) -> Var: """Initialize the dynamic `*ns*` variable in the Namespace `which_ns`.""" core_sym = sym.Symbol(which_ns) core_ns = Namespace.get_or_create(core_sym) ns_var = Var.intern(core_sym, sym.Symbol(ns_var_name), core_ns, dynamic=T...
[ "Initialize", "the", "dynamic", "*", "ns", "*", "variable", "in", "the", "Namespace", "which_ns", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1261-L1267
[ "def", "init_ns_var", "(", "which_ns", ":", "str", "=", "CORE_NS", ",", "ns_var_name", ":", "str", "=", "NS_VAR_NAME", ")", "->", "Var", ":", "core_sym", "=", "sym", ".", "Symbol", "(", "which_ns", ")", "core_ns", "=", "Namespace", ".", "get_or_create", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
set_current_ns
Set the value of the dynamic variable `*ns*` in the current thread.
src/basilisp/lang/runtime.py
def set_current_ns( ns_name: str, module: types.ModuleType = None, ns_var_name: str = NS_VAR_NAME, ns_var_ns: str = NS_VAR_NS, ) -> Var: """Set the value of the dynamic variable `*ns*` in the current thread.""" symbol = sym.Symbol(ns_name) ns = Namespace.get_or_create(symbol, module=module) ...
def set_current_ns( ns_name: str, module: types.ModuleType = None, ns_var_name: str = NS_VAR_NAME, ns_var_ns: str = NS_VAR_NS, ) -> Var: """Set the value of the dynamic variable `*ns*` in the current thread.""" symbol = sym.Symbol(ns_name) ns = Namespace.get_or_create(symbol, module=module) ...
[ "Set", "the", "value", "of", "the", "dynamic", "variable", "*", "ns", "*", "in", "the", "current", "thread", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1270-L1287
[ "def", "set_current_ns", "(", "ns_name", ":", "str", ",", "module", ":", "types", ".", "ModuleType", "=", "None", ",", "ns_var_name", ":", "str", "=", "NS_VAR_NAME", ",", "ns_var_ns", ":", "str", "=", "NS_VAR_NS", ",", ")", "->", "Var", ":", "symbol", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
ns_bindings
Context manager for temporarily changing the value of basilisp.core/*ns*.
src/basilisp/lang/runtime.py
def ns_bindings( ns_name: str, module: types.ModuleType = None, ns_var_name: str = NS_VAR_NAME, ns_var_ns: str = NS_VAR_NS, ): """Context manager for temporarily changing the value of basilisp.core/*ns*.""" symbol = sym.Symbol(ns_name) ns = Namespace.get_or_create(symbol, module=module) ...
def ns_bindings( ns_name: str, module: types.ModuleType = None, ns_var_name: str = NS_VAR_NAME, ns_var_ns: str = NS_VAR_NS, ): """Context manager for temporarily changing the value of basilisp.core/*ns*.""" symbol = sym.Symbol(ns_name) ns = Namespace.get_or_create(symbol, module=module) ...
[ "Context", "manager", "for", "temporarily", "changing", "the", "value", "of", "basilisp", ".", "core", "/", "*", "ns", "*", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1291-L1313
[ "def", "ns_bindings", "(", "ns_name", ":", "str", ",", "module", ":", "types", ".", "ModuleType", "=", "None", ",", "ns_var_name", ":", "str", "=", "NS_VAR_NAME", ",", "ns_var_ns", ":", "str", "=", "NS_VAR_NS", ",", ")", ":", "symbol", "=", "sym", ".",...
3d82670ee218ec64eb066289c82766d14d18cc92
test
remove_ns_bindings
Context manager to pop the most recent bindings for basilisp.core/*ns* after completion of the code under management.
src/basilisp/lang/runtime.py
def remove_ns_bindings(ns_var_name: str = NS_VAR_NAME, ns_var_ns: str = NS_VAR_NS): """Context manager to pop the most recent bindings for basilisp.core/*ns* after completion of the code under management.""" ns_var_sym = sym.Symbol(ns_var_name, ns=ns_var_ns) ns_var = Maybe(Var.find(ns_var_sym)).or_else_...
def remove_ns_bindings(ns_var_name: str = NS_VAR_NAME, ns_var_ns: str = NS_VAR_NS): """Context manager to pop the most recent bindings for basilisp.core/*ns* after completion of the code under management.""" ns_var_sym = sym.Symbol(ns_var_name, ns=ns_var_ns) ns_var = Maybe(Var.find(ns_var_sym)).or_else_...
[ "Context", "manager", "to", "pop", "the", "most", "recent", "bindings", "for", "basilisp", ".", "core", "/", "*", "ns", "*", "after", "completion", "of", "the", "code", "under", "management", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1317-L1330
[ "def", "remove_ns_bindings", "(", "ns_var_name", ":", "str", "=", "NS_VAR_NAME", ",", "ns_var_ns", ":", "str", "=", "NS_VAR_NS", ")", ":", "ns_var_sym", "=", "sym", ".", "Symbol", "(", "ns_var_name", ",", "ns", "=", "ns_var_ns", ")", "ns_var", "=", "Maybe"...
3d82670ee218ec64eb066289c82766d14d18cc92
test
get_current_ns
Get the value of the dynamic variable `*ns*` in the current thread.
src/basilisp/lang/runtime.py
def get_current_ns( ns_var_name: str = NS_VAR_NAME, ns_var_ns: str = NS_VAR_NS ) -> Namespace: """Get the value of the dynamic variable `*ns*` in the current thread.""" ns_sym = sym.Symbol(ns_var_name, ns=ns_var_ns) ns: Namespace = Maybe(Var.find(ns_sym)).map(lambda v: v.value).or_else_raise( la...
def get_current_ns( ns_var_name: str = NS_VAR_NAME, ns_var_ns: str = NS_VAR_NS ) -> Namespace: """Get the value of the dynamic variable `*ns*` in the current thread.""" ns_sym = sym.Symbol(ns_var_name, ns=ns_var_ns) ns: Namespace = Maybe(Var.find(ns_sym)).map(lambda v: v.value).or_else_raise( la...
[ "Get", "the", "value", "of", "the", "dynamic", "variable", "*", "ns", "*", "in", "the", "current", "thread", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1333-L1341
[ "def", "get_current_ns", "(", "ns_var_name", ":", "str", "=", "NS_VAR_NAME", ",", "ns_var_ns", ":", "str", "=", "NS_VAR_NS", ")", "->", "Namespace", ":", "ns_sym", "=", "sym", ".", "Symbol", "(", "ns_var_name", ",", "ns", "=", "ns_var_ns", ")", "ns", ":"...
3d82670ee218ec64eb066289c82766d14d18cc92
test
resolve_alias
Resolve the aliased symbol in the current namespace.
src/basilisp/lang/runtime.py
def resolve_alias(s: sym.Symbol, ns: Optional[Namespace] = None) -> sym.Symbol: """Resolve the aliased symbol in the current namespace.""" if s in _SPECIAL_FORMS: return s ns = Maybe(ns).or_else(get_current_ns) if s.ns is not None: aliased_ns = ns.get_alias(sym.symbol(s.ns)) if ...
def resolve_alias(s: sym.Symbol, ns: Optional[Namespace] = None) -> sym.Symbol: """Resolve the aliased symbol in the current namespace.""" if s in _SPECIAL_FORMS: return s ns = Maybe(ns).or_else(get_current_ns) if s.ns is not None: aliased_ns = ns.get_alias(sym.symbol(s.ns)) if ...
[ "Resolve", "the", "aliased", "symbol", "in", "the", "current", "namespace", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1344-L1361
[ "def", "resolve_alias", "(", "s", ":", "sym", ".", "Symbol", ",", "ns", ":", "Optional", "[", "Namespace", "]", "=", "None", ")", "->", "sym", ".", "Symbol", ":", "if", "s", "in", "_SPECIAL_FORMS", ":", "return", "s", "ns", "=", "Maybe", "(", "ns",...
3d82670ee218ec64eb066289c82766d14d18cc92
test
resolve_var
Resolve the aliased symbol to a Var from the specified namespace, or the current namespace if none is specified.
src/basilisp/lang/runtime.py
def resolve_var(s: sym.Symbol, ns: Optional[Namespace] = None) -> Optional[Var]: """Resolve the aliased symbol to a Var from the specified namespace, or the current namespace if none is specified.""" return Var.find(resolve_alias(s, ns))
def resolve_var(s: sym.Symbol, ns: Optional[Namespace] = None) -> Optional[Var]: """Resolve the aliased symbol to a Var from the specified namespace, or the current namespace if none is specified.""" return Var.find(resolve_alias(s, ns))
[ "Resolve", "the", "aliased", "symbol", "to", "a", "Var", "from", "the", "specified", "namespace", "or", "the", "current", "namespace", "if", "none", "is", "specified", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1364-L1367
[ "def", "resolve_var", "(", "s", ":", "sym", ".", "Symbol", ",", "ns", ":", "Optional", "[", "Namespace", "]", "=", "None", ")", "->", "Optional", "[", "Var", "]", ":", "return", "Var", ".", "find", "(", "resolve_alias", "(", "s", ",", "ns", ")", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
add_generated_python
Add generated Python code to a dynamic variable in which_ns.
src/basilisp/lang/runtime.py
def add_generated_python( generated_python: str, var_name: str = _GENERATED_PYTHON_VAR_NAME, which_ns: Optional[str] = None, ) -> None: """Add generated Python code to a dynamic variable in which_ns.""" if which_ns is None: which_ns = get_current_ns().name ns_sym = sym.Symbol(var_name, n...
def add_generated_python( generated_python: str, var_name: str = _GENERATED_PYTHON_VAR_NAME, which_ns: Optional[str] = None, ) -> None: """Add generated Python code to a dynamic variable in which_ns.""" if which_ns is None: which_ns = get_current_ns().name ns_sym = sym.Symbol(var_name, n...
[ "Add", "generated", "Python", "code", "to", "a", "dynamic", "variable", "in", "which_ns", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1370-L1388
[ "def", "add_generated_python", "(", "generated_python", ":", "str", ",", "var_name", ":", "str", "=", "_GENERATED_PYTHON_VAR_NAME", ",", "which_ns", ":", "Optional", "[", "str", "]", "=", "None", ",", ")", "->", "None", ":", "if", "which_ns", "is", "None", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
print_generated_python
Return the value of the `*print-generated-python*` dynamic variable.
src/basilisp/lang/runtime.py
def print_generated_python( var_name: str = _PRINT_GENERATED_PY_VAR_NAME, core_ns_name: str = CORE_NS ) -> bool: """Return the value of the `*print-generated-python*` dynamic variable.""" ns_sym = sym.Symbol(var_name, ns=core_ns_name) return ( Maybe(Var.find(ns_sym)) .map(lambda v: v.val...
def print_generated_python( var_name: str = _PRINT_GENERATED_PY_VAR_NAME, core_ns_name: str = CORE_NS ) -> bool: """Return the value of the `*print-generated-python*` dynamic variable.""" ns_sym = sym.Symbol(var_name, ns=core_ns_name) return ( Maybe(Var.find(ns_sym)) .map(lambda v: v.val...
[ "Return", "the", "value", "of", "the", "*", "print", "-", "generated", "-", "python", "*", "dynamic", "variable", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1391-L1400
[ "def", "print_generated_python", "(", "var_name", ":", "str", "=", "_PRINT_GENERATED_PY_VAR_NAME", ",", "core_ns_name", ":", "str", "=", "CORE_NS", ")", "->", "bool", ":", "ns_sym", "=", "sym", ".", "Symbol", "(", "var_name", ",", "ns", "=", "core_ns_name", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
bootstrap
Bootstrap the environment with functions that are are difficult to express with the very minimal lisp environment.
src/basilisp/lang/runtime.py
def bootstrap(ns_var_name: str = NS_VAR_NAME, core_ns_name: str = CORE_NS) -> None: """Bootstrap the environment with functions that are are difficult to express with the very minimal lisp environment.""" core_ns_sym = sym.symbol(core_ns_name) ns_var_sym = sym.symbol(ns_var_name, ns=core_ns_name) __...
def bootstrap(ns_var_name: str = NS_VAR_NAME, core_ns_name: str = CORE_NS) -> None: """Bootstrap the environment with functions that are are difficult to express with the very minimal lisp environment.""" core_ns_sym = sym.symbol(core_ns_name) ns_var_sym = sym.symbol(ns_var_name, ns=core_ns_name) __...
[ "Bootstrap", "the", "environment", "with", "functions", "that", "are", "are", "difficult", "to", "express", "with", "the", "very", "minimal", "lisp", "environment", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L1403-L1455
[ "def", "bootstrap", "(", "ns_var_name", ":", "str", "=", "NS_VAR_NAME", ",", "core_ns_name", ":", "str", "=", "CORE_NS", ")", "->", "None", ":", "core_ns_sym", "=", "sym", ".", "symbol", "(", "core_ns_name", ")", "ns_var_sym", "=", "sym", ".", "symbol", ...
3d82670ee218ec64eb066289c82766d14d18cc92
test
Var.intern
Intern the value bound to the symbol `name` in namespace `ns`.
src/basilisp/lang/runtime.py
def intern( ns: sym.Symbol, name: sym.Symbol, val, dynamic: bool = False, meta=None ) -> "Var": """Intern the value bound to the symbol `name` in namespace `ns`.""" var_ns = Namespace.get_or_create(ns) var = var_ns.intern(name, Var(var_ns, name, dynamic=dynamic, meta=meta)) v...
def intern( ns: sym.Symbol, name: sym.Symbol, val, dynamic: bool = False, meta=None ) -> "Var": """Intern the value bound to the symbol `name` in namespace `ns`.""" var_ns = Namespace.get_or_create(ns) var = var_ns.intern(name, Var(var_ns, name, dynamic=dynamic, meta=meta)) v...
[ "Intern", "the", "value", "bound", "to", "the", "symbol", "name", "in", "namespace", "ns", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L233-L240
[ "def", "intern", "(", "ns", ":", "sym", ".", "Symbol", ",", "name", ":", "sym", ".", "Symbol", ",", "val", ",", "dynamic", ":", "bool", "=", "False", ",", "meta", "=", "None", ")", "->", "\"Var\"", ":", "var_ns", "=", "Namespace", ".", "get_or_crea...
3d82670ee218ec64eb066289c82766d14d18cc92
test
Var.intern_unbound
Create a new unbound `Var` instance to the symbol `name` in namespace `ns`.
src/basilisp/lang/runtime.py
def intern_unbound( ns: sym.Symbol, name: sym.Symbol, dynamic: bool = False, meta=None ) -> "Var": """Create a new unbound `Var` instance to the symbol `name` in namespace `ns`.""" var_ns = Namespace.get_or_create(ns) return var_ns.intern(name, Var(var_ns, name, dynamic=dynamic, meta...
def intern_unbound( ns: sym.Symbol, name: sym.Symbol, dynamic: bool = False, meta=None ) -> "Var": """Create a new unbound `Var` instance to the symbol `name` in namespace `ns`.""" var_ns = Namespace.get_or_create(ns) return var_ns.intern(name, Var(var_ns, name, dynamic=dynamic, meta...
[ "Create", "a", "new", "unbound", "Var", "instance", "to", "the", "symbol", "name", "in", "namespace", "ns", "." ]
chrisrink10/basilisp
python
https://github.com/chrisrink10/basilisp/blob/3d82670ee218ec64eb066289c82766d14d18cc92/src/basilisp/lang/runtime.py#L243-L248
[ "def", "intern_unbound", "(", "ns", ":", "sym", ".", "Symbol", ",", "name", ":", "sym", ".", "Symbol", ",", "dynamic", ":", "bool", "=", "False", ",", "meta", "=", "None", ")", "->", "\"Var\"", ":", "var_ns", "=", "Namespace", ".", "get_or_create", "...
3d82670ee218ec64eb066289c82766d14d18cc92