forked from M-Labs/artiq
compiler: handle language.core.int during embedding.
This commit is contained in:
parent
83ebb999c8
commit
c621b1f275
@ -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)))
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user