|
1 | | -from operator import index |
2 | | - |
3 | | -from jinja2.runtime import new_context |
4 | | -from numba.typed.listobject import new_list |
5 | 1 | import os |
6 | 2 |
|
7 | 3 | TT_FLOAT = 'FLOAT' |
@@ -1206,6 +1202,9 @@ def multed_by(self, other): |
1206 | 1202 | else: |
1207 | 1203 | return None, Value.illegal_operation(self, other) |
1208 | 1204 |
|
| 1205 | + def __str__(self): |
| 1206 | + return f'{",".join([str(x) for x in self.elements])}' |
| 1207 | + |
1209 | 1208 | def __repr__(self): |
1210 | 1209 | return f'[{",".join([str(x) for x in self.elements])}]' |
1211 | 1210 |
|
@@ -1414,7 +1413,6 @@ def populate_args(self, arg_names, args, exec_ctx): |
1414 | 1413 | for i in range(len(args)): |
1415 | 1414 | arg_name = arg_names[i] |
1416 | 1415 | arg_value = args[i] |
1417 | | - # maybe newcontext? |
1418 | 1416 | arg_value.set_context(exec_ctx) |
1419 | 1417 | exec_ctx.symbol_table.set(arg_name, arg_value) |
1420 | 1418 |
|
@@ -1830,19 +1828,15 @@ def visit_CallNode(self, node, context): |
1830 | 1828 | res = RTResult() |
1831 | 1829 | args = [] |
1832 | 1830 |
|
1833 | | - # 不再 copy(),保留原函数引用 |
1834 | 1831 | value_to_call = res.register(self.visit(node.node_to_call, context)) |
1835 | 1832 | if res.error: return res |
1836 | 1833 | value_to_call.set_pos(node.pos_start, node.pos_end).set_context(context) |
1837 | 1834 |
|
1838 | 1835 | for arg_node in node.arg_nodes: |
1839 | 1836 | args.append(res.register(self.visit(arg_node, context))) |
1840 | 1837 | if res.error: return res |
1841 | | - |
1842 | 1838 | return_value = res.register(value_to_call.execute(args)) |
1843 | 1839 | if res.error: return res |
1844 | | - |
1845 | | - # 返回值可以 copy,因为它是新创建的,不会影响上下文 |
1846 | 1840 | return res.success(return_value.copy().set_pos(node.pos_start, node.pos_end).set_context(context)) |
1847 | 1841 |
|
1848 | 1842 |
|
|
0 commit comments