Class: Rubydex::ResolvedConstantReference

Inherits:
ConstantReference show all
Defined in:
ext/rubydex/reference.c

Instance Method Summary collapse

Methods inherited from ConstantReference

#initialize, #location

Methods inherited from Reference

#initialize

Constructor Details

This class inherits a constructor from Rubydex::ConstantReference

Instance Method Details

#declarationObject

ResolvedConstantReference#declaration -> Declaration



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'ext/rubydex/reference.c', line 79

static VALUE rdxr_resolved_constant_reference_declaration(VALUE self) {
    HandleData *data;
    TypedData_Get_Struct(self, HandleData, &handle_type, data);

    void *graph;
    TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);

    const struct CDeclaration *decl = rdx_resolved_constant_reference_declaration(graph, data->id);
    if (decl == NULL) {
        rb_raise(rb_eRuntimeError, "Invalid declaration for a resolved constant reference");
    }

    VALUE decl_class = rdxi_declaration_class_for_kind(decl->kind);
    VALUE argv[] = {data->graph_obj, ULL2NUM(decl->id)};
    free_c_declaration(decl);

    return rb_class_new_instance(2, argv, decl_class);
}