Skip to content

Make calculateStrSize behavior more obvious at call site #1474

@scolsen

Description

@scolsen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions