1+ "enable aexpr"
2+
13import Morph from 'src/components/widgets/lively-morph.js' ;
24import { AExprRegistry } from 'src/client/reactive/active-expression/active-expression.js' ;
35import { 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/
68export 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