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, #location

Constructor Details

This class inherits a constructor from Rubydex::ConstantReference

Instance Method Details

#declarationRubydex::Declaration

Returns the resolved declaration.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'ext/rubydex/reference.c', line 109

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