Class: Rubydex::ConstantAlias

Inherits:
Declaration show all
Includes:
Visibility
Defined in:
lib/rubydex/declaration.rb,
ext/rubydex/declaration.c

Instance Method Summary collapse

Methods included from Visibility

#private?, #protected?, #public?

Methods inherited from Declaration

#definitions, #initialize, #name, #owner, #unqualified_name

Constructor Details

This class inherits a constructor from Rubydex::Declaration

Instance Method Details

#referencesObject

Returns an enumerator that yields constant references to this declaration



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'ext/rubydex/declaration.c', line 339

static VALUE rdxr_constant_declaration_references(VALUE self) {
    if (!rb_block_given_p()) {
        return rb_enumeratorize_with_size(self, rb_str_new2("references"), 0, NULL,
                                          constant_declaration_references_size);
    }

    HandleData *data;
    TypedData_Get_Struct(self, HandleData, &handle_type, data);

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

    void *iter = rdx_declaration_constant_references_iter_new(graph, data->id);
    if (iter == NULL) {
        rb_raise(rb_eRuntimeError, "Declaration not found");
    }

    VALUE args = rb_ary_new_from_args(2, data->graph_obj, ULL2NUM((uintptr_t)iter));
    rb_ensure(rdxi_constant_references_yield, args, rdxi_constant_references_ensure, args);

    return self;
}

#targetObject

a target



445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'ext/rubydex/declaration.c', line 445

static VALUE rdxr_constant_alias_target(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 CDeclaration *decl = rdx_constant_alias_target(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);
}

#visibilityObject

Declaration#visibility -> Symbol



424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# File 'ext/rubydex/declaration.c', line 424

static VALUE rdxr_declaration_visibility(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 CVisibility *visibility = rdx_graph_visibility(graph, data->id);
    if (visibility == NULL) {
        rb_raise(rb_eRuntimeError, "declaration has no visibility");
    }

    VALUE symbol = rdxi_visibility_to_symbol(*visibility);
    free_c_visibility(visibility);

    return symbol;
}