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
package/Index.js CHANGED
@@ -20,8 +20,5 @@ var start = function start(name, meta) {
20
20
  var initiator = start(process.env.INITIATOR || "initiator");
21
21
  exports.initiator = initiator;
22
22
  (0, _create_server["default"])(initiator);
23
- setTimeout(function () {
24
- initiator.compiler.run("\n greeting = 'Hello, world!' \n parse greeting\n");
25
- }, 1500);
26
23
  var _default = start;
27
24
  exports["default"] = _default;
@@ -1,83 +1,478 @@
1
1
  "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
- value: true
4
+ value: true,
5
5
  });
6
6
  exports["default"] = void 0;
7
- var _parse_to_obj = _interopRequireDefault(require("./functions/parse_to_obj"));
8
- var _tokenise = _interopRequireDefault(require("./functions/tokenise"));
9
- var _global = _interopRequireDefault(require("./native_classes/global"));
10
- var _format_instructions = _interopRequireDefault(require("./utils/format_instructions"));
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12
- 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); }
13
- 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); } }
14
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
15
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
16
- 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; }
17
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
18
- 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); }
19
- var Loader_sequence = /*#__PURE__*/_createClass(function Loader_sequence(account) {
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+)?$/;
118
+ // let str_pattern = /^["'][^"']*["']$/;
119
+ var var_pattern = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
120
+ var Loader = /*#__PURE__*/ _createClass(function Loader(account) {
20
121
  var _this = this;
21
- _classCallCheck(this, Loader_sequence);
22
- _defineProperty(this, "curr_namespace", function () {
23
- return _this.namestack.slice(-1)[0];
122
+ _classCallCheck(this, Loader);
123
+ _defineProperty(this, "instruction_index", function () {
124
+ var index = _this.instruction_indexes.slice(-1);
125
+ index++;
126
+ _this.instruction_indexes.splice(-1, 1, index);
127
+ return index;
24
128
  });
25
- _defineProperty(this, "tokenise", function (code) {
26
- _this.tokens = (0, _tokenise["default"])(code, null, _this);
129
+ _defineProperty(this, "stack_instruction", function (instruction) {
130
+ 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);
27
138
  });
28
- _defineProperty(this, "parse", function (tokens, stop_token) {
29
- tokens = tokens || _this.tokens;
139
+ _defineProperty(this, "push_instruction", function (instruction) {
140
+ 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);
146
+ } else {
147
+ _this.stack_instruction("cursor ".concat(_this.instruction_index()));
148
+ _this.stack_instruction("write ".concat(instruction));
149
+ }
150
+ });
151
+ _defineProperty(this, "parse_tokens", function (line, stop_char) {
152
+ var tokens = new Array();
30
153
  var pos = 0,
31
- recent_token;
32
- while (pos < tokens.length) {
33
- var token = tokens[pos];
34
- if (stop_token) {
35
- if (token.type === stop_token.type && token.value === stop_token.value) break;
154
+ 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
+ };
163
+ line = line.trim();
164
+ 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) {
172
+ pos++;
173
+ continue;
36
174
  }
37
- if (recent_token && token.pos === recent_token.pos) throw new Error("Token recursion: ".concat(token.pos, ", ").concat(token.col, ", ").concat(token.value));
38
- recent_token = token;
39
- var curr_obj = _this.curr_namespace();
40
- var token_obj = (0, _parse_to_obj["default"])(token, curr_obj, {
41
- tokens: tokens,
42
- pos: pos
175
+ if (_char === "\n") {
176
+ line_number++;
177
+ pos++;
178
+ } else if (_char === "@") {
179
+ var acc = "";
180
+ while (line[pos] && line[pos].trim()) {
181
+ acc += line[pos];
182
+ pos++;
183
+ }
184
+ push_token(acc, "address");
185
+ } else if (_char === ",") {
186
+ pos++;
187
+ } else if (_char === ":") {
188
+ push_token(_char, "separator");
189
+ pos++;
190
+ } else if (_char === "[") {
191
+ pos++;
192
+ var toks = _this.parse_tokens(line.slice(pos), "]");
193
+ push_token(toks.tokens, "array");
194
+ pos += toks.pos + 1;
195
+ } else if (_char === "{") {
196
+ 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 === ">") {
201
+ pos++;
202
+ } else if (_char === "'" || _char === '"') {
203
+ var _acc = "";
204
+ pos++;
205
+ while (line[pos] !== _char) {
206
+ if (!line[pos]) break;
207
+ _acc += line[pos];
208
+ pos++;
209
+ }
210
+ pos++;
211
+ push_token(_acc, "string");
212
+ } else if (num_pattern.test(_char)) {
213
+ var _acc2 = _char;
214
+ pos++;
215
+ while (
216
+ num_pattern.test(line[pos]) ||
217
+ (line[pos] === "." && !_acc2.includes(line[pos]))
218
+ ) {
219
+ if (!line[pos]) break;
220
+ _acc2 += line[pos];
221
+ pos++;
222
+ }
223
+ push_token(_acc2, "number");
224
+ } else if (var_pattern.test(_char)) {
225
+ var _acc3 = _char;
226
+ pos++;
227
+ while (line[pos] && var_pattern.test("".concat(line[pos].trim()))) {
228
+ _acc3 += line[pos];
229
+ pos++;
230
+ }
231
+ push_token(
232
+ _acc3,
233
+ _this.opcodes.includes(_acc3) ? "opcode" : "variable"
234
+ );
235
+ }
236
+ }
237
+ return tokens;
238
+ });
239
+ _defineProperty(this, "parse", function (token) {
240
+ 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),
249
+ ]);
250
+ } else if (token.type === "array") {
251
+ _this.push_instruction(
252
+ "link Accounts/".concat(_this.account.name, "/Datatypes/Array")
253
+ );
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)
260
+ ? "{metadata.output:-1}"
261
+ : "{datapath:-1}"
262
+ ),
263
+ ]);
43
264
  });
44
- curr_obj.children.push(token_obj);
45
- var greeds = token_obj.greedy(tokens.slice(pos));
46
- curr_obj.children.splice(-1);
47
- curr_obj.push(greeds.obj);
48
- pos += greeds.pos;
265
+ _this.push_instruction("pop Array");
266
+ } else if (token.type === "twain") {
267
+ _this.push_instruction(
268
+ "link Accounts/".concat(_this.account.name, "/Datatypes/Twain")
269
+ );
270
+ var curs = true;
271
+ if (token.value)
272
+ token.value.map(function (entry) {
273
+ if (entry.type === "separator") {
274
+ curs = false;
275
+ return;
276
+ }
277
+ _this.parse(entry);
278
+ if (curs) {
279
+ {
280
+ _this.push_instruction(
281
+ "cursor {*".concat(
282
+ _this.is_not_literal(entry.type)
283
+ ? "metadata.output:-1"
284
+ : "datapath:-1",
285
+ "}"
286
+ )
287
+ );
288
+ }
289
+ } else {
290
+ _this.push_instruction(
291
+ "write ".concat(
292
+ _this.is_not_literal(entry.type)
293
+ ? "{metadata.output:-1}"
294
+ : "{datapath:-1}"
295
+ )
296
+ );
297
+ curs = true;
298
+ }
299
+ });
300
+ _this.push_instruction("pop Twain");
301
+ } 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),
307
+ ]);
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];
316
+ if (linked || line.type) {
317
+ var line_split = (line.value || line)
318
+ .slice(line.value ? null : 1)
319
+ .trim()
320
+ .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(" "));
326
+ tokens.unshift && tokens.unshift(null);
327
+ if (line.type === "address")
328
+ return _this.push_instruction("pop ".concat(path[path.length - 1]));
329
+ } 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),
335
+ "pop",
336
+ ]);
49
337
  }
50
- stop_token && _this.namestack.pop();
51
- return {
52
- pos: pos
53
- };
338
+ var prev_token;
339
+ if (tokens[1] && tokens[1].type === "opcode") {
340
+ _this.parse_opcode(tokens.slice(1));
341
+ prev_token = tokens[1];
342
+ } else {
343
+ tokens.slice(1).map(function (tok) {
344
+ _this.parse(tok);
345
+ });
346
+ prev_token = tokens.slice(-1)[0];
347
+ }
348
+ if (tokens.length > 1) {
349
+ _this.push_instruction([
350
+ "cursor {output}",
351
+ "write ".concat(
352
+ _this.is_not_literal(prev_token && prev_token.type)
353
+ ? "{metadata.output:-1}"
354
+ : "{datapath:-1}"
355
+ ),
356
+ "pop ".concat(identifier.value),
357
+ ]);
358
+ } else _this.push_instruction("pop ".concat(identifier.value));
54
359
  });
55
- _defineProperty(this, "compile", function (obj) {
56
- obj = obj || _this.globe;
57
- var instructions = new Array();
58
- obj.generate_assembly(instructions);
59
- obj.children = [];
60
- return (0, _format_instructions["default"])(instructions, 1);
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"),
367
+ ]);
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)
374
+ ? "{metadata.output:-1}"
375
+ : "{datapath:-1}"
376
+ ),
377
+ ]);
378
+ });
379
+ _this.push_instruction([
380
+ "pop Twain",
381
+ "cursor inputs",
382
+ "write {datapath:-1}",
383
+ op.value,
384
+ "cursor {output}",
385
+ "write {datapath:-1}",
386
+ "pop ".concat(op.value),
387
+ ]);
61
388
  });
