Add None constants.

pull/1/head
Stella Laurenzo 2020-06-07 16:21:00 -07:00
parent 4cd604f2a2
commit 7c176ed872
2 changed files with 10 additions and 0 deletions

View File

@ -76,3 +76,11 @@ def ellipsis():
# CHECK: basicpy.unknown_cast %[[A]]
a = ...
return a
# CHECK-LABEL: func @none_constant
@import_global
def none_constant():
# CHECK: %[[A:.*]] = basicpy.singleton : !basicpy.NoneType
# CHECK: basicpy.unknown_cast %[[A]]
a = None
return a

View File

@ -191,6 +191,8 @@ class ExpressionImporter(BaseNodeVisitor):
self.value = ir_h.basicpy_bool_constant_op(True).result
elif value is False:
self.value = ir_h.basicpy_bool_constant_op(False).result
elif value is None:
self.value = ir_h.basicpy_singleton_op(ir_h.basicpy_NoneType).result
elif isinstance(value, int):
# TODO: Configurable type mapping
ir_type = ir_h.i64_type