Class: Rubydex::MethodReference
- Defined in:
- ext/rubydex/reference.c
Instance Method Summary collapse
-
#document ⇒ Rubydex::Document
Returns the document this method reference belongs to.
- #initialize ⇒ Object constructor
-
#location ⇒ Rubydex::Location
Returns the source location for this method reference.
-
#name ⇒ String
Returns the referenced method name.
-
#receiver ⇒ Rubydex::Declaration?
Returns the resolved declaration for the receiver of the method call.
Constructor Details
#initialize ⇒ Object
Instance Method Details
#document ⇒ Rubydex::Document
Returns the document this method reference belongs to.
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'ext/rubydex/reference.c', line 144
static VALUE rdxr_method_reference_document(VALUE self) {
HandleData *data;
void *graph = rdxi_graph_from_handle(self, &data);
const uint64_t *uri_id = rdx_method_reference_document(graph, data->id);
if (uri_id == NULL) {
rb_raise(rb_eRuntimeError, "Method reference not found");
}
VALUE argv[] = {data->graph_obj, ULL2NUM(*uri_id)};
free_u64(uri_id);
return rb_class_new_instance(2, argv, cDocument);
}
|
#location ⇒ Rubydex::Location
Returns the source location for this method reference.
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'ext/rubydex/reference.c', line 102
static VALUE rdxr_method_reference_location(VALUE self) {
HandleData *data;
void *graph = rdxi_graph_from_handle(self, &data);
Location *loc = rdx_method_reference_location(graph, data->id);
if (loc == NULL) {
rb_raise(rb_eRuntimeError, "Method reference must exist for a valid id");
}
VALUE location = rdxi_build_location_value(loc);
rdx_location_free(loc);
return location;
}
|
#name ⇒ String
Returns the referenced method name.
85 86 87 88 89 90 91 92 93 94 |
# File 'ext/rubydex/reference.c', line 85
static VALUE rdxr_method_reference_name(VALUE self) {
HandleData *data;
void *graph = rdxi_graph_from_handle(self, &data);
const char *name = rdx_method_reference_name(graph, data->id);
if (name == NULL) {
rb_raise(rb_eRuntimeError, "Method reference must exist for a valid id");
}
return rdxi_owned_c_string_to_ruby(name);
}
|
#receiver ⇒ Rubydex::Declaration?
Returns the resolved declaration for the receiver of the method call. Returns nil when the receiver is not a tracked constant or cannot be resolved.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'ext/rubydex/reference.c', line 122
static VALUE rdxr_method_reference_receiver(VALUE self) {
HandleData *data;
void *graph = rdxi_graph_from_handle(self, &data);
const struct CDeclaration *decl = rdx_method_reference_receiver_declaration(graph, data->id);
if (decl == NULL) {
return Qnil;
}
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);
}
|