awv3
Version:
⚡ AWV3 embedded CAD
51 lines (41 loc) • 1.32 kB
JavaScript
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
var _class, _temp;
import Ast from './ast';
import NameVariable from './namevariable';
import VariableDef from './variabledef';
var Module = (_temp = _class =
/*#__PURE__*/
function (_Ast) {
_inheritsLoose(Module, _Ast);
function Module() {
return _Ast.apply(this, arguments) || this;
}
var _proto = Module.prototype;
_proto.unparse = function unparse() {
var variables = new Set();
for (var _iterator = this.walk(), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var _node = _ref;
if (_node instanceof NameVariable) variables.add(_node);
}
var stmts = variables.size !== 0 ? [new VariableDef(variables.concat())] : [];
return stmts.concat(this.body).map(function (stmt) {
return stmt.unparse();
}).join(' ');
};
return Module;
}(Ast), Object.defineProperty(_class, "_fields", {
configurable: true,
enumerable: true,
writable: true,
value: ['body']
}), _temp);
export { Module as default };