global
now takes multiple arguments.
This commit is contained in:
parent
2bf723a5d1
commit
cfa805c102
@ -1017,13 +1017,21 @@ class HyASTCompiler(object):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
@builds("global")
|
@builds("global")
|
||||||
@checkargs(1)
|
@checkargs(min=1)
|
||||||
def compile_global_expression(self, expr):
|
def compile_global_expression(self, expr):
|
||||||
expr.pop(0) # global
|
expr.pop(0) # global
|
||||||
e = expr.pop(0)
|
names = []
|
||||||
return ast.Global(names=[ast_str(e)],
|
while len(expr) > 0:
|
||||||
lineno=e.start_line,
|
identifier = expr.pop(0)
|
||||||
col_offset=e.start_column)
|
name = ast_str(identifier)
|
||||||
|
names.append(name)
|
||||||
|
if not isinstance(identifier, HySymbol):
|
||||||
|
raise HyTypeError(identifier, "(global) arguments must "
|
||||||
|
" be Symbols")
|
||||||
|
|
||||||
|
return ast.Global(names=names,
|
||||||
|
lineno=expr.start_line,
|
||||||
|
col_offset=expr.start_column)
|
||||||
|
|
||||||
@builds("yield")
|
@builds("yield")
|
||||||
@checkargs(max=1)
|
@checkargs(max=1)
|
||||||
|
@ -211,12 +211,13 @@ def test_ast_bad_assert():
|
|||||||
def test_ast_good_global():
|
def test_ast_good_global():
|
||||||
"Make sure AST can compile valid global"
|
"Make sure AST can compile valid global"
|
||||||
can_compile("(global a)")
|
can_compile("(global a)")
|
||||||
|
can_compile("(global foo bar)")
|
||||||
|
|
||||||
|
|
||||||
def test_ast_bad_global():
|
def test_ast_bad_global():
|
||||||
"Make sure AST can't compile invalid global"
|
"Make sure AST can't compile invalid global"
|
||||||
cant_compile("(global)")
|
cant_compile("(global)")
|
||||||
cant_compile("(global foo bar)")
|
cant_compile("(global (foo))")
|
||||||
|
|
||||||
|
|
||||||
def test_ast_good_defclass():
|
def test_ast_good_defclass():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user