-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/dataflow/internal/process/functions/call/built-in/built-in-library.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { type DataflowProcessorInformation } from '../../../../../processor' | ||
import type { DataflowInformation } from '../../../../../info' | ||
import { processKnownFunctionCall } from '../known-call-handling' | ||
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate' | ||
import type { RFunctionArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call' | ||
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol' | ||
import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id' | ||
import { dataflowLogger } from '../../../../../logger' | ||
import { unpackArgument } from '../argument/unpack-argument' | ||
import type { RString } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string' | ||
import { RType } from '../../../../../../r-bridge/lang-4.x/ast/model/type' | ||
import { wrapArgumentsUnnamed } from '../argument/make-argument' | ||
|
||
|
||
export function processLibrary<OtherInfo>( | ||
name: RSymbol<OtherInfo & ParentInformation>, | ||
args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], | ||
rootId: NodeId, | ||
data: DataflowProcessorInformation<OtherInfo & ParentInformation> | ||
): DataflowInformation { | ||
if(args.length !== 1) { | ||
dataflowLogger.warn(`Currently only one-arg library-likes are allows (for ${name.content}), skipping`) | ||
return processKnownFunctionCall({ name, args, rootId, data }).information | ||
} | ||
const nameToLoad = unpackArgument(args[0]) | ||
if(nameToLoad === undefined || nameToLoad.type !== RType.Symbol) { | ||
dataflowLogger.warn('No library name provided, skipping') | ||
return processKnownFunctionCall({ name, args, rootId, data }).information | ||
} | ||
|
||
// treat as a function call but convert the first argument to a string | ||
const newArg: RString<OtherInfo & ParentInformation> = { | ||
type: RType.String, | ||
info: nameToLoad.info, | ||
lexeme: nameToLoad.lexeme, | ||
location: nameToLoad.location, | ||
content: { | ||
quotes: 'none', | ||
str: nameToLoad.content | ||
} | ||
} | ||
|
||
return processKnownFunctionCall({ name, args: wrapArgumentsUnnamed([newArg], data.completeAst.idMap), rootId, data }).information | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109c97b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"artificial" Benchmark Suite
Retrieve AST from R code
238.58655709090908
ms305.50355490909095
ms0.78
Normalize R AST
31.396694181818184
ms33.04192136363636
ms0.95
Produce dataflow information
57.500119318181824
ms66.58585145454545
ms0.86
Total per-file
1268.435217909091
ms1512.547620909091
ms0.84
Static slicing
1.2457829018017852
ms (1.0300278002694851
)1.3817132831241319
ms (1.27303105869458
)0.90
Reconstruct code
0.39786935534707357
ms (0.21208717073911798
)0.45135141022522257
ms (0.25927254974160097
)0.88
Total per-slice
1.6628788016526317
ms (1.086112033950825
)1.8475447304133532
ms (1.3326721674469058
)0.90
failed to reconstruct/re-parse
0
#0
#1
times hit threshold
0
#0
#1
reduction (characters)
0.797431685913541
#0.7329390759026897
#1.09
reduction (normalized tokens)
0.7740577588998524
#0.7209834969577295
#1.07
This comment was automatically generated by workflow using github-action-benchmark.
109c97b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"social-science" Benchmark Suite
Retrieve AST from R code
238.08479186000002
ms330.55613118
ms0.72
Normalize R AST
32.145331219999996
ms36.10837608
ms0.89
Produce dataflow information
82.76708640000001
ms188.6117503
ms0.44
Total per-file
2698.0098440799998
ms3858.78617088
ms0.70
Static slicing
5.490282685186625
ms (10.19658663160487
)8.763488287471356
ms (15.142795018273485
)0.63
Reconstruct code
0.36974444329004974
ms (0.19980092020192466
)0.6295735167403027
ms (0.28826473087031307
)0.59
Total per-slice
5.869149850496005
ms (10.265754110897918
)9.403718790030862
ms (15.25727767695505
)0.62
failed to reconstruct/re-parse
2
#7
#0.29
times hit threshold
0
#298
#0
reduction (characters)
0.9241844105867956
#0.8935817303062389
#1.03
reduction (normalized tokens)
0.8924953600737399
#0.8531248144961375
#1.05
This comment was automatically generated by workflow using github-action-benchmark.