Skip to content

Commit

Permalink
refactor(alias): start with set instead of array (#1106)
Browse files Browse the repository at this point in the history
  • Loading branch information
gigalasr committed Dec 17, 2024
1 parent ad1a4f4 commit 73f5c80
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/dataflow/environments/resolve-by-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function resolveToConstants(name: Identifier | undefined, environment: RE


export function getAliases(sourceIds: readonly NodeId[], dataflow: DataflowGraph, environment: REnvironmentInformation): NodeId[] | undefined {
const definitions: NodeId[] = [];
const definitions: Set<NodeId> = new Set<NodeId>();

for(const sourceId of sourceIds) {
const info = dataflow.getVertex(sourceId);
Expand All @@ -123,7 +123,7 @@ export function getAliases(sourceIds: readonly NodeId[], dataflow: DataflowGraph

if(info.tag === VertexType.Value) {
// Source is constant
definitions.push(sourceId);
definitions.add(sourceId);
} else if(info.tag === VertexType.Use) {

// Source is Symbol -> resolve definitions of symbol
Expand All @@ -144,9 +144,9 @@ export function getAliases(sourceIds: readonly NodeId[], dataflow: DataflowGraph
if(def.value === undefined) {
return undefined;
}
definitions.push(...def.value);
def.value.forEach(v => definitions.add(v));
} else if(def.type === ReferenceType.Constant || def.type === ReferenceType.BuiltInConstant) {
definitions.push(def.nodeId);
definitions.add(def.nodeId);
} else {
return undefined;
}
Expand All @@ -157,7 +157,7 @@ export function getAliases(sourceIds: readonly NodeId[], dataflow: DataflowGraph
}
}

return [...new Set(definitions)];
return definitions.values().toArray();

Check failure on line 160 in src/dataflow/environments/resolve-by-name.ts

View workflow job for this annotation

GitHub Actions / ⚗️ Test Suite (coverage)

test/functionality/benchmark/slicer.test.ts > Benchmark Slicer > Stats by parsing text-based inputs > Slicing the same code three times

TypeError: definitions.values(...).toArray is not a function ❯ Module.getAliases src/dataflow/environments/resolve-by-name.ts:160:30 ❯ processAssignmentToSymbol src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:300:18 ❯ processAssignment src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:102:10 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55 ❯ Module.processNamedCall src/dataflow/internal/process/functions/call/named-call-handling.ts:59:65 ❯ Module.processAsNamedCall src/dataflow/internal/process/process-named-call.ts:16:9 ❯ Object.RBinaryOp src/dataflow/extractor.ts:36:40 ❯ Module.processDataflowFor src/dataflow/processor.ts:72:31 ❯ processExpressionList src/dataflow/internal/process/functions/call/built-in/built-in-expression-list.ts:144:21 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55

Check failure on line 160 in src/dataflow/environments/resolve-by-name.ts

View workflow job for this annotation

GitHub Actions / ⚗️ Test Suite (coverage)

test/functionality/dataflow/graph/cluster.test.ts > Graph Clustering > Code Snippets > imperative > assignment [x <- 3]

TypeError: definitions.values(...).toArray is not a function ❯ Module.getAliases src/dataflow/environments/resolve-by-name.ts:160:30 ❯ processAssignmentToSymbol src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:300:18 ❯ processAssignment src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:102:10 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55 ❯ Module.processNamedCall src/dataflow/internal/process/functions/call/named-call-handling.ts:59:65 ❯ Module.processAsNamedCall src/dataflow/internal/process/process-named-call.ts:16:9 ❯ Object.RBinaryOp src/dataflow/extractor.ts:36:40 ❯ Module.processDataflowFor src/dataflow/processor.ts:72:31 ❯ processExpressionList src/dataflow/internal/process/functions/call/built-in/built-in-expression-list.ts:144:21 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55

Check failure on line 160 in src/dataflow/environments/resolve-by-name.ts

View workflow job for this annotation

GitHub Actions / ⚗️ Test Suite (coverage)

test/functionality/dataflow/graph/cluster.test.ts > Graph Clustering > Code Snippets > imperative > two independent assignments [x <- 3\ny <- 4]

TypeError: definitions.values(...).toArray is not a function ❯ Module.getAliases src/dataflow/environments/resolve-by-name.ts:160:30 ❯ processAssignmentToSymbol src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:300:18 ❯ processAssignment src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:102:10 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55 ❯ Module.processNamedCall src/dataflow/internal/process/functions/call/named-call-handling.ts:59:65 ❯ Module.processAsNamedCall src/dataflow/internal/process/process-named-call.ts:16:9 ❯ Object.RBinaryOp src/dataflow/extractor.ts:36:40 ❯ Module.processDataflowFor src/dataflow/processor.ts:72:31 ❯ processExpressionList src/dataflow/internal/process/functions/call/built-in/built-in-expression-list.ts:144:21 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55

Check failure on line 160 in src/dataflow/environments/resolve-by-name.ts

View workflow job for this annotation

GitHub Actions / ⚗️ Test Suite (coverage)

test/functionality/dataflow/graph/cluster.test.ts > Graph Clustering > Code Snippets > imperative > with a print call [x <- 3\nprint(x)]

TypeError: definitions.values(...).toArray is not a function ❯ Module.getAliases src/dataflow/environments/resolve-by-name.ts:160:30 ❯ processAssignmentToSymbol src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:300:18 ❯ processAssignment src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:102:10 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55 ❯ Module.processNamedCall src/dataflow/internal/process/functions/call/named-call-handling.ts:59:65 ❯ Module.processAsNamedCall src/dataflow/internal/process/process-named-call.ts:16:9 ❯ Object.RBinaryOp src/dataflow/extractor.ts:36:40 ❯ Module.processDataflowFor src/dataflow/processor.ts:72:31 ❯ processExpressionList src/dataflow/internal/process/functions/call/built-in/built-in-expression-list.ts:144:21 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55

Check failure on line 160 in src/dataflow/environments/resolve-by-name.ts

View workflow job for this annotation

GitHub Actions / ⚗️ Test Suite (coverage)

test/functionality/dataflow/graph/cluster.test.ts > Graph Clustering > Code Snippets > imperative > late join of clusters [x <- 3\ny <- 4\nprint(x + y)]

TypeError: definitions.values(...).toArray is not a function ❯ Module.getAliases src/dataflow/environments/resolve-by-name.ts:160:30 ❯ processAssignmentToSymbol src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:300:18 ❯ processAssignment src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:102:10 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55 ❯ Module.processNamedCall src/dataflow/internal/process/functions/call/named-call-handling.ts:59:65 ❯ Module.processAsNamedCall src/dataflow/internal/process/process-named-call.ts:16:9 ❯ Object.RBinaryOp src/dataflow/extractor.ts:36:40 ❯ Module.processDataflowFor src/dataflow/processor.ts:72:31 ❯ processExpressionList src/dataflow/internal/process/functions/call/built-in/built-in-expression-list.ts:144:21 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55

Check failure on line 160 in src/dataflow/environments/resolve-by-name.ts

View workflow job for this annotation

GitHub Actions / ⚗️ Test Suite (coverage)

test/functionality/dataflow/graph/cluster.test.ts > Graph Clustering > Code Snippets > imperative > x join of clusters [x <- 3\ny <- 4\nprint(x + y)\nprint(x)\nprint(y)]

TypeError: definitions.values(...).toArray is not a function ❯ Module.getAliases src/dataflow/environments/resolve-by-name.ts:160:30 ❯ processAssignmentToSymbol src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:300:18 ❯ processAssignment src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:102:10 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55 ❯ Module.processNamedCall src/dataflow/internal/process/functions/call/named-call-handling.ts:59:65 ❯ Module.processAsNamedCall src/dataflow/internal/process/process-named-call.ts:16:9 ❯ Object.RBinaryOp src/dataflow/extractor.ts:36:40 ❯ Module.processDataflowFor src/dataflow/processor.ts:72:31 ❯ processExpressionList src/dataflow/internal/process/functions/call/built-in/built-in-expression-list.ts:144:21 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55

Check failure on line 160 in src/dataflow/environments/resolve-by-name.ts

View workflow job for this annotation

GitHub Actions / ⚗️ Test Suite (coverage)

test/functionality/dataflow/graph/cluster.test.ts > Graph Clustering > Code Snippets > imperative > conditional > linked conditional [x <- 2\n if(runif(k) > j) {\nx <- 3\n} else {\nx <- 4 }\nprint(x)]

TypeError: definitions.values(...).toArray is not a function ❯ Module.getAliases src/dataflow/environments/resolve-by-name.ts:160:30 ❯ processAssignmentToSymbol src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:300:18 ❯ processAssignment src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:102:10 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55 ❯ Module.processNamedCall src/dataflow/internal/process/functions/call/named-call-handling.ts:59:65 ❯ Module.processAsNamedCall src/dataflow/internal/process/process-named-call.ts:16:9 ❯ Object.RBinaryOp src/dataflow/extractor.ts:36:40 ❯ Module.processDataflowFor src/dataflow/processor.ts:72:31 ❯ processExpressionList src/dataflow/internal/process/functions/call/built-in/built-in-expression-list.ts:144:21 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55

Check failure on line 160 in src/dataflow/environments/resolve-by-name.ts

View workflow job for this annotation

GitHub Actions / ⚗️ Test Suite (coverage)

test/functionality/dataflow/graph/cluster.test.ts > Graph Clustering > Code Snippets > inter-procedural > contain call target [y <- 42\nf <- function(x) { x * y }\nf(2)\nf(3)]

TypeError: definitions.values(...).toArray is not a function ❯ Module.getAliases src/dataflow/environments/resolve-by-name.ts:160:30 ❯ processAssignmentToSymbol src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:300:18 ❯ processAssignment src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:102:10 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55 ❯ Module.processNamedCall src/dataflow/internal/process/functions/call/named-call-handling.ts:59:65 ❯ Module.processAsNamedCall src/dataflow/internal/process/process-named-call.ts:16:9 ❯ Object.RBinaryOp src/dataflow/extractor.ts:36:40 ❯ Module.processDataflowFor src/dataflow/processor.ts:72:31 ❯ processExpressionList src/dataflow/internal/process/functions/call/built-in/built-in-expression-list.ts:144:21 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55

Check failure on line 160 in src/dataflow/environments/resolve-by-name.ts

View workflow job for this annotation

GitHub Actions / ⚗️ Test Suite (coverage)

test/functionality/dataflow/graph/cluster.test.ts > Graph Clustering > Code Snippets > inter-procedural > some odd ducklings [y <- 42\nz <- 5\nf <- function(x) { x * y }\nf(2)\nprint(z)\nf(3)\nu]

TypeError: definitions.values(...).toArray is not a function ❯ Module.getAliases src/dataflow/environments/resolve-by-name.ts:160:30 ❯ processAssignmentToSymbol src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:300:18 ❯ processAssignment src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:102:10 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55 ❯ Module.processNamedCall src/dataflow/internal/process/functions/call/named-call-handling.ts:59:65 ❯ Module.processAsNamedCall src/dataflow/internal/process/process-named-call.ts:16:9 ❯ Object.RBinaryOp src/dataflow/extractor.ts:36:40 ❯ Module.processDataflowFor src/dataflow/processor.ts:72:31 ❯ processExpressionList src/dataflow/internal/process/functions/call/built-in/built-in-expression-list.ts:144:21 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55

Check failure on line 160 in src/dataflow/environments/resolve-by-name.ts

View workflow job for this annotation

GitHub Actions / ⚗️ Test Suite (coverage)

test/functionality/dataflow/graph/cluster.test.ts > Graph Clustering > Code Snippets > inter-procedural > uncalled functions [f <- function() 1\nx <- 3]

TypeError: definitions.values(...).toArray is not a function ❯ Module.getAliases src/dataflow/environments/resolve-by-name.ts:160:30 ❯ processAssignmentToSymbol src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:300:18 ❯ processAssignment src/dataflow/internal/process/functions/call/built-in/built-in-assignment.ts:102:10 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55 ❯ Module.processNamedCall src/dataflow/internal/process/functions/call/named-call-handling.ts:59:65 ❯ Module.processAsNamedCall src/dataflow/internal/process/process-named-call.ts:16:9 ❯ Object.RBinaryOp src/dataflow/extractor.ts:36:40 ❯ Module.processDataflowFor src/dataflow/processor.ts:72:31 ❯ processExpressionList src/dataflow/internal/process/functions/call/built-in/built-in-expression-list.ts:144:21 ❯ Object.processor src/dataflow/environments/built-in-config.ts:83:55
}

export function resolveToValues(identifier: Identifier | undefined, environment: REnvironmentInformation, graph: DataflowGraph) {
Expand Down

0 comments on commit 73f5c80

Please sign in to comment.