示例#1
0
static bool analyzer_symbol_table_add_fndecl(struct analyzer_traversal_ctx *ctx,
                                             struct ast_node *n)
{
    struct symbol_table_record *rec;
    const struct RFstring *fn_name;
    fn_name = ast_fndecl_name_str(n);
    rec = symbol_table_lookup_record(ctx->current_st, fn_name, NULL);

    if (rec && type_is_function(rec->data)) {
        analyzer_err(ctx->m, ast_node_startmark(n),
                     ast_node_endmark(n),
                     "Function \""RF_STR_PF_FMT"\" was already declared "
                     "at "INPLOCATION_FMT,
                     RF_STR_PF_ARG(fn_name),
                     INPLOCATION_ARG(
                         module_get_file(ctx->m),
                         ast_node_location(symbol_table_record_node(rec))));
        return false;
    }

    if (!symbol_table_add_node(ctx->current_st, ctx->m, fn_name, n)) {
        RF_ERROR("Could not add a function node to a symbol table");
        return false;
    }

    // function's arguments are added to the symbol table by type creation
    return true;
}
示例#2
0
const struct RFstring *type_callable_category_str(const struct type *t)
{
    RF_ASSERT(type_is_callable(t), "Non callable type detected");
    if (type_is_function(t)) {
        return &s_function_;
    }
    return &s_ctor_;
}
示例#3
0
struct type *type_function_get_rettype(const struct type *t)
{
    RF_ASSERT(type_is_function(t) && darray_size(t->operator.operands) == 2,
              "Non function type detected");
    return darray_item(t->operator.operands, 1);
}
示例#4
0
文件: type.c 项目: tomtix/uuc
const struct type *type_function_return(const struct type *ty)
{
    assert(type_is_function(ty));
    return ty->function_type.return_value;
}
示例#5
0
文件: type.c 项目: tomtix/uuc
const struct list *type_function_argv(const struct type *ty)
{
    assert(type_is_function(ty));
    return ty->function_type.argv;
}
示例#6
0
文件: type.c 项目: tomtix/uuc
int type_function_argc(const struct type *ty)
{
    assert(type_is_function(ty));
    return ty->function_type.argc;
}