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

Added support for atomic vectors #1245

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

Slartibartfass2
Copy link
Collaborator

Closes #1142

@Slartibartfass2 Slartibartfass2 self-assigned this Jan 17, 2025
@Slartibartfass2 Slartibartfass2 force-pushed the 1142-add-support-for-atomic-vectors-field-sensitive-pointer-analysis branch 3 times, most recently from e0f55e2 to 199b3f0 Compare January 21, 2025 15:29
@Slartibartfass2 Slartibartfass2 force-pushed the 1142-add-support-for-atomic-vectors-field-sensitive-pointer-analysis branch 2 times, most recently from fff8984 to 09fcff2 Compare January 25, 2025 15:38
This reduces the indentation of the whole pointer analysis block
and the argument filtering before can be excluded too.
This was previously added but shouldn't be.
While lexemes are great to destinguish indices from named arguments in lists, for vectors we need to also store the index.
Furthermore, this is important for index based access on lists or vectors.
Index information for named arguments will be added separately.
These will be required later for the index based access on lists.
For an expression `c(1, 2, c(3, 4))` the nested vector would be flattened so that it equals `c(1, 2, 3, 4)`.
For this to work, we need to fetch the indices for the nested vector and add them to the existing indices.
In a case where there are values after a nested index we need to rewrite the indices so that they are in correct order.
E.g. for `c(1, c(2, 3), 4)` the argument with value '4' has initially the index 3, after it has been flattened,
it has to be 4. This is done by merging both lists with new indices similar to the merging part of MergeSort.
With this test suite we can test whether the indices of a vector are defined correctly.
Previously we only could check this by accessing the indices and testing the reads edges.
This eliminates this step and lets us test this unit separately.
Previously only numbers were recognized as values for a vector definition.
Now we can use the same method for the index based access, which works in the same way.
- removed 'dataflow' prefix, because the tests are in the `test/functionality/dataflow` directory, which makes the prefix obsolete
- added the type of access to the test files: list-access -> list-name-based-access to differentiate other types of access
On the way down, we don't have all information e.g. about nested containers, which makes it inevitable to resolve them on the way up.
Previously, for a vector definition nested containers were handled on the way up, while primitves were handled on the way down.
This lead to a rather complex merging logic. Handling now everything on the way up let's us iterate the arguments once and define the
indices for the container at the same time. While adding the resolving of unnamed list arguments, I changed this too for list definitions.
These functions are now used for all container logic.
This enabled the pointer analysis for assignments like the following:
```r
a <- c(1, 2)
a[[1]] <- 3
a[2] <- 4
```

This does not include access with a variable or a range or anything that accessed more than one index.
This way, we can test the same behavior for vectors and lists (with named and unnamed arguments).
This enables it e.g. to query the second access operation in the same line, which was previously
only possible using the line:column format.
This enables passing the indices of one container to another.
Example:
```r
a <- c(1, 2)
b <- a # indices [1, 2] are passed to b
print(b) # definition of a is also in slice
```
@Slartibartfass2 Slartibartfass2 force-pushed the 1142-add-support-for-atomic-vectors-field-sensitive-pointer-analysis branch from bbe8c41 to b4f8b0a Compare January 25, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for atomic vectors (field-sensitive pointer analysis)
1 participant