From d2dc42bf12988a6518cedd0cca3a3d9e895a06ab Mon Sep 17 00:00:00 2001 From: Tamir Bahar Date: Sat, 21 Sep 2024 09:50:48 +0300 Subject: [PATCH] Removed unused files and updated readmes --- .npmrc | 1 - .vscode/extensions.json | 5 +- src/demo/README.md | 12 +- src/frontend/README.md | 13 +- src/frontend/src/assets/sample1.go | 209 ------------------ .../src/assets/samples/aaSwitchTesting.go | 10 - .../assets/samples/anotherLabelTestCase.go | 17 -- .../src/assets/samples/binary-in-loop.go | 14 -- .../src/assets/samples/breakcontinue.go | 9 - src/frontend/src/assets/samples/cstyleFor.go | 5 - .../src/assets/samples/endlessbreak.go | 5 - .../src/assets/samples/endlessloop.go | 4 - src/frontend/src/assets/samples/goto.go | 9 - src/frontend/src/assets/samples/if.go | 6 - .../src/assets/samples/labeledStatement.go | 5 - src/frontend/src/assets/samples/naive.go | 3 - src/frontend/src/assets/samples/rangefor.go | 5 - src/frontend/src/assets/samples/return.go | 6 - src/frontend/src/assets/samples/switch.go | 15 -- src/frontend/src/assets/samples/trimspace.go | 35 --- src/frontend/src/assets/samples/typeSwitch.go | 10 - vsc-extension-quickstart.md | 46 ---- 22 files changed, 11 insertions(+), 433 deletions(-) delete mode 100644 .npmrc delete mode 100644 src/frontend/src/assets/sample1.go delete mode 100644 src/frontend/src/assets/samples/aaSwitchTesting.go delete mode 100644 src/frontend/src/assets/samples/anotherLabelTestCase.go delete mode 100644 src/frontend/src/assets/samples/binary-in-loop.go delete mode 100644 src/frontend/src/assets/samples/breakcontinue.go delete mode 100644 src/frontend/src/assets/samples/cstyleFor.go delete mode 100644 src/frontend/src/assets/samples/endlessbreak.go delete mode 100644 src/frontend/src/assets/samples/endlessloop.go delete mode 100644 src/frontend/src/assets/samples/goto.go delete mode 100644 src/frontend/src/assets/samples/if.go delete mode 100644 src/frontend/src/assets/samples/labeledStatement.go delete mode 100644 src/frontend/src/assets/samples/naive.go delete mode 100644 src/frontend/src/assets/samples/rangefor.go delete mode 100644 src/frontend/src/assets/samples/return.go delete mode 100644 src/frontend/src/assets/samples/switch.go delete mode 100644 src/frontend/src/assets/samples/trimspace.go delete mode 100644 src/frontend/src/assets/samples/typeSwitch.go delete mode 100644 vsc-extension-quickstart.md diff --git a/.npmrc b/.npmrc deleted file mode 100644 index 37d1b60..0000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -enable-pre-post-scripts = true \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json index e08c0ec..0179e45 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,6 +4,7 @@ "recommendations": [ "dbaeumer.vscode-eslint", "connor4312.esbuild-problem-matchers", - "ms-vscode.extension-test-runner" + "ms-vscode.extension-test-runner", + "oven.bun-vscode" ] -} +} \ No newline at end of file diff --git a/src/demo/README.md b/src/demo/README.md index 723fab7..44ca1e6 100644 --- a/src/demo/README.md +++ b/src/demo/README.md @@ -1,11 +1,7 @@ -# CFG Web View +# Function-Graph-Overview Demo -This is a tool meant to help debugging the CFG generation and presentation. +This is the interactive web demo. -Use `bun run web` to run it. +To run it, run `bun demo`. -Add more samples under `./src/assets/samples/` to see them in the web view. - -## TODO - -- [ ] Find a better way to serve the `.wasm` files rather than sticking them in the `public` dir. +To build it, `bun build-demo`. diff --git a/src/frontend/README.md b/src/frontend/README.md index 723fab7..2ea4ce7 100644 --- a/src/frontend/README.md +++ b/src/frontend/README.md @@ -1,11 +1,6 @@ -# CFG Web View +# Test Viewer -This is a tool meant to help debugging the CFG generation and presentation. +This is the test viewer, meant to make testing easier. -Use `bun run web` to run it. - -Add more samples under `./src/assets/samples/` to see them in the web view. - -## TODO - -- [ ] Find a better way to serve the `.wasm` files rather than sticking them in the `public` dir. +To run it, run `bun web-tests` to generate test data, (or use `--watch` to run continiously), +then run `bun web` to start the server. diff --git a/src/frontend/src/assets/sample1.go b/src/frontend/src/assets/sample1.go deleted file mode 100644 index 6e1f660..0000000 --- a/src/frontend/src/assets/sample1.go +++ /dev/null @@ -1,209 +0,0 @@ -package WhoCares - -// func blocksToDot(function *ssa.Function) ([]byte, error) { -// functionGraph := simple.NewDirectedGraph() - -// for _, block := range function.Blocks { -// functionGraph.AddNode(&Node{index: block.Index, function: function}) -// } - -// for _, block := range function.Blocks { -// for _, succ := range block.Succs { -// // gonum.graph.simple does not support self-links, so we hack around it... -// if block.Index == succ.Index { -// functionGraph.Node(int64(block.Index)).(*Node).hasSelfEdge = true -// } else { -// functionGraph.SetEdge(Edge{ -// from: block.Index, -// to: succ.Index, -// function: function, -// }) -// } -// } -// } - -// dotGraph, err := dot.Marshal(functionGraph, function.Name(), "", " ") -// dotGraph = bytes.Replace(dotGraph, []byte("\\n"), []byte("\\l"), -1) -// return dotGraph, err -// } - -// func ifMerge() { -// if x { - -// } else if y { -// } else {} -// } - -// // File: demo/demo.go -// func Demo(flag bool, n int) { -// if flag { -// fmt.Println("Hello, World!") -// } -// fmt.Println("Oh no!") - -// for _, x := range "Hello, World!" { -// fmt.Println(x) -// } - -// if flag { -// fmt.Println("A") -// } else if n == 3 { -// fmt.Println("B") -// } else if n == 2 { -// fmt.Println("C") -// } else { -// fmt.Println("D") -// } - -// switch n { -// case 1: -// return -// case 2: -// return -// case 3: -// return -// } -// fmt.Println("Yo") -// } - -// func ret() { -// if a { -// return; -// } -// return; -// } - -// func Switch() { -// switch n { -// case 1: -// x = 1 -// y = 2 -// return -// case 2: -// x = 2 -// case 3: -// f() -// default: -// a = 1 -// } -// return -// } - -// func endlessLoop() { -// for { - -// } -// } - -// func endlessBreak() { -// for { -// break -// } -// } - -// func endlessContinue() { -// for { -// continue -// } -// } - -// func ifBreakContinue() { -// for { -// if x { -// break; -// } else { -// continue; -// } -// } -// } - -func switchStatement() { - switch x { - case 1: - break; - case 2: - print() - case 3: - return - case 4: - x = 1; - break; - default: - print() - } -} - -// func hasGoto() { -// if x { -// goto myCoolLabel -// } -// return -// myCoolLabel: -// x = 2 -// return -// } - -// func typeSwitch() { -// switch val.(type) { -// case int: -// f(); -// case float: -// f(); -// default: -// f(); -// } -// } - -// func isCallTo(target callTarget, node ast.Node, typesInfo *types.Info) bool { -// _, isCall := node.(*ast.CallExpr) -// if !isCall { -// return false -// } - -// for { -// switch current := node.(type) { -// case *ast.CallExpr: -// node = current.Fun -// case *ast.SelectorExpr: -// node = current.Sel -// case *ast.Ident: -// definition, exists := typesInfo.Uses[current] -// if !exists { -// return false -// } - -// funcDef, isFunc := definition.(*types.Func) -// if !isFunc { -// return false -// } - -// if funcDef.Pkg() == nil { -// return false -// } -// if funcDef.Pkg().Path() == target.PkgPath && funcDef.Name() == target.Name { -// return true -// } -// return false -// default: -// return false -// } -// } -// } - -// func (bla bla) method() { -// return -// } - - -// var x = func() {return;} - - -// func hasSelect() { -// select { -// case c <- x: -// f() -// case <-quit: -// return -// } -// f() -// } \ No newline at end of file diff --git a/src/frontend/src/assets/samples/aaSwitchTesting.go b/src/frontend/src/assets/samples/aaSwitchTesting.go deleted file mode 100644 index 92b7a40..0000000 --- a/src/frontend/src/assets/samples/aaSwitchTesting.go +++ /dev/null @@ -1,10 +0,0 @@ -func basicSwitchTest() { - switch x { - // Who cares? - case 1: - // CFG: a - fallthrough - case 2: - case 3: - } -} \ No newline at end of file diff --git a/src/frontend/src/assets/samples/anotherLabelTestCase.go b/src/frontend/src/assets/samples/anotherLabelTestCase.go deleted file mode 100644 index 04ef816..0000000 --- a/src/frontend/src/assets/samples/anotherLabelTestCase.go +++ /dev/null @@ -1,17 +0,0 @@ -func anotherLabelTest() { - switch x { - case 1: - case 2: - goto label - case 3: - case 4: - } - return - -label: - if x { - f() - } else { - g() - } -} diff --git a/src/frontend/src/assets/samples/binary-in-loop.go b/src/frontend/src/assets/samples/binary-in-loop.go deleted file mode 100644 index 72a20e1..0000000 --- a/src/frontend/src/assets/samples/binary-in-loop.go +++ /dev/null @@ -1,14 +0,0 @@ - -func trimRightUnicode(s, cutset string) string { - for len(s) > 0 { - r, n := rune(s[len(s)-1]), 1 - if r >= utf8.RuneSelf { - r, n = utf8.DecodeLastRuneInString(s) - } - if !ContainsRune(cutset, r) { - break - } - s = s[:len(s)-n] - } - return s -} \ No newline at end of file diff --git a/src/frontend/src/assets/samples/breakcontinue.go b/src/frontend/src/assets/samples/breakcontinue.go deleted file mode 100644 index dcf6894..0000000 --- a/src/frontend/src/assets/samples/breakcontinue.go +++ /dev/null @@ -1,9 +0,0 @@ -func ifBreakContinue() { - for { - if x { - break; - } else { - continue; - } - } -} \ No newline at end of file diff --git a/src/frontend/src/assets/samples/cstyleFor.go b/src/frontend/src/assets/samples/cstyleFor.go deleted file mode 100644 index 5288389..0000000 --- a/src/frontend/src/assets/samples/cstyleFor.go +++ /dev/null @@ -1,5 +0,0 @@ -func CStyleFor() { - for i := 0; i < 10; i++ { - f() - } -} \ No newline at end of file diff --git a/src/frontend/src/assets/samples/endlessbreak.go b/src/frontend/src/assets/samples/endlessbreak.go deleted file mode 100644 index 3a85279..0000000 --- a/src/frontend/src/assets/samples/endlessbreak.go +++ /dev/null @@ -1,5 +0,0 @@ -func endlessBreak() { - for { - break - } -} \ No newline at end of file diff --git a/src/frontend/src/assets/samples/endlessloop.go b/src/frontend/src/assets/samples/endlessloop.go deleted file mode 100644 index 7999967..0000000 --- a/src/frontend/src/assets/samples/endlessloop.go +++ /dev/null @@ -1,4 +0,0 @@ -func endlessLoop() { - for { - } -} \ No newline at end of file diff --git a/src/frontend/src/assets/samples/goto.go b/src/frontend/src/assets/samples/goto.go deleted file mode 100644 index bd190b3..0000000 --- a/src/frontend/src/assets/samples/goto.go +++ /dev/null @@ -1,9 +0,0 @@ -func hasGoto() { - if x { - goto myCoolLabel - } - return -myCoolLabel: - x = 2 - return -} \ No newline at end of file diff --git a/src/frontend/src/assets/samples/if.go b/src/frontend/src/assets/samples/if.go deleted file mode 100644 index ffa96be..0000000 --- a/src/frontend/src/assets/samples/if.go +++ /dev/null @@ -1,6 +0,0 @@ -func ifMerge() { - if x { - } else if y { - } else { - } -} \ No newline at end of file diff --git a/src/frontend/src/assets/samples/labeledStatement.go b/src/frontend/src/assets/samples/labeledStatement.go deleted file mode 100644 index 5fbd5f4..0000000 --- a/src/frontend/src/assets/samples/labeledStatement.go +++ /dev/null @@ -1,5 +0,0 @@ -func labeledStatement() { -label: - if x { - } -} \ No newline at end of file diff --git a/src/frontend/src/assets/samples/naive.go b/src/frontend/src/assets/samples/naive.go deleted file mode 100644 index cfbe6fd..0000000 --- a/src/frontend/src/assets/samples/naive.go +++ /dev/null @@ -1,3 +0,0 @@ -func f() { - -} diff --git a/src/frontend/src/assets/samples/rangefor.go b/src/frontend/src/assets/samples/rangefor.go deleted file mode 100644 index 722755d..0000000 --- a/src/frontend/src/assets/samples/rangefor.go +++ /dev/null @@ -1,5 +0,0 @@ -func rangeFor() { - for index, value := range thing { - f() - } -} \ No newline at end of file diff --git a/src/frontend/src/assets/samples/return.go b/src/frontend/src/assets/samples/return.go deleted file mode 100644 index 9d4d954..0000000 --- a/src/frontend/src/assets/samples/return.go +++ /dev/null @@ -1,6 +0,0 @@ -func ret() { - if a { - return; - } - return; -} \ No newline at end of file diff --git a/src/frontend/src/assets/samples/switch.go b/src/frontend/src/assets/samples/switch.go deleted file mode 100644 index 93c186e..0000000 --- a/src/frontend/src/assets/samples/switch.go +++ /dev/null @@ -1,15 +0,0 @@ -func switchStatement() { - switch x { - case 1: - break; - case 2: - print() - case 3: - return - case 4: - x = 1; - break; - default: - print() - } -} \ No newline at end of file diff --git a/src/frontend/src/assets/samples/trimspace.go b/src/frontend/src/assets/samples/trimspace.go deleted file mode 100644 index 3ddab2e..0000000 --- a/src/frontend/src/assets/samples/trimspace.go +++ /dev/null @@ -1,35 +0,0 @@ -// TrimSpace returns a slice of the string s, with all leading -// and trailing white space removed, as defined by Unicode. -func TrimSpace(s string) string { - // Fast path for ASCII: look for the first ASCII non-space byte - start := 0 - for ; start < len(s); start++ { - c := s[start] - if c >= utf8.RuneSelf { - // If we run into a non-ASCII byte, fall back to the - // slower unicode-aware method on the remaining bytes - return TrimFunc(s[start:], unicode.IsSpace) - } - if asciiSpace[c] == 0 { - break - } - } - - // Now look for the first ASCII non-space byte from the end - stop := len(s) - for ; stop > start; stop-- { - c := s[stop-1] - if c >= utf8.RuneSelf { - // start has been already trimmed above, should trim end only - return TrimRightFunc(s[start:stop], unicode.IsSpace) - } - if asciiSpace[c] == 0 { - break - } - } - - // At this point s[start:stop] starts and ends with an ASCII - // non-space bytes, so we're done. Non-ASCII cases have already - // been handled above. - return s[start:stop] -} \ No newline at end of file diff --git a/src/frontend/src/assets/samples/typeSwitch.go b/src/frontend/src/assets/samples/typeSwitch.go deleted file mode 100644 index 3496fd8..0000000 --- a/src/frontend/src/assets/samples/typeSwitch.go +++ /dev/null @@ -1,10 +0,0 @@ -func typeSwitch(i interface{}) { - switch v := i.(type) { - case int: - fmt.Printf("Twice %v is %v\n", v, v*2) - case string: - fmt.Printf("%q is %v bytes long\n", v, len(v)) - default: - fmt.Printf("I don't know about type %T!\n", v) - } -} \ No newline at end of file diff --git a/vsc-extension-quickstart.md b/vsc-extension-quickstart.md deleted file mode 100644 index e2d793c..0000000 --- a/vsc-extension-quickstart.md +++ /dev/null @@ -1,46 +0,0 @@ -# Welcome to your VS Code Extension - -## What's in the folder - -- This folder contains all of the files necessary for your extension. -- `package.json` - this is the manifest file in which you declare your extension and command. - - The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. -- `src/extension.ts` - this is the main file where you will provide the implementation of your command. - - The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. - - We pass the function containing the implementation of the command as the second parameter to `registerCommand`. - -## Setup - -- install the recommended extensions (amodio.tsl-problem-matcher, ms-vscode.extension-test-runner, and dbaeumer.vscode-eslint) - -## Get up and running straight away - -- Press `F5` to open a new window with your extension loaded. -- Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. -- Set breakpoints in your code inside `src/extension.ts` to debug your extension. -- Find output from your extension in the debug console. - -## Make changes - -- You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`. -- You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. - -## Explore the API - -- You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`. - -## Run tests - -- Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner) -- Run the "watch" task via the **Tasks: Run Task** command. Make sure this is running, or tests might not be discovered. -- Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A` -- See the output of the test result in the Test Results view. -- Make changes to `src/test/extension.test.ts` or create new test files inside the `test` folder. - - The provided test runner will only consider files matching the name pattern `**.test.ts`. - - You can create folders inside the `test` folder to structure your tests any way you want. - -## Go further - -- Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension). -- [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VS Code extension marketplace. -- Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration).