77from src .api import global_ , tmp_labels
88from src .api .config import OPTIONS , OptimizationStrategy
99from src .api .exception import TempAlreadyFreedError
10-
1110from .runtime import LABEL_REQUIRED_MODULES , NAMESPACE , RUNTIME_LABELS
1211from .runtime import Labels as RuntimeLabel
1312
@@ -34,6 +33,7 @@ class DataType(StrEnum):
3433 i32 = "i32"
3534 f16 = "f16"
3635 f = "f"
36+ str = "str"
3737
3838
3939# Handy constants, to not having to type long names :-)
@@ -46,7 +46,7 @@ class DataType(StrEnum):
4646I32_t : Final [DataType ] = DataType .i32
4747F16_t : Final [DataType ] = DataType .f16
4848F_t : Final [DataType ] = DataType .f
49-
49+ STR_t : Final [ DataType ] = DataType . str
5050
5151# Internal data types definition, with its size in bytes, or -1 if it is variable (string)
5252# Compound types are only arrays, and have the t
@@ -297,32 +297,6 @@ def get_bytes_size(elements: list[str]) -> int:
297297 return len (get_bytes (elements ))
298298
299299
300- def to_bool (stype : DataType ) -> list [str ]:
301- """Returns the instruction sequence for converting the number given number (in the stack)
302- to boolean (just 0 (False) or non-zero (True))."""
303-
304- if stype in (U8_t , I8_t ):
305- return []
306-
307- if stype in (U16_t , I16_t ):
308- return [
309- "ld a, h" "or l" ,
310- ]
311-
312- if stype in (U32_t , I32_t , F16_t ):
313- return ["ld a, h" "or l" "or d" , "or e," ]
314-
315- if stype == F_t :
316- return [
317- "or b" ,
318- "or c" ,
319- "or d" ,
320- "or e" ,
321- ]
322-
323- raise NotImplementedError (f"type conversion from { stype } to bool is undefined" )
324-
325-
326300def normalize_boolean () -> list [str ]:
327301 if OPTIONS .opt_strategy == OptimizationStrategy .Size :
328302 return [runtime_call (RuntimeLabel .NORMALIZE_BOOLEAN )]
0 commit comments