Consider:
library(ggplot2)
ggplot()
I want a reads | calls edge from ggplot to the ggplot2 library if we know that ggplot2 exports the ggplot function. Additionally, I want to add the information to ggplot, that it comes from the ggplot2 package.
So in other words, we want to link calls from package functions to the package that provides them.
This information is provided by the dependencies context.
Please note: Right now, flowR does not have dependencies for packages loaded (this is the step after this one with which we include the results from crawlR) so whenever you want to test this, you have to tell flowR what every package is exporting (but just for the tests, for this you can have a look at the namespace file tests which we already have.
It should mainly work like this: in the built-in-library handler:
|
export function processLibrary<OtherInfo>( |
|
name: RSymbol<OtherInfo & ParentInformation>, |
|
args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], |
|
rootId: NodeId, |
|
data: DataflowProcessorInformation<OtherInfo & ParentInformation> |
|
): DataflowInformation { |
|
/* we do not really know what loading the library does and what side effects it causes, hence we mark it as an unknown side effect */ |
I want access knowledge that we have about this package (with the dependencies context of the flowr analyzer context). Similar to assignments
|
information.environment = define(nodeToDefine, assignmentConfig?.superAssignment, information.environment); |
this should add the exported variables to the current environment. In other words, if we know ggplot2 exports ggplot, the built-in library handler with library(ggplot2) should assign ggplot to point to the package (i.e., add an according Identifier Definition). Then, every variable use of ggplot etc. should link to this definition (you can set definedAt to built-in:ggplot when defining it in the environment).
Consider:
library(ggplot2) ggplot()I want a
reads | callsedge fromggplotto theggplot2library if we know thatggplot2exports theggplotfunction. Additionally, I want to add the information toggplot, that it comes from theggplot2package.So in other words, we want to link calls from package functions to the package that provides them.
This information is provided by the dependencies context.
Please note: Right now, flowR does not have dependencies for packages loaded (this is the step after this one with which we include the results from crawlR) so whenever you want to test this, you have to tell flowR what every package is exporting (but just for the tests, for this you can have a look at the namespace file tests which we already have.
It should mainly work like this: in the built-in-library handler:
flowr/src/dataflow/internal/process/functions/call/built-in/built-in-library.ts
Lines 19 to 25 in 613d91f
I want access knowledge that we have about this package (with the dependencies context of the flowr analyzer context). Similar to
assignmentsflowr/src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts
Line 410 in 613d91f
this should add the exported variables to the current environment. In other words, if we know
ggplot2exportsggplot, the built-in library handler withlibrary(ggplot2)should assignggplotto point to the package (i.e., add an according Identifier Definition). Then, every variable use ofggplotetc. should link to this definition (you can setdefinedAttobuilt-in:ggplotwhen defining it in the environment).