Skip to content

Commit

Permalink
add arrow-import runtime semantic (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
lihebi authored Feb 27, 2023
1 parent d577eb0 commit ea55b87
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ui/src/lib/store/runtimeSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { analyzeCode, analyzeCodeViaQuery } from "../parser";
function collectSymbolTables({ id, get }: { id: string; get: () => MyState }) {
let pods = get().pods;
let pod = pods[id];
// Collect from parent scope.
if (!pod.parent) return {};
let allSymbolTables = pods[pod.parent].children.map(({ id, type }) => {
// FIXME make this consistent, CODE, POD, DECK, SCOPE; use enums
Expand All @@ -25,6 +26,21 @@ function collectSymbolTables({ id, get }: { id: string; get: () => MyState }) {
return Object.assign({}, ...tables);
}
});
// Collect from scopes by Arrows.
const edges = get().edges;
edges.forEach(({ source, target }) => {
if (target === pod.parent) {
if (pods[source].type === "CODE") {
allSymbolTables.push(pods[target].symbolTable);
} else {
let tables = (pods[source].children || [])
.filter(({ id }) => pods[id].ispublic)
.map(({ id }) => pods[id].symbolTable);
allSymbolTables.push(Object.assign({}, ...tables));
}
}
});
// Combine the tables and return.
let res = Object.assign({}, pods[id].symbolTable, ...allSymbolTables);
return res;
}
Expand Down

0 comments on commit ea55b87

Please sign in to comment.