mirror of
https://github.com/exaloop/codon.git
synced 2025-06-03 15:03:52 +08:00
Update format error checking
Simplifies LLVM IR output when not using format strings
This commit is contained in:
parent
fd43d67f28
commit
0a08303870
@ -8,7 +8,7 @@ class int:
|
|||||||
def __format__(self, format_spec: str) -> str:
|
def __format__(self, format_spec: str) -> str:
|
||||||
err = False
|
err = False
|
||||||
ret = _C.seq_str_int(self, format_spec, __ptr__(err))
|
ret = _C.seq_str_int(self, format_spec, __ptr__(err))
|
||||||
if err:
|
if format_spec and err:
|
||||||
_format_error(ret)
|
_format_error(ret)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ class Int:
|
|||||||
def __format__(self, format_spec: str) -> str:
|
def __format__(self, format_spec: str) -> str:
|
||||||
err = False
|
err = False
|
||||||
ret = _C.seq_str_int(self.__int__(), format_spec, __ptr__(err))
|
ret = _C.seq_str_int(self.__int__(), format_spec, __ptr__(err))
|
||||||
if err:
|
if format_spec and err:
|
||||||
_format_error(ret)
|
_format_error(ret)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ class UInt:
|
|||||||
def __format__(self, format_spec: str) -> str:
|
def __format__(self, format_spec: str) -> str:
|
||||||
err = False
|
err = False
|
||||||
ret = _C.seq_str_uint(self.__int__(), format_spec, __ptr__(err))
|
ret = _C.seq_str_uint(self.__int__(), format_spec, __ptr__(err))
|
||||||
if err:
|
if format_spec and err:
|
||||||
_format_error(ret)
|
_format_error(ret)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ class float:
|
|||||||
def __format__(self, format_spec: str) -> str:
|
def __format__(self, format_spec: str) -> str:
|
||||||
err = False
|
err = False
|
||||||
ret = _C.seq_str_float(self, format_spec, __ptr__(err))
|
ret = _C.seq_str_float(self, format_spec, __ptr__(err))
|
||||||
if err:
|
if format_spec and err:
|
||||||
_format_error(ret)
|
_format_error(ret)
|
||||||
return ret if ret != "-nan" else "nan"
|
return ret if ret != "-nan" else "nan"
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ class str:
|
|||||||
def __format__(self, format_spec: str) -> str:
|
def __format__(self, format_spec: str) -> str:
|
||||||
err = False
|
err = False
|
||||||
ret = _C.seq_str_str(self, format_spec, __ptr__(err))
|
ret = _C.seq_str_str(self, format_spec, __ptr__(err))
|
||||||
if err:
|
if format_spec and err:
|
||||||
_format_error(ret)
|
_format_error(ret)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -53,6 +53,6 @@ class Ptr:
|
|||||||
def __format__(self, format_spec: str) -> str:
|
def __format__(self, format_spec: str) -> str:
|
||||||
err = False
|
err = False
|
||||||
ret = _C.seq_str_ptr(self.as_byte(), format_spec, __ptr__(err))
|
ret = _C.seq_str_ptr(self.as_byte(), format_spec, __ptr__(err))
|
||||||
if err:
|
if format_spec and err:
|
||||||
_format_error(ret)
|
_format_error(ret)
|
||||||
return ret
|
return ret
|
||||||
|
Loading…
x
Reference in New Issue
Block a user