godprotocol 1.0.81 → 1.0.82

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 (51) hide show
  1. package/.babelrc +3 -0
  2. package/Index.js +8 -19
  3. package/Loader_sequence/main.js +368 -234
  4. package/Objects/Account.js +187 -178
  5. package/Objects/Block.js +60 -61
  6. package/Objects/Blockweb.js +27 -34
  7. package/Objects/Chain.js +115 -118
  8. package/Objects/Explorer.js +30 -37
  9. package/Objects/Filesystem.js +95 -80
  10. package/Objects/Frame.js +43 -48
  11. package/Objects/Manager.js +60 -69
  12. package/Objects/Opcodes.js +39 -101
  13. package/Objects/Oracle.js +50 -66
  14. package/Objects/Virtual_machine.js +132 -132
  15. package/build/Account.js +187 -0
  16. package/build/Block.js +68 -0
  17. package/build/Blockweb.js +36 -0
  18. package/build/Chain.js +119 -0
  19. package/build/Explorer.js +47 -0
  20. package/build/Filesystem.js +127 -0
  21. package/build/Frame.js +52 -0
  22. package/build/Index.js +20 -0
  23. package/build/Manager.js +86 -0
  24. package/build/Opcodes.js +109 -0
  25. package/build/Oracle.js +81 -0
  26. package/build/Virtual_machine.js +136 -0
  27. package/build/add.js +26 -0
  28. package/build/create_server.js +132 -0
  29. package/build/framer.js +59 -0
  30. package/build/functions.js +82 -0
  31. package/build/hash.js +14 -0
  32. package/build/indices.js +31 -0
  33. package/build/jmp.js +19 -0
  34. package/build/main.js +327 -0
  35. package/build/opcodes.js +60 -0
  36. package/build/privacy.js +27 -0
  37. package/build/services.js +50 -0
  38. package/build/std.js +15 -0
  39. package/framer.js +36 -34
  40. package/opcodes/add.js +9 -25
  41. package/opcodes/indices.js +13 -16
  42. package/opcodes/jmp.js +7 -12
  43. package/opcodes/std.js +7 -13
  44. package/opcodes.js +32 -42
  45. package/package.json +1 -1
  46. package/readme.md +4 -4
  47. package/utils/create_server.js +72 -105
  48. package/utils/functions.js +31 -43
  49. package/utils/hash.js +10 -11
  50. package/utils/privacy.js +10 -15
  51. package/utils/services.js +32 -33
@@ -1,327 +1,461 @@
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 _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
9
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread 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 _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
12
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
13
- 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; }
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 num_pattern = /^[+-]?\d+(\.\d+)?$/;
1
+ let num_pattern = /^[+-]?\d+(\.\d+)?$/;
21
2
  // let str_pattern = /^["'][^"']*["']$/;
