diff --git a/artiq/compiler/embedding.py b/artiq/compiler/embedding.py index ed9ec1ad4..dbac0fa17 100644 --- a/artiq/compiler/embedding.py +++ b/artiq/compiler/embedding.py @@ -74,6 +74,10 @@ class ASTSynthesizer: typ = builtins.TFloat() return asttyped.NumT(n=value, ctx=None, type=typ, loc=self._add(repr(value))) + elif isinstance(value, language_core.int): + typ = builtins.TInt(width=types.TValue(value.width)) + return asttyped.NumT(n=int(value), ctx=None, type=typ, + loc=self._add(repr(value))) elif isinstance(value, str): return asttyped.StrT(s=value, ctx=None, type=builtins.TStr(), loc=self._add(repr(value))) diff --git a/artiq/compiler/transforms/llvm_ir_generator.py b/artiq/compiler/transforms/llvm_ir_generator.py index 05e3212ab..ef20056f0 100644 --- a/artiq/compiler/transforms/llvm_ir_generator.py +++ b/artiq/compiler/transforms/llvm_ir_generator.py @@ -6,6 +6,7 @@ into LLVM intermediate representation. import os from pythonparser import ast, diagnostic from llvmlite_artiq import ir as ll +from ...language import core as language_core from .. import types, builtins, ir @@ -1007,8 +1008,8 @@ class LLVMIRGenerator: assert value in (True, False) return ll.Constant(lli1, value) elif builtins.is_int(typ): - assert isinstance(value, int) - return ll.Constant(ll.IntType(builtins.get_int_width(typ)), value) + assert isinstance(value, (int, language_core.int)) + return ll.Constant(ll.IntType(builtins.get_int_width(typ)), int(value)) elif builtins.is_float(typ): assert isinstance(value, float) return ll.Constant(lldouble, value) diff --git a/artiq/language/core.py b/artiq/language/core.py index 1a931d2d9..c87cc8e0f 100644 --- a/artiq/language/core.py +++ b/artiq/language/core.py @@ -72,8 +72,8 @@ class int: return self @property - def width(width): - return width._width + def width(self): + return self._width def __int__(self): return self._value