generated from CMU-17313Q/NodeBB-f23
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #128 from CMU-17313Q/implementing-the-iroh-tool-wi…
…th-saada Implementing the Iroh tool
- Loading branch information
Showing
3 changed files
with
69 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include: | ||
- ./src/pubsub.ts | ||
exclude: | ||
- ./node_modules/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* eslint-disable */ | ||
const Iroh = require("iroh"); | ||
|
||
let stage = new Iroh.Stage(` | ||
function factorial(n) { | ||
if (n === 0) return 1; | ||
return n * factorial(n - 1); | ||
}; | ||
factorial(3); | ||
`); | ||
|
||
// function call | ||
stage.addListener(Iroh.CALL) | ||
.on("before", (e) => { | ||
let external = e.external ? "#external" : ""; | ||
console.log(" ".repeat(e.indent) + "call", e.name, external, "(", e.arguments, ")"); | ||
//console.log(e.getSource()); | ||
}) | ||
.on("after", (e) => { | ||
let external = e.external ? "#external" : ""; | ||
console.log(" ".repeat(e.indent) + "call", e.name, "end", external, "->", [e.return]); | ||
//console.log(e.getSource()); | ||
}); | ||
|
||
// function | ||
stage.addListener(Iroh.FUNCTION) | ||
.on("enter", (e) => { | ||
let sloppy = e.sloppy ? "#sloppy" : ""; | ||
if (e.sloppy) { | ||
console.log(" ".repeat(e.indent) + "call", e.name, sloppy, "(", e.arguments, ")"); | ||
//console.log(e.getSource()); | ||
} | ||
}) | ||
.on("leave", (e) => { | ||
let sloppy = e.sloppy ? "#sloppy" : ""; | ||
if (e.sloppy) { | ||
console.log(" ".repeat(e.indent) + "call", e.name, "end", sloppy, "->", [void 0]); | ||
//console.log(e.getSource()); | ||
} | ||
}) | ||
.on("return", (e) => { | ||
let sloppy = e.sloppy ? "#sloppy" : ""; | ||
if (e.sloppy) { | ||
console.log(" ".repeat(e.indent) + "call", e.name, "end", sloppy, "->", [e.return]); | ||
//console.log(e.getSource()); | ||
} | ||
}); | ||
|
||
// program | ||
stage.addListener(Iroh.PROGRAM) | ||
.on("enter", (e) => { | ||
console.log(" ".repeat(e.indent) + "Program"); | ||
}) | ||
.on("leave", (e) => { | ||
console.log(" ".repeat(e.indent) + "Program end", "->", e.return); | ||
}); | ||
|
||
eval(stage.script); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters