in sources/cg_c.c [580:673]
static void cg_var_decl(charbuf *output, sem_t sem_type, CSTR base_name, bool_t is_local) {
Contract(is_unitary(sem_type));
Contract(!is_null_type(sem_type));
Contract(cg_main_output);
sem_t core_type = core_type_of(sem_type);
bool_t notnull = is_not_nullable(sem_type);
CHARBUF_OPEN(name);
if (is_out_parameter(sem_type)) {
bprintf(&name, "*_Nonnull ");
}
bprintf(&name, "%s", base_name);
switch (core_type) {
case SEM_TYPE_INTEGER:
if (notnull) {
bprintf(output, "%s %s", rt->cql_int32, name.ptr);
}
else {
bprintf(output, "cql_nullable_int32 %s", name.ptr);
}
break;
case SEM_TYPE_TEXT:
bprintf(output, "%s ", rt->cql_string_ref);
if (!is_local) {
cg_var_nullability_annotation(output, sem_type);
}
bprintf(output, "%s", name.ptr);
if (is_local) {
bprintf(cg_cleanup_output, " %s(%s);\n", rt->cql_string_release, name.ptr);
}
break;
case SEM_TYPE_BLOB:
bprintf(output, "%s ", rt->cql_blob_ref);
if (!is_local) {
cg_var_nullability_annotation(output, sem_type);
}
bprintf(output, "%s", name.ptr);
if (is_local) {
bprintf(cg_cleanup_output, " %s(%s);\n", rt->cql_blob_release, name.ptr);
}
break;
case SEM_TYPE_OBJECT:
bprintf(output, "%s ", rt->cql_object_ref);
if (!is_local) {
cg_var_nullability_annotation(output, sem_type);
}
bprintf(output, "%s", name.ptr);
if (is_local) {
bprintf(cg_cleanup_output, " %s(%s);\n", rt->cql_object_release, name.ptr);
}
break;
case SEM_TYPE_LONG_INTEGER:
if (notnull) {
bprintf(output, "%s %s", rt->cql_int64, name.ptr);
}
else {
bprintf(output, "cql_nullable_int64 %s", name.ptr);
}
break;
case SEM_TYPE_REAL:
if (notnull) {
bprintf(output, "%s %s", rt->cql_double, name.ptr);
}
else {
bprintf(output, "cql_nullable_double %s", name.ptr);
}
break;
case SEM_TYPE_BOOL:
if (notnull) {
bprintf(output, "%s %s", rt->cql_bool, name.ptr);
}
else {
bprintf(output, "cql_nullable_bool %s", name.ptr);
}
break;
}
if (is_local) {
cg_emit_local_init(output, sem_type);
bprintf(output, ";\n");
if (!notnull) {
cg_emit_local_nullable_init(output, name.ptr, sem_type);
}
}
CHARBUF_CLOSE(name);
}