62
- _defineProperty(this, "run", function (code, cb, no_run) {
63
- _this.tokenise(code);
64
- _this.parse();
65
- var payload = {
66
- program: {
67
- instructions: _this.compile()
389
+ _defineProperty(this, "resolve_addr", function (addr) {
390
+ addr = addr.split("/");
391
+ var real_addr = "";
392
+ if (addr[0] === "@") {
393
+ addr[0] = _this.account.physical_address;
394
+ real_addr = addr.join("/");
395
+ } else if (addr[0] === ".." || addr[0] === ".") {
396
+ var curr_addr = _this.stacks.slice(-1)[0].split("/");
397
+ while (addr[0] === ".." || addr[0] === ".") {
398
+ if (addr[0] === "..") curr_addr.splice(-1);
399
+ delete addr[0];
68
400
  }
69
- };
70
- !no_run && _this.account.load(payload, cb);
71
- // console.log(payload.instructions, "hiya");
401
+ real_addr = curr_addr.join("/") + "".concat(addr.join("/"));
402
+ }
403
+ return real_addr;
404
+ });
405
+ _defineProperty(this, "new_stack_instructions", function (new_stack) {
406
+ var curr_stack = _this.stacks.slice(-1)[0].split("/");
407
+ new_stack = new_stack.split("/");
408
+ if (curr_stack[1] !== new_stack[1]) {
409
+ } else {
410
+ var i = 0;
411
+ 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")
416
+ );
417
+ }
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}",
433
+ ]);
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();
446
+ if (!line) continue;
447
+ if (line === ";") _this.pop();
448
+ else if (line.startsWith("link ")) _this.parse_routine(line);
449
+ else if (line.startsWith(".") || line.startsWith("@"))
450
+ _this.parse_routine(line);
451
+ 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);
455
+ }
456
+ });
457
+ _defineProperty(this, "run", function (codes, callback) {
458
+ _this.compile(codes);
459
+
460
+ // console.log(JSON.stringify(this.instructions, null, 2), "hiya");
461
+
462
+ _this.account.load({
463
+ program: {
464
+ instructions: _toConsumableArray(_this.instructions),
465
+ },
466
+ callback: callback,
467
+ });
468
+ _this.instructions = [];
72
469
  });
73
470
  this.account = account;
74
- this.name = this.account.name;
75
- this.globe = new _global["default"](this);
76
- this.namestack = new Array(this.globe);
77
- this.expr_types = ["number", "string", "twain", "array", "boolean", "variable"];
78
- this.datatypes = ["array", "string", "number", "boolean", "twain", "void"];
79
- this.open_parens = "([{";
80
- this.close_parens = ")]}";
471
+ this.opcodes = new Array();
472
+ this.instructions = new Array();
473
+ this.instruction_indexes = new Array();
474
+ this.instruction_stacks = [[]];
475
+ this.stacks = new Array(account.physical_address);
81
476
  });
82
- var _default = Loader_sequence;
83
- exports["default"] = _default;
477
+ var _default = Loader;
478
+ exports["default"] = _default;
@@ -43,13 +43,14 @@ var Account = /*#__PURE__*/function (_Filesystem) {
43
43
  return call_session;
44
44
  });
45
45
  _defineProperty(_assertThisInitialized(_this), "buff", function (block, pid) {
46
- var bf = _this.mine_buffer[pid];
47
- if (!bf) return;
48
- bf.blocks.push(block.stringify());
46
+ var buffer = _this.mine_buffer[pid];
47
+ if (!buffer) return;
48
+ buffer.blocks.push(block.stringify());
49
49
  });
50
50
  _defineProperty(_assertThisInitialized(_this), "flush_buffer", function (pid) {
51
51
  var buff = _this.mine_buffer[pid];
52
- buff.callback && buff.callback(buff.blocks);
52
+ if (!buff) return;
53
+ buff.callback && _this.run_callback(buff.callback, buff.blocks);
53
54
  delete _this.mine_buffer[pid];
54
55
  });
