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

[ruby] Type & Singleton Split #4655

Merged
merged 8 commits into from
Jun 12, 2024

Conversation

DavidBakerEffendi
Copy link
Collaborator

  1. Created classes and modules in pairs, where one is Foo (the "regular" class) and the other is Foo<class> (the singleton class). module singletons get the final keyword.
  2. Define members for @@ fields under Foo<class>
  3. Define members with dynamicTypeHintFullNames set to the corresponding self methods and under Foo<class>. Foo<class> should have empty bindings to these self methods. An empty binding is one with name=="" and signature==""
  4. During object instantiations, e.g. Foo.new, add Foo<class> to the receiver's dynamic type hints, and Foo as the return type of Call(new). The call linker may add an edge directly from Foo.new to Foo.initialize.

cc @AndreiDreyer

Resolves #4652

1. Created classes and modules in pairs, where one is `Foo` (the "regular" class) and the other is `Foo<class>` (the singleton class). `module` singletons get the `final` keyword.
2. Define members for `@@` fields under `Foo<class>`
3. Define members with `dynamicTypeHintFullName`s set to the corresponding `self` methods and under `Foo<class>`. `Foo<class>` should have empty bindings to these `self` methods. An empty binding is one with `name==""` and `signature==""`
4. During object instantiations, e.g. `Foo.new`, add `Foo<class>` to the receiver's dynamic type hints, and `Foo` as the return type of `Call(new)`. The call linker may add an edge directly from `Foo.new` to `Foo.initialize`.

Resolves #4652
@DavidBakerEffendi DavidBakerEffendi added the ruby Relates to rubysrc2cpg label Jun 11, 2024
@DavidBakerEffendi DavidBakerEffendi self-assigned this Jun 11, 2024
@DavidBakerEffendi DavidBakerEffendi merged commit ed9671b into master Jun 12, 2024
5 checks passed
@DavidBakerEffendi DavidBakerEffendi deleted the dave/ruby/class-singleton-split branch June 12, 2024 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ruby Relates to rubysrc2cpg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ruby] Class & Singleton Class Modelling
2 participants