debug.type_mask_to_string
Defined in module
"debug"from "debug" import type_mask_to_stringConvert type mask to human-readable string
from "debug" import type_mask_to_string, get_function_info_table
function heal(hitPoints: int) { return hitPoints }
let mask = get_function_info_table(heal).argTypeMask[0]
println("type_mask_to_string(mask) =", type_mask_to_string(mask))Output:
type_mask_to_string(mask) = intParameters
mask | int | a bit set of type flags |
Return value
A string such as "int", "int|string", or "any" when every bit is set. Mask 0 (no type allowed) gives the empty string.
Notes
Some names in the output are aliases that already cover more than one bit, such as number for "int or float"; the mask for int|float prints as number, not as int|float.
Example
from "debug" import type_mask_to_string, get_function_info_table
function add(a: int, b: float) { return a + b }
let info = get_function_info_table(add)
println("type_mask_to_string(argTypeMask[0]) =", type_mask_to_string(info.argTypeMask[0]))
println("type_mask_to_string(argTypeMask[1]) =", type_mask_to_string(info.argTypeMask[1]))
// combining int and float collapses to the "number" alias
println("type_mask_to_string(argTypeMask[0] | argTypeMask[1]) =", type_mask_to_string(info.argTypeMask[0] | info.argTypeMask[1]))
println("type_mask_to_string(-1) =", type_mask_to_string(-1)) // every bit set
println("type_mask_to_string(0) =", $"[{type_mask_to_string(0)}]") // no bit setOutput:
type_mask_to_string(argTypeMask[0]) = int
type_mask_to_string(argTypeMask[1]) = float
type_mask_to_string(argTypeMask[0] | argTypeMask[1]) = number
type_mask_to_string(-1) = any
type_mask_to_string(0) = []See also
get_function_info_table | Returns meta information about a function as table |
get_function_decl_string | Returns a function declaration string |
| debug | module index |