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

Chopping and Dicing #925

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/slicing/static/dicer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { DataflowGraph } from '../../dataflow/graph/graph'
import type { NormalizedAst } from '../../r-bridge/lang-4.x/ast/model/processing/decorate'
import type { SlicingCriteria } from '../criterion/parse'
import type { SliceResult } from './slicer-types'
import { staticSlicing } from './static-slicer'



export function staticDicing(graph: DataflowGraph, ast: NormalizedAst, endCriteria: SlicingCriteria, startCriteria: SlicingCriteria, threshold = 75): Readonly<SliceResult> {
const backwardsSlice = staticSlicing(graph, ast, endCriteria, threshold)
const forwardSlice = forwardSlicing(graph, ast, startCriteria, threshold)

return { timesHitThreshold: backwardsSlice.timesHitThreshold, result: backwardsSlice.result.intersection(forwardSlice.result), decodedCriteria: backwardsSlice.decodedCriteria }

Check failure on line 13 in src/slicing/static/dicer.ts

View workflow job for this annotation

GitHub Actions / 👩‍🏫 Linting (local)

Unsafe assignment of an `any` value

Check failure on line 13 in src/slicing/static/dicer.ts

View workflow job for this annotation

GitHub Actions / 👩‍🏫 Linting (local)

Unsafe call of an `any` typed value
}

function forwardSlicing(graph: DataflowGraph, ast: NormalizedAst, criteria: SlicingCriteria, threshold = 75): Readonly<SliceResult> {
return staticSlicing(graph, ast, criteria, threshold)
}
15 changes: 15 additions & 0 deletions test/functionality/slicing/dicing/simple-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { assertSliced, withShell } from '../../_helper/shell'
import type { SlicingCriteria } from '../../../../src/slicing/criterion/parse'

describe.only('Simple', withShell(shell => {
describe('Base Dicing Cases', () => {
const testcases: [{ name: string, input: string, endCriterion: SlicingCriteria, startCriterion: SlicingCriteria, expected: string }]
= [
{ name: 'Simple Example', input: 'a = 3\nb = 4\nc = a + b', endCriterion: ['3@c'], startCriterion: ['1@a'], expected: 'a = 3\nc = a + b' }
]

for(const testcase of testcases) {
assertSliced(testcase.name, shell, testcase.input, testcase.endCriterion, testcase.expected)
}
})
}))
3 changes: 3 additions & 0 deletions test/functionality/slicing/slicing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ describe('Slicing', () => {
describe('Slicing-Criterion', () => {
requireAllTestsInFolder(path.join(__dirname, 'slicing-criterion'))
})
describe('DIcing', () => {
EagleoutIce marked this conversation as resolved.
Show resolved Hide resolved
requireAllTestsInFolder(path.join(__dirname, 'dicing'))
})
})
Loading