Skip to content

Commit ea55b87

Browse files
authored
add arrow-import runtime semantic (#226)
1 parent d577eb0 commit ea55b87

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ui/src/lib/store/runtimeSlice.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { analyzeCode, analyzeCodeViaQuery } from "../parser";
1212
function collectSymbolTables({ id, get }: { id: string; get: () => MyState }) {
1313
let pods = get().pods;
1414
let pod = pods[id];
15+
// Collect from parent scope.
1516
if (!pod.parent) return {};
1617
let allSymbolTables = pods[pod.parent].children.map(({ id, type }) => {
1718
// FIXME make this consistent, CODE, POD, DECK, SCOPE; use enums
@@ -25,6 +26,21 @@ function collectSymbolTables({ id, get }: { id: string; get: () => MyState }) {
2526
return Object.assign({}, ...tables);
2627
}
2728
});
29+
// Collect from scopes by Arrows.
30+
const edges = get().edges;
31+
edges.forEach(({ source, target }) => {
32+
if (target === pod.parent) {
33+
if (pods[source].type === "CODE") {
34+
allSymbolTables.push(pods[target].symbolTable);
35+
} else {
36+
let tables = (pods[source].children || [])
37+
.filter(({ id }) => pods[id].ispublic)
38+
.map(({ id }) => pods[id].symbolTable);
39+
allSymbolTables.push(Object.assign({}, ...tables));
40+
}
41+
}
42+
});
43+
// Combine the tables and return.
2844
let res = Object.assign({}, pods[id].symbolTable, ...allSymbolTables);
2945
return res;
3046
}

0 commit comments

Comments
 (0)