parent
24ebbc611e
commit
5b879323aa
@ -1806,16 +1806,17 @@ class HyASTCompiler(object):
|
|||||||
ctx=ast.Load(),
|
ctx=ast.Load(),
|
||||||
lineno=root_line,
|
lineno=root_line,
|
||||||
col_offset=root_column)
|
col_offset=root_column)
|
||||||
|
temp_variables = [name, expr_name]
|
||||||
|
|
||||||
def make_assign(value, node=None):
|
def make_assign(value, node=None):
|
||||||
if node is None:
|
if node is None:
|
||||||
line, column = root_line, root_column
|
line, column = root_line, root_column
|
||||||
else:
|
else:
|
||||||
line, column = node.lineno, node.col_offset
|
line, column = node.lineno, node.col_offset
|
||||||
return ast.Assign(targets=[ast.Name(id=var,
|
positioned_name = ast.Name(id=var, ctx=ast.Store(),
|
||||||
ctx=ast.Store(),
|
lineno=line, col_offset=column)
|
||||||
lineno=line,
|
temp_variables.append(positioned_name)
|
||||||
col_offset=column)],
|
return ast.Assign(targets=[positioned_name],
|
||||||
value=value,
|
value=value,
|
||||||
lineno=line,
|
lineno=line,
|
||||||
col_offset=column)
|
col_offset=column)
|
||||||
@ -1845,7 +1846,7 @@ class HyASTCompiler(object):
|
|||||||
orelse=[]))
|
orelse=[]))
|
||||||
current = current[-1].body
|
current = current[-1].body
|
||||||
ret = sum(root, ret)
|
ret = sum(root, ret)
|
||||||
ret += Result(expr=expr_name, temp_variables=[expr_name, name])
|
ret += Result(expr=expr_name, temp_variables=temp_variables)
|
||||||
else:
|
else:
|
||||||
ret += ast.BoolOp(op=opnode(),
|
ret += ast.BoolOp(op=opnode(),
|
||||||
lineno=root_line,
|
lineno=root_line,
|
||||||
|
@ -949,6 +949,28 @@
|
|||||||
(and 0 (setv a 2))
|
(and 0 (setv a 2))
|
||||||
(assert (= a 1)))
|
(assert (= a 1)))
|
||||||
|
|
||||||
|
(defn test-and-#1151-do []
|
||||||
|
(setv a (and 0 (do 2 3)))
|
||||||
|
(assert (= a 0))
|
||||||
|
(setv a (and 1 (do 2 3)))
|
||||||
|
(assert (= a 3)))
|
||||||
|
|
||||||
|
(defn test-and-#1151-for []
|
||||||
|
(setv l [])
|
||||||
|
(setv x (and 0 (for [n [1 2]] (.append l n))))
|
||||||
|
(assert (= x 0))
|
||||||
|
(assert (= l []))
|
||||||
|
(setv x (and 15 (for [n [1 2]] (.append l n))))
|
||||||
|
(assert (= l [1 2])))
|
||||||
|
|
||||||
|
(defn test-and-#1151-del []
|
||||||
|
(setv l ["a" "b"])
|
||||||
|
(setv x (and 0 (del (get l 1))))
|
||||||
|
(assert (= x 0))
|
||||||
|
(assert (= l ["a" "b"]))
|
||||||
|
(setv x (and 15 (del (get l 1))))
|
||||||
|
(assert (= l ["a"])))
|
||||||
|
|
||||||
|
|
||||||
(defn test-or []
|
(defn test-or []
|
||||||
"NATIVE: test the or function"
|
"NATIVE: test the or function"
|
||||||
@ -967,6 +989,27 @@
|
|||||||
(or 1 (setv a 2))
|
(or 1 (setv a 2))
|
||||||
(assert (= a 1)))
|
(assert (= a 1)))
|
||||||
|
|
||||||
|
(defn test-or-#1151-do []
|
||||||
|
(setv a (or 1 (do 2 3)))
|
||||||
|
(assert (= a 1))
|
||||||
|
(setv a (or 0 (do 2 3)))
|
||||||
|
(assert (= a 3)))
|
||||||
|
|
||||||
|
(defn test-or-#1151-for []
|
||||||
|
(setv l [])
|
||||||
|
(setv x (or 15 (for [n [1 2]] (.append l n))))
|
||||||
|
(assert (= x 15))
|
||||||
|
(assert (= l []))
|
||||||
|
(setv x (or 0 (for [n [1 2]] (.append l n))))
|
||||||
|
(assert (= l [1 2])))
|
||||||
|
|
||||||
|
(defn test-or-#1151-del []
|
||||||
|
(setv l ["a" "b"])
|
||||||
|
(setv x (or 15 (del (get l 1))))
|
||||||
|
(assert (= x 15))
|
||||||
|
(assert (= l ["a" "b"]))
|
||||||
|
(setv x (or 0 (del (get l 1))))
|
||||||
|
(assert (= l ["a"])))
|
||||||
|
|
||||||
(defn test-xor []
|
(defn test-xor []
|
||||||
"NATIVE: test the xor macro"
|
"NATIVE: test the xor macro"
|
||||||
|
Loading…
Reference in New Issue
Block a user