From a1e6ff4ab7c53795eecd87b6c584a1239dadddd8 Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Sun, 7 Jun 2020 15:49:39 -0700 Subject: [PATCH] Add ellipsis constants. --- pytest/Compiler/constants.py | 7 +++++++ python/npcomp/compiler/frontend.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/pytest/Compiler/constants.py b/pytest/Compiler/constants.py index b6196cc99..273b921a7 100644 --- a/pytest/Compiler/constants.py +++ b/pytest/Compiler/constants.py @@ -61,3 +61,10 @@ def joined_string_constant(): a = "I am" " still here" return a +# CHECK-LABEL: func @ellipsis +@import_global +def ellipsis(): + # CHECK: %[[A:.*]] = basicpy.singleton : !basicpy.EllipsisType + # CHECK: basicpy.unknown_cast %[[A]] + a = ... + return a diff --git a/python/npcomp/compiler/frontend.py b/python/npcomp/compiler/frontend.py index 669ea58eb..c1d6c65e2 100644 --- a/python/npcomp/compiler/frontend.py +++ b/python/npcomp/compiler/frontend.py @@ -210,6 +210,8 @@ class ExpressionImporter(BaseNodeVisitor): self.fctx.abort("unknown named constant '%r'" % (ast_node.value,)) elif isinstance(ast_node, ast.Str): self.value = ir_h.basicpy_str_constant_op(ast_node.s).result + elif isinstance(ast_node, ast.Ellipsis): + self.value = ir_h.basicpy_singleton_op(ir_h.basicpy_EllipsisType).result else: self.fctx.abort("unknown constant type %s" % (ast_node.__class__.__name__))