Skip to content

Commit

Permalink
added iroh
Browse files Browse the repository at this point in the history
  • Loading branch information
GulnazSerikbay committed Oct 20, 2023
1 parent e50a129 commit 893cd7d
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ require('./require-main');

const nconf = require('nconf');



nconf.argv().env({
separator: '__',
});

const winston = require('winston');
const path = require('path');

const Iroh = require('iroh');
const file = require('./src/file');

process.env.NODE_ENV = process.env.NODE_ENV || 'production';
Expand All @@ -42,6 +45,65 @@ const configExists = file.existsSync(configFile) || (nconf.get('url') && nconf.g

const prestart = require('./src/prestart');



const 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) => {
const external = e.external ? '#external' : '';
console.log(`${' '.repeat(e.indent)}call`, e.name, external, '(', e.arguments, ')');
// console.log(e.getSource());
})
.on('after', (e) => {
const 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) => {
const 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) => {
const 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) => {
const 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);


prestart.loadConfig(configFile);
prestart.setupWinston();
prestart.versionCheck();
Expand Down

0 comments on commit 893cd7d

Please sign in to comment.