Skip to content

Generate a class from the C pattern of passing an pointer around #984

Open
@ddobrev

Description

@ddobrev

We have the FunctionToInstanceMethodPass which converts free functions into class methods. It is only applied manually. However, we can think about a heuristic approach which applies it automatically based on analysis of an entire unit. For example, if the selected language version is C and the first parameter of all functions in a unit take the same opaque pointer and there's one function which takes no parameters but returns this same opaque pointer, we could assume it would be more convenient to generate a class instead of static methods.
Constructing functions could be problematic to detect because there might be more than one or they might take parameters but we could leave those as static.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions