File tree 3 files changed +19
-7
lines changed
3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ <h1>Syntax Tree</h1>
20
20
< option value ="prettyPrint "> AST</ option >
21
21
< option value ="disasm "> ISEQ</ option >
22
22
< option value ="mermaid "> GRAPH</ option >
23
+ < option value ="seaOfNodes "> SEA OF NODES</ option >
23
24
</ select >
24
25
</ div >
25
26
</ nav >
Original file line number Diff line number Diff line change @@ -25,12 +25,6 @@ export default async function createRuby() {
25
25
26
26
return vm . eval ( rubySource ) . toString ( ) ;
27
27
} ,
28
- mermaid ( source ) {
29
- const jsonSource = JSON . stringify ( JSON . stringify ( source ) ) ;
30
- const rubySource = `SyntaxTree.parse(JSON.parse(${ jsonSource } )).to_mermaid` ;
31
-
32
- return vm . eval ( rubySource ) . toString ( ) ;
33
- } ,
34
28
// A function that calls through to the SyntaxTree.format function to get
35
29
// the pretty-printed version of the source.
36
30
format ( source ) {
@@ -39,12 +33,29 @@ export default async function createRuby() {
39
33
40
34
return vm . eval ( rubySource ) . toString ( ) ;
41
35
} ,
36
+ mermaid ( source ) {
37
+ const jsonSource = JSON . stringify ( JSON . stringify ( source ) ) ;
38
+ const rubySource = `SyntaxTree.parse(JSON.parse(${ jsonSource } )).to_mermaid` ;
39
+
40
+ return vm . eval ( rubySource ) . toString ( ) ;
41
+ } ,
42
42
// A function that calls through to PP to get the pretty-printed version of
43
43
// the syntax tree.
44
44
prettyPrint ( source ) {
45
45
const jsonSource = JSON . stringify ( JSON . stringify ( source ) ) ;
46
46
const rubySource = `PP.pp(SyntaxTree.parse(JSON.parse(${ jsonSource } )), +"", 80)` ;
47
47
48
+ return vm . eval ( rubySource ) . toString ( ) ;
49
+ } ,
50
+ // A function to print the current sea of nodes
51
+ seaOfNodes ( source ) {
52
+ const jsonSource = JSON . stringify ( JSON . stringify ( source ) ) ;
53
+ const rubySource = `
54
+ iseq = RubyVM::InstructionSequence.compile(JSON.parse(${ jsonSource } ))
55
+ iseq = SyntaxTree::YARV::InstructionSequence.from(iseq.to_a)
56
+ iseq.to_son.to_mermaid
57
+ ` ;
58
+
48
59
return vm . eval ( rubySource ) . toString ( ) ;
49
60
}
50
61
} ;
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ Promise.all([
50
50
try {
51
51
let source = displayFunction ( editor . getValue ( ) ) ;
52
52
53
- if ( event . detail . kind === "mermaid" ) {
53
+ if ( event . detail . kind === "mermaid" || event . detail . kind === "seaOfNodes" ) {
54
54
output . setAttribute ( "style" , "display: none;" ) ;
55
55
graph . setAttribute ( "style" , "text-align: left;" )
56
56
graph . innerHTML = "Loading..."
You can’t perform that action at this time.
0 commit comments