godprotocol 1.0.796 → 1.0.798

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