Class: Rubydex::ResolvedConstantReference

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

Instance Method Summary collapse

Methods inherited from ConstantReference

#document, #initialize, #location

Methods inherited from Reference

#initialize, #location

Constructor Details

This class inherits a constructor from Rubydex::ConstantReference

Instance Method Details

#declarationRubydex::Declaration

Returns the resolved declaration.



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'ext/rubydex/reference.c', line 165

static VALUE rdxr_resolved_constant_reference_declaration(VALUE self) {
    HandleData *data;
    void *graph = rdxi_graph_from_handle(self, &data);

    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);
}