godprotocol 1.0.771 → 1.0.783

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/Index.js +0 -3
  2. package/Loader_sequence/main.js +460 -65
  3. package/Objects/Account.js +23 -20
  4. package/Objects/Block.js +4 -1
  5. package/Objects/Chain.js +8 -1
  6. package/Objects/Filesystem.js +11 -15
  7. package/Objects/Manager.js +174 -37
  8. package/Objects/Opcodes.js +5 -3
  9. package/Objects/Oracle.js +10 -0
  10. package/Objects/Virtual_machine.js +1 -7
  11. package/framer.js +2 -4
  12. package/opcodes/std.js +2 -1
  13. package/opcodes.js +6 -4
  14. package/package.json +7 -4
  15. package/readme.md +1 -1
  16. package/utils/services.js +1 -1
  17. package/Loader_sequence/functions/parse_expression.js +0 -107
  18. package/Loader_sequence/functions/parse_to_obj.js +0 -38
  19. package/Loader_sequence/functions/parse_variable.js +0 -38
  20. package/Loader_sequence/functions/tokenise.js +0 -135
  21. package/Loader_sequence/functions/utils.js +0 -14
  22. package/Loader_sequence/keywords/parse.js +0 -23
  23. package/Loader_sequence/native_classes/Variable.js +0 -49
  24. package/Loader_sequence/native_classes/datatypes/Array.js +0 -56
  25. package/Loader_sequence/native_classes/datatypes/Boolean.js +0 -42
  26. package/Loader_sequence/native_classes/datatypes/Number.js +0 -42
  27. package/Loader_sequence/native_classes/datatypes/String.js +0 -42
  28. package/Loader_sequence/native_classes/datatypes/Twain.js +0 -65
  29. package/Loader_sequence/native_classes/datatypes/Void.js +0 -42
  30. package/Loader_sequence/native_classes/global.js +0 -48
  31. package/Loader_sequence/native_classes/native.js +0 -63
  32. package/Loader_sequence/native_classes/operators.js +0 -64
  33. package/Loader_sequence/native_classes/parse.js +0 -54
  34. package/Loader_sequence/utils/format_instructions.js +0 -52
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _native = _interopRequireDefault(require("./native"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
11
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
12
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
13
- function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
14
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
15
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
16
- function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
17
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
18
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
19
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
20
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
21
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
22
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
- var Global = /*#__PURE__*/function (_Native) {
24
- _inherits(Global, _Native);
25
- var _super = _createSuper(Global);
26
- function Global(compiler) {
27
- var _this;
28
- _classCallCheck(this, Global);
29
- _this = _super.call(this);
30
- _defineProperty(_assertThisInitialized(_this), "generate_assembly", function (sequence) {
31
- // sequence.push(`chain ${this.name}`);
32
-
33
- _this.children.map(function (c) {
34
- return c.generate_assembly(sequence);
35
- });
36
-
37
- // sequence.push(`pop ${this.name}`);
38
- });
39
- _this.is_global = true;
40
- _this.compiler = compiler;
41
- _this.name = _this.compiler.name;
42
- _this.path = _this.compiler.account.physical_address;
43
- return _this;
44
- }
45
- return _createClass(Global);
46
- }(_native["default"]);
47
- var _default = Global;
48
- exports["default"] = _default;
@@ -1,63 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _parse_expression3 = require("../functions/parse_expression");
8
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
9
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
10
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
12
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
13
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
- var Native = /*#__PURE__*/_createClass(function Native() {
16
- var _this = this;
17
- _classCallCheck(this, Native);
18
- _defineProperty(this, "find", function (obj) {
19
- for (var c = 0; c < _this.children.length; c++) {
20
- var child = _this.children[c];
21
- if (child.token.value === obj.token.value && child.token.type === "variable") {
22
- return child;
23
- }
24
- }
25
- return _this.parent ? _this.parent.find(obj) : null;
26
- });
27
- _defineProperty(this, "greedy", function (tokens) {
28
- var pos = 0,
29
- obj;
30
- if (_this.token.compiler.expr_types.includes(_this.token.type)) {
31
- var _parse_expression = (0, _parse_expression3.parse_expression)(tokens.slice(pos + 1), _this, true),
32
- obj_ = _parse_expression.obj,
33
- pos_ = _parse_expression.pos;
34
- obj = obj_;
35
- pos += pos_;
36
- } else if (_this.token.type === "keyword") {
37
- if (["parse", "return"].includes(_this.token.value)) {
38
- var _parse_expression2 = (0, _parse_expression3.parse_expression)(tokens.slice(pos + 1), _this),
39
- _obj = _parse_expression2.obj,
40
- _pos_ = _parse_expression2.pos;
41
- _this.push(_obj);
42
- pos += _pos_ + 1;
43
- }
44
- }
45
- return {
46
- obj: obj || _this,
47
- pos: pos
48
- };
49
- });
50
- _defineProperty(this, "set_parent", function (parent) {
51
- _this.parent = parent;
52
- _this.path = "".concat(_this.parent.path, "/").concat(_this.name);
53
- });
54
- _defineProperty(this, "push", function (obj) {
55
- if (!obj) return;
56
- _this.children.push(obj);
57
- if (obj.set_parent) obj.set_parent(_this);
58
- });
59
- this._id = Math.random();
60
- this.children = new Array();
61
- });
62
- var _default = Native;
63
- exports["default"] = _default;
@@ -1,64 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.op_to_name = exports["default"] = void 0;
7
- var _native = _interopRequireDefault(require("./native"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
11
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
12
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
13
- function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
14
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
15
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
16
- function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
17
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
18
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
19
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
20
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
21
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
22
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
- var op_to_name = {
24
- "+": "add",
25
- "-": "subtract",
26
- "/": "divide",
27
- "*": "multiply",
28
- "=": "assign"
29
- };
30
- exports.op_to_name = op_to_name;
31
- var Operator = /*#__PURE__*/function (_Native) {
32
- _inherits(Operator, _Native);
33
- var _super = _createSuper(Operator);
34
- function Operator(token) {
35
- var _this;
36
- _classCallCheck(this, Operator);
37
- _this = _super.call(this);
38
- _defineProperty(_assertThisInitialized(_this), "generate_assembly", function (sequence) {
39
- sequence.push("link ".concat(_this.token.compiler.account.physical_address, "/Opcodes/").concat(_this.name));
40
- sequence.push("link ".concat(_this.token.compiler.account.physical_address, "/Datatypes/Twain"));
41
- for (var c = 0; c < _this.children.length; c++) {
42
- var child = _this.children[c];
43
- child.generate_assembly(sequence);
44
- sequence.push("cursor op".concat(c));
45
- sequence.push("write {".concat(_this.token.compiler.datatypes.includes(child.token.type) ? "datapath" : "metadata.output", ":-1}"));
46
- }
47
- sequence.push("pop");
48
- sequence.push("link ".concat(_this.token.compiler.account.physical_address, "/Datatypes/Twain"));
49
- sequence.push("cursor inputs");
50
- sequence.push("write ../{datapath:-1}");
51
- sequence.push(_this.name);
52
- sequence.push("pop ".concat(_this.token.compiler.account.physical_address, "/Datatypes/Twain"));
53
- sequence.push("cursor {output}");
54
- sequence.push("write ^{datapath:-1}");
55
- sequence.push("pop Opcodes/".concat(_this.name));
56
- });
57
- _this.token = token;
58
- _this.name = op_to_name[_this.token.value];
59
- return _this;
60
- }
61
- return _createClass(Operator);
62
- }(_native["default"]);
63
- var _default = Operator;
64
- exports["default"] = _default;
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _native = _interopRequireDefault(require("./native"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
11
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
12
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
13
- function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
14
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
15
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
16
- function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
17
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
18
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
19
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
20
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
21
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
22
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
- var Parse = /*#__PURE__*/function (_Native) {
24
- _inherits(Parse, _Native);
25
- var _super = _createSuper(Parse);
26
- function Parse(token) {
27
- var _this;
28
- _classCallCheck(this, Parse);
29
- _this = _super.call(this);
30
- _defineProperty(_assertThisInitialized(_this), "generate_assembly", function (sequence) {
31
- sequence.push("link ".concat(_this.token.compiler.account.physical_address, "/Opcodes/stdout"));
32
- sequence.push("link ".concat(_this.token.compiler.account.physical_address, "/Datatypes/Twain"));
33
- for (var c = 0; c < _this.children.length; c++) {
34
- var child = _this.children[c];
35
- child.generate_assembly(sequence);
36
- sequence.push("cursor op".concat(c));
37
- sequence.push("write {".concat(_this.token.compiler.datatypes.includes(child.token.type) ? "datapath" : "metadata.output", ":-1}"));
38
- }
39
- sequence.push("pop");
40
- sequence.push("link ".concat(_this.token.compiler.account.physical_address, "/Datatypes/Twain"));
41
- sequence.push("cursor inputs");
42
- sequence.push("write ../{datapath:-1}");
43
- sequence.push(_this.name);
44
- sequence.push("pop Datatypes/Twain");
45
- sequence.push("pop Opcodes/stdout");
46
- });
47
- _this.token = token;
48
- _this.name = "stdout";
49
- return _this;
50
- }
51
- return _createClass(Parse);
52
- }(_native["default"]);
53
- var _default = Parse;
54
- exports["default"] = _default;
@@ -1,52 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
9
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
11
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
12
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
13
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
14
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
15
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
16
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
17
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
18
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
- var Tree_node = /*#__PURE__*/_createClass(function Tree_node(value) {
21
- var _this = this;
22
- _classCallCheck(this, Tree_node);
23
- _defineProperty(this, "add_child", function (childNode) {
24
- _this.children.push(childNode);
25
- });
26
- this.value = value;
27
- this.children = [];
28
- });
29
- var format_instructions = function format_instructions(instructions, no) {
30
- if (no) return instructions;
31
- var root = new Tree_node("air");
32
- var current = root;
33
- var node_stack = [];
34
- instructions.forEach(function (instruction) {
35
- var _instruction$split = instruction.split(" ", 2),
36
- _instruction$split2 = _slicedToArray(_instruction$split, 2),
37
- opcode = _instruction$split2[0],
38
- operand = _instruction$split2[1];
39
- if (opcode === "chain" || opcode === "link") {
40
- var new_node = new Tree_node(instruction);
41
- current.add_child(new_node);
42
- node_stack.push(current);
43
- current = new_node;
44
- } else if (opcode === "pop") {
45
- current.add_child(instruction);
46
- current = node_stack.pop();
47
- } else current.add_child(instruction);
48
- });
49
- return JSON.stringify(root, null, 2);
50
- };
51
- var _default = format_instructions;
52
- exports["default"] = _default;