55
56
  _defineProperty(_assertThisInitialized(_this), "load", function (_ref) {
@@ -84,35 +85,37 @@ var Account = /*#__PURE__*/function (_Filesystem) {
84
85
  var data = query ? chain.explore(query) : chain;
85
86
  _this.run_callback(callback, data && data.stringify());
86
87
  });
87
- _defineProperty(_assertThisInitialized(_this), "run", function (_ref3) {
88
- var payload = _ref3.payload,
89
- signature = _ref3.signature,
90
- callback = _ref3.callback;
88
+ _defineProperty(_assertThisInitialized(_this), "run", function (request) {
89
+ var payload = request.payload,
90
+ signature = request.signature,
91
+ callback = request.callback;
91
92
  var physical_address = payload.physical_address,
92
93
  account = payload.account,
93
94
  query = payload.query;
94
95
  account = _this.get_account(account);
95
96
  if (!account.validate(payload, signature)) return;
96
97
  var pid = account.manage_buffer(callback);
97
- var context = physical_address ? _this.manager.web.get({
98
- physical_address: physical_address
99
- }, true) : account.vm.get_context();
98
+ var context = physical_address ? _this.manager.web.get(physical_address) : account.vm.get_context();
100
99
  if (!context) return account.flush_buffer(pid);
101
- var blk = query ? context.explore(query) : context.get_block(0);
102
- if (blk) {
103
- _this.vm.stack.push(blk.hash);
104
- _this.manager.push({
105
- sequence: blk.data,
100
+ var blk = query ? context.explore(query) : context.get_latest_block();
101
+ if (blk && blk.metadata && blk.metadata.program) {
102
+ var program = _this.read(blk.metadata.program);
103
+ account.vm.contexts.push(context);
104
+ program.push("pop");
105
+ Array.isArray(program) && program.length && _this.manager.push({
106
+ sequence: program,
106
107
  account: account,
107
108
  pid: pid
108
109
  });
109
110
  }
110
111
  });
111
112
  _defineProperty(_assertThisInitialized(_this), "run_callback", function (callback, payload) {
112
- if (!callback) return;
113
- if (typeof callback === "function") return callback(payload);
114
- _this.vm.stdin(payload);
115
- callback.physical_address && _this.run(callback);
113
+ setTimeout(function () {
114
+ if (!callback) return;
115
+ if (typeof callback === "function") return callback(payload);
116
+ _this.vm.stdin(payload);
117
+ callback.payload && callback.payload.physical_address && _this.run(callback);
118
+ }, 0);
116
119
  });
117
120
  _defineProperty(_assertThisInitialized(_this), "validate", function (payload, signature) {
118
121
  if (!_this["private"]) return true;
package/Objects/Block.js CHANGED
@@ -49,7 +49,10 @@ var Block = /*#__PURE__*/_createClass(function Block(chain) {
49
49
  chain: ch.chain.hash
50
50
  });
51
51
  });
52
- obj.chain = _this.chain.hash;
52
+ obj.chain = {
53
+ hash: _this.chain.hash,
54
+ physical_address: _this.chain.physical_address
55
+ };
53
56
  return str ? JSON.stringify(obj) : obj;
54
57
  });
55
58
  this.chain = chain;
package/Objects/Chain.js CHANGED
@@ -34,7 +34,12 @@ var Chain = /*#__PURE__*/function (_Explorer) {
34
34
  _this.cursors.push(_this.cursor);
35
35
  _this.cursor = -1;
36
36
  });
37
+ _defineProperty(_assertThisInitialized(_this), "set_cursor", function (cursor) {
38
+ _this.cursor = cursor;
39
+ _this.cursors.push(cursor);
40
+ });
37
41
  _defineProperty(_assertThisInitialized(_this), "get_buffer", function () {
42
+ _this.cursor = _this.cursors.pop();
38
43
  return _this.buffs.slice(-1)[0];
39
44
  });
40
45
  _defineProperty(_assertThisInitialized(_this), "generate_hash", function () {
@@ -64,7 +69,8 @@ var Chain = /*#__PURE__*/function (_Explorer) {
64
69
  return block;
65
70
  });
66
71
  _defineProperty(_assertThisInitialized(_this), "add_block", function (block) {
67
- return _this.blocks.push(block);
72
+ _this.blocks.push(block);
73
+ _this.height = _this.blocks.length;
68
74
  });
69
75
  _defineProperty(_assertThisInitialized(_this), "get_latest_block", function () {
70
76
  return _this.blocks.slice(-1)[0];
@@ -99,6 +105,7 @@ var Chain = /*#__PURE__*/function (_Explorer) {
99
105
  _this.connections = new Array();
100
106
  _this.blocks = new Array();
101
107
  _this.txs = new Array();
108
+ _this.height = 0;
102
109
  _this.cursor = -1;
103
110
  _this.cursors = new Array();
104
111
  _this.buffs = new Array();