Skip to content

Commit d094ea6

Browse files
authored
Merge pull request #35 from tmr232/release-0.0.10
Prep for release 0.0.10
2 parents 1aeddef + b431a48 commit d094ea6

File tree

7 files changed

+92
-14
lines changed

7 files changed

+92
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
66

77
## [Unreleased]
88

9+
## [0.0.10]
10+
911
### Added
1012

1113
- Added JetBrains frontend for use in JetBrains IDE plugin

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Custom color schems are created via the [interactive demo](https://tmr232.github
4545

4646
- [Go](https://tmr232.github.io/function-graph-overview/?language=0)
4747
- [C](https://tmr232.github.io/function-graph-overview/?language=1)
48+
- [C++](https://tmr232.github.io/function-graph-overview/?language=3)
4849
- [Python](https://tmr232.github.io/function-graph-overview/?language=2)
4950

5051
## Development

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"//": "START EXTENSION ATTRIBUTES",
6767
"publisher": "tamir-bahar",
6868
"name": "function-graph-overview",
69-
"version": "0.0.9",
69+
"version": "0.0.10",
7070
"description": "Function Graph Overview",
7171
"displayName": "Function Graph Overview",
7272
"icon": "./media/icon.png",

src/components/CodeSegmentation.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
}
117117
</script>
118118

119-
{#await initialize() then}
119+
{#await initialize() then _}
120120
<pre>{@html renderWrapper(code, language, { simplify, trim })}</pre>
121121
<button on:click={recolorNodes}>Recolor Nodes</button>
122122
{/await}

src/components/Demo.svelte

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,20 @@
1010
import ColorScheme from "./ColorSchemeEditor.svelte";
1111
import { getSystemColorList, toggleTheme, isDark } from "./lightdark.ts";
1212
import type { LanguageSupport } from "@codemirror/language";
13+
import { evolve } from "../control-flow/evolve.ts";
14+
15+
// ADD-LANGUAGES-HERE
16+
const defaultCodeSamples: { [language in Language]?: string } = {
17+
Go: "func Example() {\n\tif x {\n\t\treturn\n\t}\n}",
18+
C: "void main() {\n\tif (x) {\n\t\treturn;\n\t}\n}",
19+
"C++": "void main() {\n\tif (x) {\n\t\treturn;\n\t}\n}",
20+
Python: "def example():\n if x:\n return",
21+
};
22+
23+
export let code: { [language in Language]?: string } = {};
24+
25+
const languageCode = evolve(defaultCodeSamples, code);
1326
14-
export let codeGo = "func Example() {\n\tif x {\n\t\treturn\n\t}\n}";
15-
export let codeC = "void main() {\n\tif (x) {\n\t\treturn;\n\t}\n}";
16-
export let codeCpp = "void main() {\n\tif (x) {\n\t\treturn;\n\t}\n}";
17-
export let codePython = "def example():\n if x:\n return";
1827
let offsetToHighlight: number | undefined = undefined;
1928
let colorList = getSystemColorList();
2029
// ADD-LANGUAGES-HERE
@@ -37,13 +46,6 @@
3746
},
3847
] as const;
3948
40-
const languageCode: { [language in Language]: string } = {
41-
Go: codeGo,
42-
C: codeC,
43-
Python: codePython,
44-
"C++": codeCpp,
45-
};
46-
4749
const urlParams = new URLSearchParams(window.location.search);
4850
if (urlParams.has("go")) {
4951
languageCode.Go = LZString.decompressFromEncodedURIComponent(

src/demo/src/App.svelte

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,30 @@
33
import demoCodeGo from "./assets/demo.go?raw";
44
import demoCodeC from "./assets/demo.c?raw";
55
import demoCodePython from "./assets/demo.py?raw";
6+
import demoCodeCpp from "./assets/demo.cpp?raw";
67
import { isDark } from "../../components/lightdark";
78
import { onDestroy } from "svelte";
9+
import type { Language } from "../../control-flow/cfg.ts";
810
911
document.body.dataset.theme = isDark ? "dark" : "light";
1012
1113
const unsubscribe = isDark.subscribe((isDark) => {
1214
document.body.dataset.theme = isDark ? "dark" : "light";
1315
});
1416
17+
// ADD-LANGUAGES-HERE
18+
const code: { [language in Language]?: string } = {
19+
C: demoCodeC,
20+
Python: demoCodePython,
21+
Go: demoCodeGo,
22+
"C++": demoCodeCpp,
23+
};
24+
1525
onDestroy(unsubscribe);
1626
</script>
1727

1828
<main>
19-
<Demo codeGo={demoCodeGo} codeC={demoCodeC} codePython={demoCodePython} />
29+
<Demo {code} />
2030
</main>
2131

2232
<style>

src/demo/src/assets/demo.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
Capturer::Capturer( StringRef macroName,
2+
SourceLineInfo const& lineInfo,
3+
ResultWas::OfType resultType,
4+
StringRef names ):
5+
m_resultCapture( getResultCapture() ) {
6+
auto trimmed = [&] (size_t start, size_t end) {
7+
while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) {
8+
++start;
9+
}
10+
while (names[end] == ',' || isspace(static_cast<unsigned char>(names[end]))) {
11+
--end;
12+
}
13+
return names.substr(start, end - start + 1);
14+
};
15+
auto skipq = [&] (size_t start, char quote) {
16+
for (auto i = start + 1; i < names.size() ; ++i) {
17+
if (names[i] == quote)
18+
return i;
19+
if (names[i] == '\\')
20+
++i;
21+
}
22+
CATCH_INTERNAL_ERROR("CAPTURE parsing encountered unmatched quote");
23+
};
24+
25+
size_t start = 0;
26+
std::stack<char> openings;
27+
for (size_t pos = 0; pos < names.size(); ++pos) {
28+
char c = names[pos];
29+
switch (c) {
30+
case '[':
31+
case '{':
32+
case '(':
33+
// It is basically impossible to disambiguate between
34+
// comparison and start of template args in this context
35+
// case '<':
36+
openings.push(c);
37+
break;
38+
case ']':
39+
case '}':
40+
case ')':
41+
// case '>':
42+
openings.pop();
43+
break;
44+
case '"':
45+
case '\'':
46+
pos = skipq(pos, c);
47+
break;
48+
case ',':
49+
if (start != pos && openings.empty()) {
50+
m_messages.emplace_back(macroName, lineInfo, resultType);
51+
m_messages.back().message = static_cast<std::string>(trimmed(start, pos));
52+
m_messages.back().message += " := ";
53+
start = pos;
54+
}
55+
break;
56+
default:; // noop
57+
}
58+
}
59+
assert(openings.empty() && "Mismatched openings");
60+
m_messages.emplace_back(macroName, lineInfo, resultType);
61+
m_messages.back().message = static_cast<std::string>(trimmed(start, names.size() - 1));
62+
m_messages.back().message += " := ";
63+
}

0 commit comments

Comments
 (0)