const Readable = require("stream").Readable; module.exports = function buildSyms(ctx) { const rs = Readable(); let it = new ComponentIt(ctx, 0, "main"); let counter = 0; rs._read = function() { const actual = it.current(); if (actual == null ) { rs.push(null); return; } let s=actual.offset; while (ctx.signals[s].e >= 0) s = ctx.signals[s].e; let wId = ctx.signals[s].id; if (typeof(wId) == "undefined") wId=-1; rs.push(`${actual.offset},${wId},${actual.cIdx},${actual.name}\n`); it.next(); counter ++; if ((ctx.verbose)&&(counter%10000 == 0)) console.log("Symbols saved: "+counter); }; return rs; }; class SignalIt { constructor (ctx, offset, prefix, cIdx) { this.ctx = ctx; this.offset = offset; this.prefix = prefix; this.cur = 0; this.cIdx = cIdx; } next() { this.cur = 1; return this.current(); } current() { if (this.cur == 0) { return {offset: this.offset, name: this.prefix, cIdx: this.cIdx}; } } } class ArrayIt { constructor (ctx, type, sizes, offset, prefix, cIdx) { if (sizes.length == 0) { if (type == "S") { return new SignalIt(ctx, offset, prefix, cIdx); } else { return new ComponentIt(ctx, offset, prefix); } } this.ctx = ctx; this.type = type; this.sizes = sizes; this.offset = offset; this.prefix = prefix; this.cIdx = cIdx; this.subIt = null; this.cur = 0; this.subArrSize = 1; for (let i=1; i