@@ -31,6 +31,7 @@ import { resolveIdToValue } from '../../../../../eval/resolve/alias-tracking';
3131import type { ReadOnlyFlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context' ;
3232import type { RProjectFile } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-project' ;
3333import { BuiltInProcName } from '../../../../../environments/built-in' ;
34+ import { EdgeType } from '../../../../../graph/edge' ;
3435
3536/**
3637 * Infers working directories based on the given option and reference chain
@@ -210,7 +211,7 @@ export function processSourceCall<OtherInfo>(
210211 result = sourceRequest ( rootId , {
211212 request : 'file' ,
212213 content : f
213- } , data , result , sourcedDeterministicCountingIdGenerator ( ( findCount > 0 ? findCount + '::' : '' ) + f , name . location ) ) ;
214+ } , data , result , true , sourcedDeterministicCountingIdGenerator ( ( findCount > 0 ? findCount + '::' : '' ) + f , name . location ) ) ;
214215 }
215216 return result ;
216217 }
@@ -225,7 +226,7 @@ export function processSourceCall<OtherInfo>(
225226 * Processes a source request with the given dataflow processor information and existing dataflow information
226227 * Otherwise, this can be an {@link RProjectFile} representing a standalone source file
227228 */
228- export function sourceRequest < OtherInfo > ( rootId : NodeId , request : RParseRequest | RProjectFile < OtherInfo & ParentInformation > , data : DataflowProcessorInformation < OtherInfo & ParentInformation > , information : DataflowInformation , getId ?: IdGenerator < NoInfo > ) : DataflowInformation {
229+ export function sourceRequest < OtherInfo > ( rootId : NodeId , request : RParseRequest | RProjectFile < OtherInfo & ParentInformation > , data : DataflowProcessorInformation < OtherInfo & ParentInformation > , information : DataflowInformation , makeMaybe : boolean , getId ?: IdGenerator < NoInfo > ) : DataflowInformation {
229230 // parse, normalize and dataflow the sourced file
230231 let dataflow : DataflowInformation ;
231232 let fst : RProjectFile < OtherInfo & ParentInformation > ;
@@ -276,11 +277,20 @@ export function sourceRequest<OtherInfo>(rootId: NodeId, request: RParseRequest
276277
277278 // take the entry point as well as all the written references, and give them a control dependency to the source call to show that they are conditional
278279 if ( ! String ( rootId ) . startsWith ( 'file-' ) ) {
279- if ( dataflow . graph . hasVertex ( dataflow . entryPoint ) ) {
280- dataflow . graph . addControlDependency ( dataflow . entryPoint , rootId , true ) ;
281- }
282- for ( const out of dataflow . out ) {
283- dataflow . graph . addControlDependency ( out . nodeId , rootId , true ) ;
280+ if ( makeMaybe ) {
281+ if ( dataflow . graph . hasVertex ( dataflow . entryPoint ) ) {
282+ dataflow . graph . addControlDependency ( dataflow . entryPoint , rootId , true ) ;
283+ }
284+ for ( const out of dataflow . out ) {
285+ dataflow . graph . addControlDependency ( out . nodeId , rootId , true ) ;
286+ }
287+ } else {
288+ if ( dataflow . graph . hasVertex ( dataflow . entryPoint ) ) {
289+ dataflow . graph . addEdge ( dataflow . entryPoint , rootId , EdgeType . Reads ) ;
290+ }
291+ for ( const out of dataflow . out ) {
292+ dataflow . graph . addEdge ( out . nodeId , rootId , EdgeType . Reads ) ;
293+ }
284294 }
285295 }
286296
@@ -319,5 +329,5 @@ export function standaloneSourceFile<OtherInfo>(
319329 ...data ,
320330 environment : information . environment ,
321331 referenceChain : [ ...data . referenceChain , file . filePath ]
322- } , information ) ;
332+ } , information , false ) ;
323333}
0 commit comments