Opened 4 years ago

#188 new enhancement

Aliasing C names with Cforall Names

Reported by: ajbeach Owned by:
Priority: minor Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description

There was discussion of adding an aliasing feature that would allow you to create a CFA name that aliases a C name, having no other definition. These would likely have to be visible but might be able to be implemented entirely as part of code generation, possibly even as a special mangled name.

This could be used on variable (two variables of the same time), but its main purpose is to alias functions (which should allow reference<->pointer conversions).

Use cases include aliasing multiple C types with the same name to take advantage of overloading (syntax is just something I came up with in the moment, it could change):

extern "C" {
int operation_int(int, int);
char operation_char(char, char);
}
valuedef int operation(int, int) = operation_int;
valuedef char operation(char, char) = operation_char;

Turning some operations into operators:

void append_data(struct Data *, const struct Data *);

valuedef void ?+=?(struct Data &, const struct Data &);

Turning initialization and clean-up into constructors and destructors (this one might have to be used carefully otherwise the operations could be inserted in the wrong place):

void init_Data(struct Data *, void *, size_t);
void cleanup_Data(struct Data *);

valuedef ?{}(struct Data &, void *, size_t) = init_Data;
valuedef ^?{}(struct Data &);

Internally we could also use it for mangled C names:

struct __cfadbg_state __cfadbg_current_state;

valuedef __cfadbg_state current_debug_state = __cfadbg_current_state;

It could probably alias CFA names to CFA names as well, although perhaps that use should be discouraged. At least I cannot think of as many use cases for it.

Change History (0)

Note: See TracTickets for help on using tickets.