Ejemplo n.º 1
0
static char *def_fn(CTX *ctx, struct ir_fn_decl *fn)
{
    if (fn->body && fn->body->parent)
        return def_nested_fn(ctx, fn->body);
    char *m = get_mangle(ctx, fn);
    if (m)
        return m;
    assert(ctx->writing_types);
    m = link_name(ctx, fn->name);
    add_mangle(ctx, fn, m);
    do_fn_types(ctx, fn->type);
    if (!fn->name.visible)
        fprintf(ctx->f, "static ");
    write_fn_type(ctx, fn->type, false, m);
    fprintf(ctx->f, ";\n");
    return m;
}
Ejemplo n.º 2
0
void generate_c(FILE *f, struct ir_unit *unit)
{
    CTX *ctx = talloc_struct(NULL, CTX, { f, 0 });
    ctx->type_mangle = ht_create(ctx, HT_DATA_dptr, HT_DATA_dstr);
    ctx->redef = ht_create(ctx, HT_DATA_dstr, HT_DATA_dempty);
    ctx->tuple_abbrev = ht_create(ctx, HT_DATA_dstr, HT_DATA_dstr);
    ctx->tmp = talloc_new(ctx);
    prelude(ctx);
    struct optimize_settings opt = OPTIMIZE_DEFAULT;
    opt.opt_inline = true;
    unit_optimize(unit, &opt);
    for (int n = 0; n < unit->fn_decls_count; n++) {
        struct ir_fn_decl *fn = unit->fn_decls[n];
        gen_fn(ctx, fn->body, link_name(ctx, fn->name), fn->name.visible);
    }
    talloc_free(ctx);
}
Ejemplo n.º 3
0
void StepLink::output(std::ostream& os) const
{
	os << link_name() << ' ' << m_sourcePoly << ' ' << m_destPoly << ' ' << m_sourceEdge << ' ' << m_destEdge;
}