Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overloaded operator support. #3796

Merged
merged 10 commits into from
Mar 19, 2024

Commits on Mar 19, 2024

  1. Overloaded operator support.

    Support is added for all overloaded operator interfaces in the current
    design apart from `Assign`, which is going to require some more work to
    properly handle, given that primitive assignment currently has a special
    implementation for quite a few builtin types.
    
    As we don't have support for generics yet -- in particular, generic
    interfaces -- there is no support for `*With` interfaces, but homogenous
    interfaces such as `Add` are supported instead.
    
    Factor out building of call expressions so that overloaded operators can
    generate calls.
    
    Switch a few places from using specific kinds of NodeId to a general
    NodeId. Because overloaded operators and other things like implicit
    conversions can result in member access and function calls, those
    operations can't require a specific kind of NodeId.
    
    Add import support for associated entities, and fix import support for
    interfaces and symbolic bindings. We now import interfaces in two steps,
    first importing a forward declaration then a definition, just like we do
    for classes. For symbolic bindings, we ensure that each BindSymbolicName
    is imported only once, because its ID is used as its symbolic identity.
    This is necessary because we (only) support operator interfaces that are
    defined in an imported Carbon package for now.
    
    The entire contents of `check/operator.cpp` should probably be
    rethought. In particular, doing a lot of name lookups on each operator
    is likely to be bad for performance. But this gets us to the point where
    overloaded operators are basically working, which seems like a good
    place to iterate from.
    zygoloid committed Mar 19, 2024
    Configuration menu
    Copy the full SHA
    900d010 View commit details
    Browse the repository at this point in the history
  2. Apply suggestions from code review

    Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
    zygoloid and jonmeow authored Mar 19, 2024
    Configuration menu
    Copy the full SHA
    3ee7364 View commit details
    Browse the repository at this point in the history
  3. Apply suggestions from code review

    Co-authored-by: Carbon Infra Bot <carbon-external-infra@google.com>
    zygoloid and CarbonInfraBot authored Mar 19, 2024
    Configuration menu
    Copy the full SHA
    a172817 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    bbe57f5 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    0dd01fa View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    67d30b5 View commit details
    Browse the repository at this point in the history
  7. Comment.

    zygoloid committed Mar 19, 2024
    Configuration menu
    Copy the full SHA
    e98e8ac View commit details
    Browse the repository at this point in the history
  8. Remove unused ID types.

    zygoloid committed Mar 19, 2024
    Configuration menu
    Copy the full SHA
    d2ebc9b View commit details
    Browse the repository at this point in the history
  9. Rename .in -> .tmpl.

    Add TODO to remove script.
    
    Minimize size of generated tests.
    zygoloid committed Mar 19, 2024
    Configuration menu
    Copy the full SHA
    bbab251 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    64bf90d View commit details
    Browse the repository at this point in the history