Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ syntest/
*.md
LICENSE*
Dockerfile
NOTICE

# The instrumentation files are copied from istanbul (and modified).
# In the future in a big refactor the instrumentation should be redone such that these files dont have to be ignored anymore.
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ dist
.vscode-test

### Syntest Javascript ###
!packages/cfg-javascript/lib

# End of https://www.toptal.com/developers/gitignore/api/node

Expand Down
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"type": "git",
"url": "git+https://github.com/syntest-framework/syntest-javascript.git"
},
"bin": {
"syntest-javascript": "./packages/javascript/dist/bin.js"
},
"scripts": {
"lint-staged": "lint-staged",
"build": "lerna run build",
Expand Down
5 changes: 5 additions & 0 deletions packages/cfg-javascript/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SynTest Javascript
Copyright 2020-2023 Delft University of Technology and SynTest contributors

This product includes software developed at
Delft University of Technology (http://www.tudelft.nl/).
1 change: 1 addition & 0 deletions packages/cfg-javascript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Control Flow Graph library for JavaScript
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ export class CFGGenerator {
/**
* Generate function map for specified target.
*
* @param targetPath The path of the AST
* @param targetAST The AST of the target
*/
generate(targetPath: string, targetAST: t.Node): CFG {
const visitor = new ControlFlowGraphVisitor(targetPath);
generate(targetAST: t.Node): CFG {
const visitor = new ControlFlowGraphVisitor();
traverse(targetAST, visitor);

return visitor.cfg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* limitations under the License.
*/

import { Visitor } from "../Visitor";
import {
BranchNode,
CFG,
Expand All @@ -27,7 +26,7 @@ import {
RootNode,
} from "@syntest/cfg-core";

export class ControlFlowGraphVisitor extends Visitor {
export class ControlFlowGraphVisitor {
private _cfg: CFG;

// private _nodeStack: Node[][]
Expand All @@ -42,8 +41,7 @@ export class ControlFlowGraphVisitor extends Visitor {

private _nodeStack: Node[];

constructor(filePath: string) {
super(filePath);
constructor() {
this._cfg = new CFG();

this._trackingLeaves = [];
Expand Down
21 changes: 21 additions & 0 deletions packages/cfg-javascript/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2020-2023 Delft University of Technology and SynTest contributors
*
* This file is part of SynTest Framework - SynTest Javascript.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export * from "./CFGGenerator";
export * from "./ControlFlowGraphGenerator";
export * from "./ControlFlowGraphVisitor";
9 changes: 9 additions & 0 deletions packages/cfg-javascript/lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../../tsconfig-base.json",
"compilerOptions": {
"outDir": "../dist",
"rootDir": ".",
"composite": true
},
"include": ["**/*.ts"]
}
34 changes: 34 additions & 0 deletions packages/cfg-javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions packages/cfg-javascript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "@syntest/cfg-javascript",
"version": "0.0.1",
"description": "SynTest CFG JavaScript is a library for generating control flow graphs for the JavaScript language",
"keywords": [
"syntest",
"control-flow-graph"
],
"homepage": "https://www.syntest.org",
"bugs": {
"url": "https://github.com/syntest-framework/syntest-javascript/issues"
},
"license": "Apache-2.0",
"contributors": [
"Annibale Panichella",
"Mitchell Olsthoorn",
"Dimitri Stallenberg"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"/dist",
"/NOTICE",
"README.md"
],
"repository": {
"type": "git",
"url": "git+https://github.com/syntest-framework/syntest-javascript.git"
},
"scripts": {
"build": "tsc --build",
"build:watch": "tsc --build --watch",
"clean": "rm -rf .nyc_output dist node_modules",
"clean:dist": "rm -rf dist",
"format": "prettier --config ../../.prettierrc.json --ignore-path ../../.prettierignore --write .",
"format:check": "prettier --config ../../.prettierrc.json --ignore-path ../../.prettierignore --check .",
"lint": "eslint --config ../../.eslintrc.json --ignore-path ../../.eslintignore .",
"lint:fix": "eslint --config ../../.eslintrc.json --ignore-path ../../.eslintignore . --fix",
"test": "mocha --config ../../.mocharc.json",
"test:coverage": "nyc --reporter=text --reporter=html mocha --config ../../.mocharc.json",
"test:coverage:ci": "nyc --reporter=lcovonly mocha --config ../../.mocharc.json --reporter json --reporter-option output=test-results.json",
"test:watch": "mocha --config ../../.mocharc.json --watch"
},
"dependencies": {
"@syntest/cfg-core": "^0.2.1-beta.0"
},
"engines": {
"node": ">=10.24.0"
},
"publishConfig": {
"access": "public"
}
}
6 changes: 6 additions & 0 deletions packages/cfg-javascript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../tsconfig-base.json",
"files": [],
"include": [],
"references": [{ "path": "lib/" }]
}
2 changes: 1 addition & 1 deletion packages/javascript/lib/JavaScriptLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import {
} from "./utils/collection";
import Messages from "./ui/Messages";
import { JavaScriptCommandLineInterface } from "./ui/JavaScriptCommandLineInterface";
import { ControlFlowGraphGenerator } from "./analysis/static/cfg/ControlFlowGraphGenerator";
import { ControlFlowGraphGenerator } from "@syntest/cfg-javascript";
import { ImportGenerator } from "./analysis/static/dependency/ImportGenerator";
import { ExportGenerator } from "./analysis/static/dependency/ExportGenerator";
import { Export } from "./analysis/static/dependency/ExportVisitor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
TargetPool,
} from "@syntest/core";
import { TargetMapGenerator } from "./map/TargetMapGenerator";
import { ControlFlowGraphGenerator } from "./cfg/ControlFlowGraphGenerator";
import { ControlFlowGraphGenerator } from "@syntest/cfg-javascript";
import { ImportGenerator } from "./dependency/ImportGenerator";
import { ExportGenerator } from "./dependency/ExportGenerator";
import { existsSync, lstatSync } from "fs";
Expand Down
7 changes: 4 additions & 3 deletions packages/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
"/dist",
"/NOTICE"
],
"bin": {
"syntest-javascript": "dist/bin.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/syntest-framework/syntest-javascript.git"
},
"bin": {
"syntest-javascript": "/dist/bin.js"
},
"scripts": {
"build": "tsc --build",
"build:watch": "tsc --build --watch",
Expand All @@ -49,6 +49,7 @@
"@babel/register": "7.18.9",
"@istanbuljs/schema": "0.1.3",
"@syntest/core": "^0.3.1-beta.0",
"@syntest/cfg-javascript": "*",
"chai": "4.3.7",
"chai-as-promised": "7.1.1",
"chalk": "4.1.1",
Expand Down