unstaged changes
This commit is contained in:
parent
9a31fc1f81
commit
fecf17960d
@ -23,4 +23,5 @@ __appname__ = "hy"
|
|||||||
__version__ = "0.ALPHA.REALLY.1.0~pre0"
|
__version__ = "0.ALPHA.REALLY.1.0~pre0"
|
||||||
|
|
||||||
|
|
||||||
import hy.importer
|
import hy.importer # NOQA
|
||||||
|
# we import for side-effects.
|
||||||
|
@ -106,34 +106,23 @@ class HyASTCompiler(object):
|
|||||||
name = "_hy_anon_fn_%d" % (self.anon_fn_count)
|
name = "_hy_anon_fn_%d" % (self.anon_fn_count)
|
||||||
sig = expression.pop(0)
|
sig = expression.pop(0)
|
||||||
|
|
||||||
ret = ast.FunctionDef(
|
ret = ast.FunctionDef(name=name, vararg=None, kwarg=None,
|
||||||
name=name,
|
kwonlyargs=[], kw_defaults=[], defaults=[],
|
||||||
lineno=expression.start_line,
|
lineno=expression.start_line,
|
||||||
col_offset=expression.start_column,
|
col_offset=expression.start_column,
|
||||||
args=ast.arguments(
|
args=ast.arguments(args=[
|
||||||
args=[
|
ast.Name(arg=str(x), id=str(x),
|
||||||
ast.Name(
|
|
||||||
arg=str(x),
|
|
||||||
id=str(x),
|
|
||||||
ctx=ast.Param(),
|
ctx=ast.Param(),
|
||||||
lineno=x.start_line,
|
lineno=x.start_line,
|
||||||
col_offset=x.start_column
|
col_offset=x.start_column)
|
||||||
) for x in sig
|
for x in sig]),
|
||||||
],
|
body=self._mangle_branch([
|
||||||
vararg=None,
|
self.compile(x) for x in expression]),
|
||||||
kwarg=None,
|
decorator_list=[])
|
||||||
kwonlyargs=[],
|
|
||||||
kw_defaults=[],
|
|
||||||
defaults=[]
|
|
||||||
),
|
|
||||||
body=self._mangle_branch([self.compile(x) for x in expression]),
|
|
||||||
decorator_list=[]
|
|
||||||
)
|
|
||||||
|
|
||||||
self.returnable = ret_status
|
self.returnable = ret_status
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
@builds(HySymbol)
|
@builds(HySymbol)
|
||||||
def compile_symbol(self, symbol):
|
def compile_symbol(self, symbol):
|
||||||
return ast.Name(id=str(symbol), ctx=ast.Load(),
|
return ast.Name(id=str(symbol), ctx=ast.Load(),
|
||||||
|
@ -57,3 +57,9 @@ def test_ast_expression_basics():
|
|||||||
))
|
))
|
||||||
|
|
||||||
_ast_spotcheck("value.func.id", code, tree)
|
_ast_spotcheck("value.func.id", code, tree)
|
||||||
|
|
||||||
|
|
||||||
|
def test_ast_anon_fns_basics():
|
||||||
|
""" Ensure anon fns work. """
|
||||||
|
code = hy_compile(tokenize("(fn (x) (* x x))")).body[0]
|
||||||
|
assert type(code) == ast.FunctionDef
|
||||||
|
Loading…
x
Reference in New Issue
Block a user