calculateStrSize emits a binding to a size variable for use in templates (for any C calls dependent on object size). The name of the variable is hardcoded in the template, however, meaning we need to rely on external information when reading templates using this code at call sites, for example:
TokC $ calculateStrSize typeEnv env innerType,
....
TokC $ "snprintf(buf, size)",
Here, size is a binding in scope in the template, declared in the return value of calculateStrSize. As a simple starting point we could just parameterize on binding name calculateStrSize typeEnv env innerType "size".
There may be other template helpers to which the same general idea might apply.
calculateStrSizeemits a binding to a size variable for use in templates (for any C calls dependent on object size). The name of the variable is hardcoded in the template, however, meaning we need to rely on external information when reading templates using this code at call sites, for example:Here,
sizeis a binding in scope in the template, declared in the return value ofcalculateStrSize. As a simple starting point we could just parameterize on binding namecalculateStrSize typeEnv env innerType "size".There may be other template helpers to which the same general idea might apply.