Skip to content

Commit 84ac660

Browse files
committed
Merge branch 'gh-pages' of https://github.com/LivelyKernel/lively4-core into gh-pages
2 parents ff0b551 + 31de060 commit 84ac660

File tree

2 files changed

+76
-12
lines changed

2 files changed

+76
-12
lines changed

src/client/reactive/active-expression-rewriting/active-expression-rewriting.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ class Dependency {
172172
DependencyManager.checkAndNotifyAExprs(aexprs, location, this, hook);
173173
}
174174

175+
type() {
176+
if(this.isGlobal()) return "global";
177+
return this._type;
178+
}
179+
175180
isMemberDependency() {
176181
return this._type === 'member' && !this.isGlobal();
177182
}
@@ -189,9 +194,23 @@ class Dependency {
189194
const [object] = ContextAndIdentifierCompositeKey.keysFor(compKey);
190195
return object === self;
191196
}
197+
198+
getHooks() {
199+
return HooksToDependencies.getHooksForDep(this);
200+
}
201+
202+
getName() {
203+
const [context, identifier] = this.contextIdentifierValue();
204+
205+
if (this.isGlobalDependency()) {
206+
return identifier.toString()
207+
}
208+
return (context?context.constructor.name:"") + "." + identifier;
209+
}
192210

193211
getAsDependencyDescription() {
194212
const [context, identifier, value] = this.contextIdentifierValue();
213+
debugger;
195214

196215
if (this.isMemberDependency()) {
197216
return {
@@ -707,6 +726,10 @@ class DataStructureHook extends Hook {
707726
// }
708727
return hook;
709728
}
729+
730+
informationString() {
731+
return "DataStructureHook";
732+
}
710733
}
711734

712735
class PropertyWrappingHook extends Hook {
@@ -717,6 +740,7 @@ class PropertyWrappingHook extends Hook {
717740
constructor(property) {
718741
super();
719742

743+
this.property = property;
720744
this.value = self[property];
721745
const { configurable, enumerable } = Object.getOwnPropertyDescriptor(self, property);
722746

@@ -733,6 +757,10 @@ class PropertyWrappingHook extends Hook {
733757
}
734758
});
735759
}
760+
761+
informationString() {
762+
return "PropertyWrappingHook: " + this.property;
763+
}
736764
}
737765

738766
class MutationObserverHook extends Hook {
@@ -792,6 +820,10 @@ class MutationObserverHook extends Hook {
792820
changeHappened() {
793821
this.notifyDependencies();
794822
}
823+
824+
informationString() {
825+
return "MutationObserverHook: " + this._element;
826+
}
795827
}
796828

797829
class EventBasedHook extends Hook {
@@ -819,6 +851,10 @@ class EventBasedHook extends Hook {
819851
changeHappened() {
820852
this.notifyDependencies();
821853
}
854+
855+
informationString() {
856+
return "EventBasedHook: " + this._element;
857+
}
822858
}
823859

824860
class FrameBasedHook extends Hook {
@@ -844,6 +880,10 @@ class FrameBasedHook extends Hook {
844880
changeHappened() {
845881
this.notifyDependencies();
846882
}
883+
884+
informationString() {
885+
return "FrameBasedHook";
886+
}
847887
}
848888

849889
export class RewritingActiveExpression extends BaseActiveExpression {

src/client/reactive/components/basic/aexpr-graph.js

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"enable aexpr"
2+
13
import Morph from 'src/components/widgets/lively-morph.js';
24
import { AExprRegistry } from 'src/client/reactive/active-expression/active-expression.js';
35
import { DebuggingCache } from 'src/client/reactive/active-expression-rewriting/active-expression-rewriting.js';
@@ -6,13 +8,21 @@ import { DebuggingCache } from 'src/client/reactive/active-expression-rewriting/
68
export default class AexprGraph extends Morph {
79
async initialize() {
810
this.windowTitle = "Active Expression Graph";
11+
this.setWindowSize(1200, 800);
912
let width = window.innerWidth;
1013
let height = window.innerHeight;
11-
this.graphViz = await (<d3-graphviz style="background:gray; width:1200px; height: 800px"></d3-graphviz>)
14+
this.graphViz = await (<d3-graphviz style="background:gray"></d3-graphviz>)
1215
this.graph.append(this.graphViz);
13-
this.graphViz.setDotData(this.graphData());
14-
//const graphvizElement = this.shadowRoot.querySelector("svg");
15-
//graphvizElement.setAttribute("height", "400px");
16+
await this.graphViz.setDotData(this.graphData());
17+
const containerElement = this.graphViz.shadowRoot.querySelector("#container");
18+
/*containerElement.setAttribute("display", "flex");
19+
containerElement.children[0].setAttribute("display", "flex");
20+
setTimeout(() => {
21+
debugger;
22+
const svgElement = this.graphViz.shadowRoot.querySelector("svg");
23+
svgElement.setAttribute("height", "100%");
24+
svgElement.setAttribute("width", "100%");
25+
}, 10000);*/
1626
}
1727

1828
graphData() {
@@ -22,17 +32,31 @@ export default class AexprGraph extends Morph {
2232

2333
const aes = AExprRegistry.allAsArray();
2434

25-
let i = 0;
26-
let j = 0;
35+
const allDeps = new Map();
36+
37+
let aeCount = 0;
38+
let depCount = 0;
39+
let hookCount = 0;
2740
for (const ae of aes) {
2841
const aeData = this.extractData(ae);
29-
nodes.push(`AE${i} [shape="record" label="{${aeData.join("|")}}"]`);
30-
for (const { _, dep, hook } of DebuggingCache.getTripletsForAE(ae)) {
31-
nodes.push(`HOOK${j} [shape="record" label="{${this.escapeTextForDOTRecordLabel(hook.informationString())}}"]`);
32-
edges.push(`AE${i} -> HOOK${j}`);
33-
j++;
42+
nodes.push(`AE${aeCount} [shape="record" label="{${aeData.join("|")}}"]`);
43+
for(const dep of ae.dependencies().all()) {
44+
if(!allDeps.has(dep)) {
45+
allDeps.set(dep, depCount);
46+
nodes.push(`DEP${depCount} [shape="record" label="{${this.escapeTextForDOTRecordLabel(dep.getName())}|${dep.type()}}"]`);
47+
depCount++;
48+
}
49+
50+
edges.push(`AE${aeCount} -> DEP${allDeps.get(dep)}`);
51+
}
52+
aeCount++;
53+
}
54+
for(const dep of allDeps.keys()) {
55+
for(const hook of dep.getHooks()) {
56+
nodes.push(`HOOK${hookCount} [shape="record" label="{${this.escapeTextForDOTRecordLabel(hook.informationString())}}"]`);
57+
edges.push(`DEP${allDeps.get(dep)} -> HOOK${hookCount}`);
58+
hookCount++;
3459
}
35-
i++;
3660
}
3761

3862
return `digraph {

0 commit comments

Comments
 (0)