22
- var var_pattern = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
23
- var Loader = /*#__PURE__*/_createClass(function Loader(account) {
24
- var _this = this;
25
- _classCallCheck(this, Loader);
26
- _defineProperty(this, "instruction_index", function () {
27
- var index = _this.instruction_indexes.slice(-1);
3
+ let var_pattern = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
4
+
5
+ class Loader {
6
+ constructor(account) {
7
+ this.account = account;
8
+ this.opcodes = new Array();
9
+ this.instructions = new Array();
10
+
11
+ this.instruction_indexes = new Array();
12
+ this.instruction_stacks = [[]];
13
+ this.stacks = new Array(account.physical_address);
14
+ this.markers = new Array();
15
+ }
16
+
17
+ instruction_index = () => {
18
+ let index = this.instruction_indexes.slice(-1);
28
19
  index++;
29
- _this.instruction_indexes.splice(-1, 1, index);
20
+ this.instruction_indexes.splice(-1, 1, index);
21
+
30
22
  return index;
31
- });
32
- _defineProperty(this, "stack_instruction", function (instruction) {
33
- if (Array.isArray(instruction)) return instruction.map(function (i) {
34
- return _this.stack_instruction(i);
35
- });
36
- _this.instruction_stacks.slice(-1)[0].push(instruction);
37
- });
38
- _defineProperty(this, "new_stack", function (addr) {
39
- _this.stacks.push(addr);
40
- });
41
- _defineProperty(this, "push_instruction", function (instruction) {
42
- if (Array.isArray(instruction)) return instruction.map(function (i) {
43
- return _this.push_instruction(i);
44
- });
45
- if (_this.pure) {
46
- _this.instructions.push(instruction);
23
+ };
24
+
25
+ stack_instruction = (instruction) => {
26
+ if (Array.isArray(instruction))
27
+ return instruction.map((i) => this.stack_instruction(i));
28
+
29
+ this.instruction_stacks.slice(-1)[0].push(instruction);
30
+ };
31
+
32
+ new_stack = (addr) => {
33
+ this.stacks.push(addr);
34
+ };
35
+
36
+ push_instruction = (instruction) => {
37
+ if (Array.isArray(instruction))
38
+ return instruction.map((i) => this.push_instruction(i));
39
+
40
+ if (this.pure) {
41
+ this.instructions.push(instruction);
47
42
  } else {
48
- _this.stack_instruction("cursor ".concat(_this.instruction_index()));
49
- _this.stack_instruction("write ".concat(instruction));
43
+ this.stack_instruction(`cursor ${this.instruction_index()}`);
44
+ this.stack_instruction(`write ${instruction}`);
50
45
  }
51
- });
52
- _defineProperty(this, "parse_tokens", function (line, stop_char) {
53
- var tokens = new Array();
54
- var pos = 0,
46
+ };
47
+
48
+ parse_tokens = (line, stop_char) => {
49
+ let tokens = new Array();
50
+ let pos = 0,
55
51
  line_number = 0;
56
- var push_token = function push_token(value, type) {
57
- return tokens.push({
58
- value: value,
59
- type: type,
60
- line: line_number,
61
- pos: pos
62
- });
63
- };
52
+
53
+ let push_token = (value, type) =>
54
+ tokens.push({ value, type, line: line_number, pos });
55
+
64
56
  line = line.trim();
65
57
  while (pos < line.length) {
66
- var _char = line[pos].trim();
67
- if (_char === stop_char) return {
68
- tokens: tokens,
69
- pos: pos
70
- };
71
- if (!_char) {
58
+ let char = line[pos].trim();
59
+
60
+ if (char === stop_char) return { tokens, pos };
61
+
62
+ if (!char) {
72
63
  pos++;
64
+
73
65
  continue;
74
66
  }
75
- if (_char === "\n") {
67
+
68
+ if (char === "\n") {
76
69
  line_number++;
77
70
  pos++;
78
- } else if (_char === "@") {
79
- var acc = "";
71
+ } else if (char === "@") {
72
+ let acc = "";
80
73
  while (line[pos] && line[pos].trim()) {
81
74
  acc += line[pos];
82
75
  pos++;
83
76
  }
84
77
  push_token(acc, "address");
85
- } else if (_char === ",") {
78
+ } else if (char === ",") {
86
79
  pos++;
87
- } else if (_char === ":") {
88
- push_token(_char, "separator");
80
+ } else if (char === ":") {
81
+ push_token(char, "separator");
89
82
  pos++;
90
- } else if (_char === "[") {
83
+ } else if (char === "[") {
91
84
  pos++;
92
- var toks = _this.parse_tokens(line.slice(pos), "]");
85
+ let toks = this.parse_tokens(line.slice(pos), "]");
93
86
  push_token(toks.tokens, "array");
94
87
  pos += toks.pos + 1;
95
- } else if (_char === "{") {
88
+ } else if (char === "{") {
96
89
  pos++;
97
- var _toks = _this.parse_tokens(line.slice(pos), "}");
98
- push_token(_toks.tokens, "twain");
99
- pos += _toks.pos + 1;
100
- } else if (_char === ">") {
90
+ let toks = this.parse_tokens(line.slice(pos), "}");
91
+ push_token(toks.tokens, "twain");
92
+ pos += toks.pos + 1;
93
+ } else if (char === ">") {
101
94
  pos++;
102
- } else if (_char === "'" || _char === '"') {
103
- var _acc = "";
95
+ } else if (char === "'" || char === '"') {
96
+ let acc = "";
104
97
  pos++;
105
- while (line[pos] !== _char) {
98
+ while (line[pos] !== char) {
106
99
  if (!line[pos]) break;
107
- _acc += line[pos];
100
+ acc += line[pos];
108
101
  pos++;
109
102
  }
110
103
  pos++;
111
- push_token(_acc, "string");
112
- } else if (num_pattern.test(_char)) {
113
- var _acc2 = _char;
104
+ push_token(acc, "string");
105
+ } else if (num_pattern.test(char)) {
106
+ let acc = char;
114
107
  pos++;
115
- while (num_pattern.test(line[pos]) || line[pos] === "." && !_acc2.includes(line[pos])) {
108
+ while (
109
+ num_pattern.test(line[pos]) ||
110
+ (line[pos] === "." && !acc.includes(line[pos]))
111
+ ) {
116
112
  if (!line[pos]) break;
117
- _acc2 += line[pos];
113
+
114
+ acc += line[pos];
118
115
  pos++;
119
116
  }
120
- push_token(_acc2, "number");
121
- } else if (var_pattern.test(_char)) {
122
- var _acc3 = _char;
117
+ push_token(acc, "number");
118
+ } else if (var_pattern.test(char)) {
119
+ let acc = char;
123
120
  pos++;
124
- while (line[pos] && var_pattern.test("".concat(line[pos].trim()))) {
125
- _acc3 += line[pos];
121
+ while (line[pos] && var_pattern.test(`${line[pos].trim()}`)) {
122
+ acc += line[pos];
126
123
  pos++;
127
124
  }
128
- push_token(_acc3, _this.opcodes.includes(_acc3) ? "opcode" : "variable");
125
+
126
+ push_token(acc, this.opcodes.includes(acc) ? "opcode" : "variable");
129
127
  }
130
128
  }
129
+
131
130
  return tokens;
132
- });
133
- _defineProperty(this, "parse", function (token) {
131
+ };
132
+
133
+ parse = (token) => {
134
134
  if (token.type === "string" || token.type === "number") {
135
- _this.push_instruction(["link ".concat(_this.account.physical_address, "/Datatypes/", "".concat(token.type[0].toUpperCase()).concat(token.type.slice(1))), "write ".concat(token.value), "pop ".concat(token.type)]);
135
+ this.push_instruction([
136
+ `link ${
137
+ this.account.physical_address
138
+ }/Datatypes/${`${token.type[0].toUpperCase()}${token.type.slice(1)}`}`,
139
+ `write ${token.value}`,
140
+ `pop ${token.type}`,
141
+ ]);
136
142
  } else if (token.type === "array") {
137
- _this.push_instruction("link Accounts/".concat(_this.account.name, "/Datatypes/Array"));
138
- token.value.map(function (item, i) {
139
- _this.parse(item);
140
- _this.push_instruction(["cursor ".concat(i), "write ".concat(_this.is_not_literal(item.type) ? "{metadata.output:-1}" : "{datapath:-1}")]);
143
+ this.push_instruction(
144
+ `link Accounts/${this.account.name}/Datatypes/Array`
145
+ );
146
+ token.value.map((item, i) => {
147
+ this.parse(item);
148
+
149
+ this.push_instruction([
150
+ `cursor ${i}`,
151
+ `write ${
152
+ this.is_not_literal(item.type)
153
+ ? "{metadata.output:-1}"
154
+ : "{datapath:-1}"
155
+ }`,
156
+ ]);
141
157
  });
142
- _this.push_instruction("pop Array");
158
+ this.push_instruction(`pop Array`);
143
159
  } else if (token.type === "twain") {
144
- _this.push_instruction("link Accounts/".concat(_this.account.name, "/Datatypes/Twain"));
145
- var curs = true;
146
- if (token.value) token.value.map(function (entry) {
147
- if (entry.type === "separator") {
148
- curs = false;
149
- return;
150
- }
151
- _this.parse(entry);
152
- if (curs) {
153
- {
154
- _this.push_instruction("cursor {*".concat(_this.is_not_literal(entry.type) ? "metadata.output:-1" : "datapath:-1", "}"));
160
+ this.push_instruction(
161
+ `link Accounts/${this.account.name}/Datatypes/Twain`
162
+ );
163
+ let curs = true;
164
+
165
+ if (token.value)
166
+ token.value.map((entry) => {
167
+ if (entry.type === "separator") {
168
+ curs = false;
169
+ return;
155
170
  }
156
- } else {
157
- _this.push_instruction("write ".concat(_this.is_not_literal(entry.type) ? "{metadata.output:-1}" : "{datapath:-1}"));
158
- curs = true;
159
- }
160
- });
161
- _this.push_instruction("pop Twain");
171
+ this.parse(entry);
172
+ if (curs) {
173
+ {
174
+ this.push_instruction(
175
+ `cursor {*${
176
+ this.is_not_literal(entry.type)
177
+ ? "metadata.output:-1"
178
+ : "datapath:-1"
179
+ }}`
180
+ );
181
+ }
182
+ } else {
183
+ this.push_instruction(
184
+ `write ${
185
+ this.is_not_literal(entry.type)
186
+ ? "{metadata.output:-1}"
187
+ : "{datapath:-1}"
188
+ }`
189
+ );
190
+ curs = true;
191
+ }
192
+ });
193
+ this.push_instruction(`pop Twain`);
162
194
  } else if (token.type === "variable") {
163
- _this.push_instruction(["link ".concat("".concat(_this.stacks.slice(-1)[0], "/").concat(token.value)), "pop ".concat(token.value)]);
164
- } else if (token.type === "address") _this.parse_assignment(token);
165
- });
166
- _defineProperty(this, "is_not_literal", function (type) {
167
- return !type || ["variable", "opcode", "address"].includes(type);
168
- });
169
- _defineProperty(this, "parse_assignment", function (line, linked) {
170
- var tokens = linked || line.type ? line : _this.parse_tokens(line);
171
- var identifier = tokens[0];
195
+ this.push_instruction([
196
+ `link ${`${this.stacks.slice(-1)[0]}/${token.value}`}`,
197
+ `pop ${token.value}`,
198
+ ]);
199
+ } else if (token.type === "address") this.parse_assignment(token);
200
+ };
201
+
202
+ is_not_literal = (type) =>
203
+ !type || ["variable", "opcode", "address"].includes(type);
204
+
205
+ parse_assignment = (line, linked) => {
206
+ let tokens = linked || line.type ? line : this.parse_tokens(line);
207
+
208
+ let identifier = tokens[0];
172
209
  if (linked || line.type) {
173
- var line_split = (line.value || line).slice(line.value ? null : 1).trim().split(" ");
174
- var path = line_split[0].split("/");
175
- _this.push_instruction("link ".concat(_this.resolve_addr(path.join("/"))));
176
- tokens = !line.type && _this.parse_tokens(line_split.slice(1).join(" "));
210
+ let line_split = (line.value || line)
211
+ .slice(line.value ? null : 1)
212
+ .trim()
213
+ .split(" ");
214
+ let path = line_split[0].split("/");
215
+
216
+ this.push_instruction(`link ${this.resolve_addr(path.join("/"))}`);
217
+
218
+ tokens = !line.type && this.parse_tokens(line_split.slice(1).join(" "));
177
219
  tokens.unshift && tokens.unshift(null);
178
- if (line.type === "address") return _this.push_instruction("pop ".concat(path[path.length - 1]));
220
+ if (line.type === "address")
221
+ return this.push_instruction(`pop ${path[path.length - 1]}`);
179
222
  } else {
180
- _this.push_instruction("chain ".concat(identifier.value));
181
- _this.stack_instruction(["link ".concat(_this.stacks.slice(-1)[0]), "chain ".concat(identifier.value), "pop ".concat(identifier.value), "pop"]);
223
+ this.push_instruction(`chain ${identifier.value}`);
224
+ this.stack_instruction([
225
+ `link ${this.stacks.slice(-1)[0]}`,
226
+ `chain ${identifier.value}`,
227
+ `pop ${identifier.value}`,
228
+ "pop",
229
+ ]);
182
230
  }
183
- var prev_token;
231
+
232
+ let prev_token;
184
233
  if (tokens[1] && tokens[1].type === "opcode") {
185
- _this.parse_opcode(tokens.slice(1));
234
+ this.parse_opcode(tokens.slice(1));
186
235
  prev_token = tokens[1];
187
236
  } else {
188
- tokens.slice(1).map(function (tok) {
189
- _this.parse(tok);
237
+ tokens.slice(1).map((tok) => {
238
+ this.parse(tok);
190
239
  });
191
240
  prev_token = tokens.slice(-1)[0];
192
241
  }
242
+
193
243
  if (tokens.length > 1) {
194
- _this.push_instruction(["cursor {output}", "write ".concat(_this.is_not_literal(prev_token && prev_token.type) ? "{metadata.output:-1}" : "{datapath:-1}"), "pop ".concat(identifier.value)]);
195
- } else _this.push_instruction("pop ".concat(identifier.value));
196
- });
197
- _defineProperty(this, "marker_pattern", /@[a-zA-Z_][a-zA-Z0-9_]*/);
198
- _defineProperty(this, "parse_opcode", function (line) {
199
- var tokens = Array.isArray(line) ? line : _this.parse_tokens(line);
200
- var op = tokens[0];
201
- if (op.type !== "opcode") return _this.parse(op);
202
- _this.push_instruction(["link Accounts/".concat(_this.account.name, "/Opcodes/").concat(op.value), "link Accounts/".concat(_this.account.name, "/Datatypes/Twain")]);
203
- tokens.slice(1).map(function (tok, i) {
204
- if (tok.type === "address" && tok.value.match(_this.marker_pattern)) {
205
- _this.push_instruction(["link ".concat(_this.account.physical_address, "/Datatypes/Number"), "write ".concat(tok.value), "pop Number"]);
206
- } else _this.parse(tok);
207
- _this.push_instruction(["cursor op".concat(i), "write ".concat(_this.is_not_literal(tok.type) && !(tok.type === "address" && tok.value.match(_this.marker_pattern)) ? "{metadata.output:-1}" : "{datapath:-1}")]);
244
+ this.push_instruction([
245
+ "cursor {output}",
246
+ `write ${
247
+ this.is_not_literal(prev_token && prev_token.type)
248
+ ? "{metadata.output:-1}"
249
+ : "{datapath:-1}"
250
+ }`,
251
+ `pop ${identifier.value}`,
252
+ ]);
253
+ } else this.push_instruction(`pop ${identifier.value}`);
254
+ };
255
+
256
+ marker_pattern = /@[a-zA-Z_][a-zA-Z0-9_]*/;
257
+
258
+ parse_opcode = (line) => {
259
+ let tokens = Array.isArray(line) ? line : this.parse_tokens(line);
260
+
261
+ let op = tokens[0];
262
+
263
+ if (op.type !== "opcode") return this.parse(op);
264
+
265
+ this.push_instruction([
266
+ `link Accounts/${this.account.name}/Opcodes/${op.value}`,
267
+ `link Accounts/${this.account.name}/Datatypes/Twain`,
268
+ ]);
269
+
270
+ tokens.slice(1).map((tok, i) => {
271
+ if (tok.type === "address" && tok.value.match(this.marker_pattern)) {
272
+ this.push_instruction([
273
+ `link ${this.account.physical_address}/Datatypes/Number`,
274
+ `write ${tok.value}`,
275
+ `pop Number`,
276
+ ]);
277
+ } else this.parse(tok);
278
+
279
+ this.push_instruction([
280
+ `cursor op${i}`,
281
+ `write ${
282
+ this.is_not_literal(tok.type) &&
283
+ !(tok.type === "address" && tok.value.match(this.marker_pattern))
284
+ ? "{metadata.output:-1}"
285
+ : "{datapath:-1}"
286
+ }`,
287
+ ]);
208
288
  });
209
- _this.push_instruction(["pop Twain", "cursor inputs", "write {datapath:-1}", op.value, "cursor {output}", "write {datapath:-1}", "pop ".concat(op.value)]);
210
- });
211
- _defineProperty(this, "resolve_addr", function (addr) {
289
+
290
+ this.push_instruction([
291
+ "pop Twain",
292
+ "cursor inputs",
293
+ `write {datapath:-1}`,
294
+ op.value,
295
+ `cursor {output}`,
296
+ `write {datapath:-1}`,
297
+ `pop ${op.value}`,
298
+ ]);
299
+ };
300
+
301
+ resolve_addr = (addr) => {
212
302
  addr = addr.split("/");
213
- var real_addr = "";
303
+
304
+ let real_addr = "";
305
+
214
306
  if (addr[0] === "@") {
215
- addr[0] = _this.account.physical_address;
307
+ addr[0] = this.account.physical_address;
216
308
  real_addr = addr.join("/");
217
309
  } else if (addr[0] === ".." || addr[0] === ".") {
218
- var curr_addr = _this.stacks.slice(-1)[0].split("/");
310
+ let curr_addr = this.stacks.slice(-1)[0].split("/");
219
311
  while (addr[0] === ".." || addr[0] === ".") {
220
312
  if (addr[0] === "..") curr_addr.splice(-1);
221
313
  delete addr[0];
222
314
  }
223
- real_addr = curr_addr.join("/") + "".concat(addr.join("/"));
315
+ real_addr = curr_addr.join("/") + `${addr.join("/")}`;
224
316
  }
317
+
225
318
  return real_addr;
226
- });
227
- _defineProperty(this, "new_stack_instructions", function (new_stack) {
228
- var curr_stack = _this.stacks.slice(-1)[0].split("/");
319
+ };
320
+
321
+ new_stack_instructions = (new_stack) => {
322
+ let curr_stack = this.stacks.slice(-1)[0].split("/");
229
323
  new_stack = new_stack.split("/");
230
- if (curr_stack[1] !== new_stack[1]) {} else {
231
- var i = 0;
324
+
325
+ if (curr_stack[1] !== new_stack[1]) {
326
+ } else {
327
+ let i = 0;
232
328
  while (curr_stack[i] === new_stack[i]) i++;
233
- for (var j = 2; j < new_stack.length; j++) _this.stack_instruction("chain ".concat(new_stack[j]));
234
- _this.stack_instruction("link ".concat(_this.account.physical_address, "/Datatypes/Array"));
329
+
330
+ for (let j = 2; j < new_stack.length; j++)
331
+ this.stack_instruction(`chain ${new_stack[j]}`);
332
+
333
+ this.stack_instruction(
334
+ `link ${this.account.physical_address}/Datatypes/Array`
335
+ );
235
336
  }
236
- });
237
- _defineProperty(this, "parse_routine", function (line) {
238
- var addr = _this.resolve_addr(line);
239
- _this.instruction_stacks.push([]);
240
- _this.new_stack_instructions(addr);
241
- _this.new_stack(addr);
242
- _this.instruction_indexes.push(-1);
243
- });
244
- _defineProperty(this, "pop", function () {
245
- var _this$instructions;
246
- var addr = _this.stacks.splice(-1)[0].split("/");
247
- _this.stack_instruction(["pop Array", "cursor {program}", "write {datapath:-1}"]);
248
- for (var j = 2; j < addr.length; j++) _this.stack_instruction("pop ".concat(addr[j]));
249
- (_this$instructions = _this.instructions).push.apply(_this$instructions, _toConsumableArray(_this.instruction_stacks.splice(-1)[0]));
250
- _this.instruction_indexes.pop();
251
- });
252
- _defineProperty(this, "revamp_marks", function () {
253
- var instruction_stack = _this.instruction_stacks.slice(-1)[0];
254
- instruction_stack = instruction_stack.map(function (ins) {
255
- return _this.resolve_offset(ins, true);
256
- });
257
- _this.instruction_stacks[_this.instruction_stacks.length - 1] = instruction_stack;
258
- });
259
- _defineProperty(this, "handle_marker", function (line) {
260
- var splits = line.slice(1).split(" ");
261
- var name = splits[0];
262
- var curr_stack = _this.stacks.slice(-1)[0];
263
- var markers = _this.markers[curr_stack];
337
+ };
338
+
339
+ parse_routine = (line) => {
340
+ let addr = this.resolve_addr(line);
341
+
342
+ this.instruction_stacks.push([]);
343
+ this.new_stack_instructions(addr);
344
+ this.new_stack(addr);
345
+
346
+ this.instruction_indexes.push(-1);
347
+ };
348
+
349
+ pop = () => {
350
+ let addr = this.stacks.splice(-1)[0].split("/");
351
+ this.stack_instruction([
352
+ `pop Array`,
353
+ `cursor {program}`,
354
+ `write {datapath:-1}`,
355
+ ]);
356
+
357
+ for (let j = 2; j < addr.length; j++)
358
+ this.stack_instruction(`pop ${addr[j]}`);
359
+
360
+ this.instructions.push(...this.instruction_stacks.splice(-1)[0]);
361
+
362
+ this.instruction_indexes.pop();
363
+ };
364
+
365
+ revamp_marks = () => {
366
+ let instruction_stack = this.instruction_stacks.slice(-1)[0];
367
+
368
+ instruction_stack = instruction_stack.map((ins) =>
369
+ this.resolve_offset(ins, true)
370
+ );
371
+
372
+ this.instruction_stacks[this.instruction_stacks.length - 1] =
373
+ instruction_stack;
374
+ };
375
+
376
+ handle_marker = (line) => {
377
+ let splits = line.slice(1).split(" ");
378
+ let name = splits[0];
379
+
380
+ let curr_stack = this.stacks.slice(-1)[0];
381
+ let markers = this.markers[curr_stack];
264
382
  if (!markers) {
265
383
  markers = new Object();
266
- _this.markers[curr_stack] = markers;
384
+ this.markers[curr_stack] = markers;
267
385
  }
268
- markers[name] = _this.instruction_index();
269
- _this.revamp_marks();
386
+ markers[name] = this.instruction_index();
387
+
388
+ this.revamp_marks();
389
+
270
390
  return splits.slice(1).join(" ");
271
- });
272
- _defineProperty(this, "resolve_offset", function (line, revamping) {
273
- var matches = line.match(_this.marker_pattern),
391
+ };
392
+
393
+ resolve_offset = (line, revamping) => {
394
+ let matches = line.match(this.marker_pattern),
274
395
  value;
275
396
  if (matches) {
276
- var match = matches[0].slice(1);
277
- var curr_stack = _this.stacks.slice(-1)[0];
278
- var markers = _this.markers[curr_stack];
397
+ let match = matches[0].slice(1);
398
+
399
+ let curr_stack = this.stacks.slice(-1)[0];
400
+ let markers = this.markers[curr_stack];
279
401
  if (!markers) {
280
402
  markers = new Object();
281
- _this.markers[curr_stack] = markers;
403
+ this.markers[curr_stack] = markers;
282
404
  }
283
405
  value = markers[match];
284
406
  }
285
- if (typeof value === "number") line = line.replace(_this.marker_pattern, (revamping && value > 0 ? value - 1 : value).toString());
407
+
408
+ if (typeof value === "number")
409
+ line = line.replace(
410
+ this.marker_pattern,
411
+ (revamping && value > 0 ? value - 1 : value).toString()
412
+ );
413
+
286
414
  return line;
287
- });
288
- _defineProperty(this, "compile", function (codes) {
289
- var code_array = codes.split("\n");
290
- for (var c = 0; c < code_array.length; c++) {
291
- var line = code_array[c].trim();
415
+ };
416
+
417
+ compile = (codes) => {
418
+ let code_array = codes.split("\n");
419
+
420
+ for (let c = 0; c < code_array.length; c++) {
421
+ let line = code_array[c].trim();
292
422
  if (!line) continue;
423
+
293
424
  if (line.startsWith(":")) {
294
- line = _this.handle_marker(line);
425
+ line = this.handle_marker(line);
426
+
295
427
  if (!line) continue;
296
428
  }
297
- line = _this.resolve_offset(line);
298
- if (line === ";") _this.pop();else if (line.startsWith(".") || line.startsWith("@")) _this.parse_routine(line);else if (line.startsWith("//")) continue;else if (line.startsWith(">@")) _this.parse_assignment(line, true);else if (line.startsWith(">")) _this.parse_assignment(line);else _this.parse_opcode(line);
429
+
430
+ line = this.resolve_offset(line);
431
+
432
+ if (line === ";") this.pop();
433
+ else if (line.startsWith(".") || line.startsWith("@"))
434
+ this.parse_routine(line);
435
+ else if (line.startsWith("//")) continue;
436
+ else if (line.startsWith(">@")) this.parse_assignment(line, true);
437
+ else if (line.startsWith(">")) this.parse_assignment(line);
438
+ else this.parse_opcode(line);
299
439
  }
300
- });
301
- _defineProperty(this, "run", function (codes, meta) {
440
+ };
441
+
442
+ run = (codes, meta) => {
302
443
  if (!meta) meta = {};
303
- _this.pure = meta && meta.pure;
304
- var cb = meta && meta.cb;
305
- _this.compile(codes);
444
+ this.pure = meta && meta.pure;
445
+
446
+ let cb = meta && meta.cb;
447
+
448
+ this.compile(codes);
306
449
 
307
450
  // console.log(JSON.stringify(this.instructions, null, 2), "hiya");
308
451
 
309
- _this.account.load({
310
- program: {
311
- instructions: _toConsumableArray(_this.instructions)
312
- },
313
- callback: cb
452
+ this.account.load({
453
+ program: { instructions: [...this.instructions] },
454
+ callback: cb,
314
455
  });
315
- _this.instructions = [];
316
- _this.pure = false;
317
- });
318
- this.account = account;
319
- this.opcodes = new Array();
320
- this.instructions = new Array();
321
- this.instruction_indexes = new Array();
322
- this.instruction_stacks = [[]];
323
- this.stacks = new Array(account.physical_address);
324
- this.markers = new Array();
325
- });
326
- var _default = Loader;
327
- exports["default"] = _default;
456
+ this.instructions = [];
457
+ this.pure = false;
458
+ };
459
+ }
460
+
461
+ export default Loader;