godprotocol 1.0.5 → 1.0.6

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 (91) hide show
  1. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  2. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/4e7ba40328eee49c03ebf12bed83a10f42022b10601b9963ee299e50cbde0026/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  3. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  4. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  5. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  6. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  7. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  8. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  9. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  10. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  11. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  12. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  13. package/Accounts/3adda1a6412201ac40ff6a13b2af60f855938088b9a129dd694116f5cf5b86ce/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  14. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  15. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/4e7ba40328eee49c03ebf12bed83a10f42022b10601b9963ee299e50cbde0026/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  16. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  17. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/bd82cf16699be29ec05cbb763199c12f0dced428dde8381dbdd31c1d5dd0e8d4/7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451 +1 -0
  18. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  19. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/46931496c37b22cb91df1929ca4d44b3349c68ec818b37b63dd8583f31e3015b +1 -0
  20. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/4c061633d7fc20f5202cf7d5940b8623c12064c5ede02977e8b5e9e6e7fb9687 +1 -0
  21. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/a20ee8d03f370f8bc61adaf18b681b3e2c4017defd3ad38cb99d2111167ca479 +1 -0
  22. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/ad1e584a505553ddda31fe599dad98fc35a04bd0ff5a654035f85137aa633842 +1 -0
  23. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/bb3d37eee86ecb7262c8ac311a2ddd7f6b9f6298682e348bc784e91511d41638 +1 -0
  24. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/be574e4859c2aba2a2e6a4eb7cf51f006fe2d493ad0268a1f6341e50f0beba90 +1 -0
  25. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f5822a8abd3cb9f230711a1ceac473518a38f8824164c9536ae2d20ca264a385 +1 -0
  26. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f5bbe585b2c9ef9a1dca11d1520b40847dc0858a0da1e509f646963be5d3866b +1 -0
  27. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/cbe4ffe620982478bd99d2d7615b427b5a46617967d6f463a7a4c24c1c29cc84/f08fe7a0bea5233f184c8bcc5bc95da33b35dee7675893d8922e4ec3db70945a/f8127f98684c7e3ab56acdc33af3a3ffe02fbcce9740184d2fa64cc7f3db7fdc +1 -0
  28. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  29. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  30. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/50009ce1da4d15e1c4a04024df691eed5f0d598e2c4c67092f205366d0adf99e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  31. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  32. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54ec06c30de07db57e1/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  33. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  34. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  35. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/de5236ee1561d9d4123d1a8dad5442710ac2acdc26111be2076d9b8ddf453650/74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  36. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  37. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/63d42d26156fcc761e57da4128e9881d5bdf3bf933f0f6e9c93d6e26b9b90ae7/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126 +1 -0
  38. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/63d42d26156fcc761e57da4128e9881d5bdf3bf933f0f6e9c93d6e26b9b90ae7/51a3716d770009c68d68a8f39f912020972c5219187f79f77bdf996e6d3cc530 +1 -0
  39. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/63d42d26156fcc761e57da4128e9881d5bdf3bf933f0f6e9c93d6e26b9b90ae7/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  40. package/Accounts/7c30057a5b553715e58b2187d1345a139341fff921e35abea9837587299472df/fdc8c39bbfa6e5741f75f97112a2c972174ae63b5e0498f56f27b70d512ddd1e/74234e98afe7498fb5daf1f36ac2d78acc339464f950703b8c019892f982b90b +1 -0
  41. package/Aircode/functions/parse_expression.js +117 -0
  42. package/Aircode/functions/parse_to_obj.js +26 -0
  43. package/Aircode/functions/parse_variable.js +35 -0
  44. package/Aircode/functions/tokenise.js +118 -0
  45. package/Aircode/functions/utils.js +11 -0
  46. package/Aircode/keywords/conditional.js +104 -0
  47. package/Aircode/keywords/parse.js +20 -0
  48. package/Aircode/main.js +94 -0
  49. package/Aircode/native_classes/Variable.js +36 -0
  50. package/Aircode/native_classes/datatypes/Number.js +20 -0
  51. package/Aircode/native_classes/datatypes/String.js +20 -0
  52. package/Aircode/native_classes/global.js +21 -0
  53. package/Aircode/native_classes/native.js +23 -0
  54. package/Aircode/native_classes/operators.js +47 -0
  55. package/Aircode/native_classes/parse.js +42 -0
  56. package/Aircode/utils/format_instructions.js +36 -0
  57. package/Aircode/utils/traverse.js +13 -0
  58. package/Index.js +19 -20
  59. package/Objects/Account.js +90 -98
  60. package/Objects/Block.js +45 -0
  61. package/Objects/Blockweb.js +30 -12
  62. package/Objects/Chain.js +96 -0
  63. package/Objects/Explorer.js +18 -62
  64. package/Objects/Filesystem.js +163 -12
  65. package/Objects/Frame.js +11 -1
  66. package/Objects/Manager.js +56 -0
  67. package/Objects/Opcodes.js +13 -17
  68. package/Objects/Oracle.js +35 -0
  69. package/Objects/Virtual_machine.js +72 -70
  70. package/Objects/folder.js +8 -83
  71. package/framer.js +27 -4
  72. package/opcodes/add.js +15 -38
  73. package/opcodes/jmp.js +9 -3
  74. package/opcodes/std.js +5 -0
  75. package/opcodes.js +19 -10
  76. package/package.json +1 -1
  77. package/utils/create_server.js +23 -12
  78. package/utils/hash.js +1 -38
  79. package/utils/services.js +25 -15
  80. package/.keypair +0 -1
  81. package/Datatypes/Array.js +0 -33
  82. package/Datatypes/Number.js +0 -21
  83. package/Datatypes/String.js +0 -23
  84. package/Datatypes/Twain.js +0 -42
  85. package/Objects/Blockchain.js +0 -135
  86. package/Objects/Emitter.js +0 -38
  87. package/Objects/Queries.js +0 -13
  88. package/Objects/file.js +0 -21
  89. package/Socket.js +0 -83
  90. package/index.d.ts +0 -50
  91. package/utils/gen_key_pair.js +0 -36
@@ -0,0 +1,94 @@
1
+ import { parse_expression } from "./functions/parse_expression";
2
+ import tokenise from "./functions/tokenise";
3
+ import { kw_conditional } from "./keywords/conditional";
4
+ import { kw_parse } from "./keywords/parse";
5
+ import Global from "./native_classes/global";
6
+ import format_instructions from "./utils/format_instructions";
7
+
8
+ class Aircode {
9
+ constructor(account) {
10
+ this.account = account;
11
+ this.name = this.account.name;
12
+ this.globe = new Global(this.name);
13
+ this.namestack = new Array(this.globe);
14
+ this.expr_types = [
15
+ "number",
16
+ "string",
17
+ "twain",
18
+ "array",
19
+ "boolean",
20
+ "variable",
21
+ ];
22
+ this.open_parens = "([{";
23
+ this.close_parens = ")]}";
24
+ this.block_keywords = [
25
+ "if",
26
+ "else",
27
+ "else if",
28
+ "fn",
29
+ "class",
30
+ "for",
31
+ "while",
32
+ ];
33
+ }
34
+
35
+ curr_namespace = () => this.namestack.slice(-1)[0];
36
+
37
+ tokenise = (code) => {
38
+ this.tokens = tokenise(code);
39
+ this.tokens.map((t) => (t.compiler = this));
40
+ };
41
+
42
+ parse = (tokens) => {
43
+ if (!tokens) {
44
+ this.globe = new Global(this.name);
45
+ this.namestack[0] = this.globe;
46
+ }
47
+
48
+ tokens = tokens || this.tokens;
49
+ let i = 0;
50
+ let curr_parent = this.curr_namespace();
51
+
52
+ while (i < tokens.length) {
53
+ let token = tokens[i];
54
+
55
+ if (this.expr_types.includes(token.type)) {
56
+ let { obj, pos } = parse_expression(tokens.slice(i), curr_parent, this);
57
+ i += pos;
58
+
59
+ curr_parent.push(obj);
60
+ } else if (token.type === "keyword") {
61
+ if (token.value === "parse") {
62
+ let { obj, pos } = kw_parse(tokens, i, curr_parent, this);
63
+ i = pos;
64
+ curr_parent.push(obj);
65
+ } else if (token.value === "if") {
66
+ let res = kw_conditional(tokens, i, curr_parent, this);
67
+ }
68
+ }
69
+ }
70
+ };
71
+
72
+ compile = (obj, load) => {
73
+ obj = obj || this.globe;
74
+
75
+ let instructions = new Array();
76
+
77
+ obj.generate_assembly(instructions);
78
+
79
+ if (load) this.account.load({ instructions });
80
+
81
+ return format_instructions(instructions, 1);
82
+ };
83
+
84
+ run = (code, no_run) => {
85
+ this.tokenise(code);
86
+ this.parse();
87
+
88
+ let payload = { instructions: this.compile() };
89
+ !no_run && this.account.load(payload);
90
+ /* no_run && */ console.log(payload.instructions);
91
+ };
92
+ }
93
+
94
+ export default Aircode;
@@ -0,0 +1,36 @@
1
+ import Native from "./native";
2
+
3
+ class Variable extends Native {
4
+ constructor(token) {
5
+ super();
6
+
7
+ this.token = token;
8
+ this.name = this.token.value;
9
+ }
10
+
11
+ assign = (obj) => {
12
+ this.assign_obj = obj;
13
+ };
14
+
15
+ generate_assembly = (sequence) => {
16
+ sequence.push(
17
+ this.declaration
18
+ ? `link ${this.declaration.reference_path()}`
19
+ : `chain ${this.name}`
20
+ );
21
+
22
+ if (this.assign_obj) this.assign_obj.generate_assembly(sequence);
23
+ sequence.push(
24
+ ...[
25
+ `cursor type`,
26
+ "write variable",
27
+ "cursor value",
28
+ "write {file.content.output:-1}",
29
+ ]
30
+ );
31
+
32
+ sequence.push(`pop ${this.name}`);
33
+ };
34
+ }
35
+
36
+ export default Variable;
@@ -0,0 +1,20 @@
1
+ import Native from "../native";
2
+
3
+ class Num extends Native {
4
+ constructor(token) {
5
+ super();
6
+
7
+ this.token = token;
8
+ this.name = this.token.value;
9
+ }
10
+
11
+ generate_assembly = (sequence) => {
12
+ sequence.push(
13
+ `link ${this.token.compiler.account.physical_address}/Datatypes/Number`
14
+ );
15
+ sequence.push(`write ${this.name}`);
16
+ sequence.push(`pop Datatypes/Number`);
17
+ };
18
+ }
19
+
20
+ export default Num;
@@ -0,0 +1,20 @@
1
+ import Native from "../native";
2
+
3
+ class Str extends Native {
4
+ constructor(token) {
5
+ super();
6
+
7
+ this.token = token;
8
+ this.name = this.token.value;
9
+ }
10
+
11
+ generate_assembly = (sequence) => {
12
+ sequence.push(
13
+ `link ${this.token.compiler.account.physical_address}/Datatypes/String`
14
+ );
15
+ sequence.push(`write ${this.name}`);
16
+ sequence.push(`pop Datatypes/String`);
17
+ };
18
+ }
19
+
20
+ export default Str;
@@ -0,0 +1,21 @@
1
+ import Native from "./native";
2
+
3
+ class Global extends Native {
4
+ constructor(name) {
5
+ super();
6
+
7
+ this.is_global = true;
8
+ this.name = name;
9
+ this.path = `./${this.name}`;
10
+ }
11
+
12
+ generate_assembly = (sequence) => {
13
+ // sequence.push(`chain ${this.name}`);
14
+
15
+ this.children.map((c) => c.generate_assembly(sequence));
16
+
17
+ // sequence.push(`pop ${this.name}`);
18
+ };
19
+ }
20
+
21
+ export default Global;
@@ -0,0 +1,23 @@
1
+ class Native {
2
+ constructor() {
3
+ this.children = new Array();
4
+ }
5
+
6
+ generate_assembly = (sequence) => {};
7
+
8
+ reference_path = () => {
9
+ return this.path;
10
+ };
11
+
12
+ set_parent = (parent) => {
13
+ this.parent = parent;
14
+ this.path = `${this.parent.path}/${this.name}`;
15
+ };
16
+
17
+ push = (obj) => {
18
+ this.children.push(obj);
19
+ if (obj.set_parent) obj.set_parent(this);
20
+ };
21
+ }
22
+
23
+ export default Native;
@@ -0,0 +1,47 @@
1
+ import Native from "./native";
2
+
3
+ let op_to_name = {
4
+ "+": "add",
5
+ "-": "subtract",
6
+ "/": "divide",
7
+ "*": "multiply",
8
+ };
9
+
10
+ class Operator extends Native {
11
+ constructor(token) {
12
+ super();
13
+
14
+ this.token = token;
15
+ this.name = op_to_name[this.token.value];
16
+ }
17
+
18
+ generate_assembly = (sequence) => {
19
+ sequence.push(
20
+ `link ${this.token.compiler.account.physical_address}/Opcodes/${this.name}`
21
+ );
22
+
23
+ sequence.push(`link Datatypes/Twain`);
24
+ for (let c = 0; c < this.children.length; c++) {
25
+ let child = this.children[c];
26
+ child.generate_assembly(sequence);
27
+ sequence.push(`cursor op${c}`);
28
+ sequence.push(`write {${"datapath"}:-1}`);
29
+ }
30
+ sequence.push("pop");
31
+
32
+ sequence.push(`link Datatypes/Twain`);
33
+ sequence.push("cursor inputs");
34
+ sequence.push(`write ../{metadata:-1}`);
35
+
36
+ sequence.push(this.name);
37
+ sequence.push(`pop Datatypes/Twain`);
38
+
39
+ sequence.push(`cursor {metadata}`);
40
+ sequence.push(`write {metadata:-1}`);
41
+
42
+ sequence.push(`pop Opcodes/${this.name}`);
43
+ };
44
+ }
45
+
46
+ export default Operator;
47
+ export { op_to_name };
@@ -0,0 +1,42 @@
1
+ import Native from "./native";
2
+
3
+ class Parse extends Native {
4
+ constructor(token, obj) {
5
+ super();
6
+
7
+ this.token = token;
8
+ this.obj = obj;
9
+ this.name = "stdout";
10
+ }
11
+
12
+ generate_assembly = (sequence) => {
13
+ sequence.push(
14
+ `link ${this.token.compiler.account.physical_address}/Opcodes/stdout`
15
+ );
16
+
17
+ sequence.push(
18
+ `link ${this.token.compiler.account.physical_address}/Datatypes/Twain`
19
+ );
20
+ this.obj.generate_assembly(sequence);
21
+ sequence.push(`cursor op${0}`);
22
+ sequence.push(`write {${"datapath"}:-1}`);
23
+
24
+ sequence.push("pop");
25
+
26
+ sequence.push(
27
+ `link ${this.token.compiler.account.physical_address}/Datatypes/Twain`
28
+ );
29
+ sequence.push("cursor inputs");
30
+ sequence.push(`write ../{datapath:-1}`);
31
+
32
+ sequence.push(this.name);
33
+ sequence.push(`pop Datatypes/Twain`);
34
+
35
+ sequence.push(`cursor {datapath}`);
36
+ sequence.push(`write {datapath:-1}`);
37
+
38
+ sequence.push(`pop Opcodes/stdout`);
39
+ };
40
+ }
41
+
42
+ export default Parse;
@@ -0,0 +1,36 @@
1
+ class Tree_node {
2
+ constructor(value) {
3
+ this.value = value;
4
+ this.children = [];
5
+ }
6
+
7
+ add_child = (childNode) => {
8
+ this.children.push(childNode);
9
+ };
10
+ }
11
+
12
+ const format_instructions = (instructions, no) => {
13
+ if (no) return instructions;
14
+
15
+ let root = new Tree_node("air");
16
+ let current = root;
17
+ let node_stack = [];
18
+
19
+ instructions.forEach((instruction) => {
20
+ let [opcode, operand] = instruction.split(" ", 2);
21
+
22
+ if (opcode === "chain" || opcode === "link") {
23
+ let new_node = new Tree_node(instruction);
24
+ current.add_child(new_node);
25
+ node_stack.push(current);
26
+ current = new_node;
27
+ } else if (opcode === "pop") {
28
+ current.add_child(instruction);
29
+ current = node_stack.pop();
30
+ } else current.add_child(instruction);
31
+ });
32
+
33
+ return JSON.stringify(root, null, 2);
34
+ };
35
+
36
+ export default format_instructions;
@@ -0,0 +1,13 @@
1
+ const traverse = (parent, obj) => {
2
+ while (true) {
3
+ for (let c = 0; c < parent.children.length; c++) {
4
+ let child = parent.children[c];
5
+
6
+ if (!child.declaration && child.name === obj.name) return child;
7
+ }
8
+ parent = parent.parent;
9
+ if (!parent) break;
10
+ }
11
+ };
12
+
13
+ export { traverse };
package/Index.js CHANGED
@@ -1,32 +1,31 @@
1
1
  import Account from "./Objects/Account";
2
+ import Manager from "./Objects/Manager";
2
3
  import framer from "./framer";
3
4
  import opcodes from "./opcodes";
4
- import Socket_server from "./Socket";
5
- import { manage_key_pair } from "./utils/gen_key_pair";
6
- import create_server, { PORT } from "./utils/create_server";
5
+ import create_server from "./utils/create_server";
7
6
 
8
- manage_key_pair();
7
+ let manager;
9
8
 
10
- const initiator = new Account(process.env.PUBLIC_KEY);
11
- let cli_server = process.env.SERVER;
9
+ const start = (name, server) => {
10
+ if (!manager) manager = new Manager();
12
11
 
13
- if (cli_server) {
14
- initiator.add_server(cli_server);
15
- } else {
16
- // console.warn("set SERVER in your env.");
17
- cli_server = `http://localhost:${PORT}`;
18
- initiator.add_server(cli_server);
19
- }
12
+ let initiator = new Account(name, manager);
20
13
 
21
- framer(initiator);
14
+ create_server(initiator, server);
22
15
 
23
- opcodes(initiator);
16
+ manager.set_intiator(initiator);
24
17
 
25
- let instructions = ["cursor value", "write 7"];
26
- initiator.load({ instructions: ["add"] });
18
+ framer(initiator);
19
+ opcodes(initiator);
27
20
 
28
- create_server(initiator);
21
+ return initiator;
22
+ };
29
23
 
30
- Socket_server();
24
+ let immanuel = start("immanuel");
31
25
 
32
- export { initiator };
26
+ setTimeout(() => {
27
+ immanuel.compiler.run("parse 'Hello'");
28
+ }, 2000);
29
+
30
+ export default start;
31
+ export { manager };
@@ -1,139 +1,131 @@
1
- import { Chain } from "./Blockchain";
1
+ import Aircode from "../Aircode/main";
2
+ import { hash } from "../utils/hash";
3
+ import { post_request } from "../utils/services";
4
+ import Chain from "./Chain";
5
+ import Filesystem from "./Filesystem";
2
6
  import Virtual_machine from "./Virtual_machine";
3
- import fs from "fs";
4
- import Emitter from "./Emitter";
5
7
  import Folder from "./folder";
6
- import Frame from "./Frame";
7
- import File from "./file";
8
- import { hash } from "../utils/hash";
9
8
 
10
- let emitter = new Emitter();
9
+ class Account extends Filesystem {
10
+ constructor(name, manager) {
11
+ super();
11
12
 
12
- class Account {
13
- constructor(name) {
14
13
  this.name = name;
14
+ this.hash = hash(this.name);
15
+ this.manager = manager;
15
16
 
16
- this.path = `./Accounts/${this.name}`;
17
-
18
- this.set_path();
17
+ this.physical_address = `${this.base_address}/${this.name}`;
18
+ this.set_paths();
19
19
 
20
- emitter.listen(this.path, (payload) => {
21
- let { aft } = payload;
22
-
23
- aft && aft(this);
24
- });
25
20
  this.account = this;
21
+ this.compiler = new Aircode(this);
26
22
 
27
- this.chain = new Chain(this);
28
- this.vm = new Virtual_machine(this.chain);
29
23
  this.accounts = new Object();
30
-
31
24
  this.servers = new Array();
32
- this.parents = new Array();
33
-
34
- this.column = 0;
35
- this.folders = new Array();
36
- this.files = new Array();
37
- this.content_buffer = new Array();
38
- }
39
25
 
40
- add_server = (server) => {
41
- this.servers.push(server);
42
- };
43
-
44
- get_column = () => {
45
- return this.column;
46
- };
47
-
48
- set_column = (value) => {
49
- this.column = value;
50
- };
51
-
52
- file = (name) => {
53
- let file = this.files.find((f) => f.name === name);
54
-
55
- if (!file) {
56
- file = new File(name, this);
57
- this.files.push(file);
58
- }
59
-
60
- return file;
61
- };
26
+ this.chain = new Chain(this);
27
+ this.vm = new Virtual_machine(this.chain);
62
28
 
63
- folder = (name, context) => {
64
- let name_hash = hash(name + context.hash);
65
- let folder = this.folders.find((f) => f.hash === name_hash);
66
- if (!folder) {
67
- folder = new Folder(name, this, name_hash);
68
- folder.account = this.account;
29
+ this.manager.oracle.tree[this.physical_address] = this;
69
30
 
70
- this.folders.push(folder);
71
- }
72
- folder.context = context.hash;
31
+ this.chain.generate_hash();
73
32
 
74
- return folder;
75
- };
33
+ this.data_tracks = new Object();
34
+ }
76
35
 
77
- set_path = () => {
78
- !fs.existsSync(this.path) && fs.mkdirSync(this.path, { recursive: true });
36
+ init_folder = (name) => {
37
+ let fold = new Folder(name, this);
38
+ return fold;
79
39
  };
80
40
 
81
- frame = (struct) => {
82
- let frame = new Frame(struct);
83
- frame.to_instruction();
84
-
85
- return frame;
41
+ get_account = (name) => {
42
+ let account = this.accounts[name];
43
+ return account || this;
86
44
  };
87
45
 
88
46
  load = ({ instructions, account }) => {
89
- let mgr = this.get_account(account);
90
-
91
- if (!mgr) this.err(`Account:${account} does not exists!`);
92
- else mgr.vm.push(instructions);
93
- };
94
-
95
- run = (data) => {
96
- let { sequence, account } = data || {};
97
-
98
47
  account = this.get_account(account);
99
48
 
100
- account.vm.push(sequence);
49
+ this.manager.push({ sequence: instructions, account });
101
50
  };
102
51
 
103
- parse = (data) => {
104
- let { sequence, account } = data || {};
105
-
106
- account = this.get_account(account);
52
+ add_server = (server) => {
53
+ if (
54
+ this.servers.find(
55
+ (s) => s.hostname === server.hostname && s.port === server.port
56
+ )
57
+ )
58
+ return;
107
59
 
108
- account.vm.push(sequence);
60
+ this.servers.push(server);
109
61
  };
110
62
 
111
- get_account = (account) => {
112
- if (!account || account === this.name) return this;
63
+ stringify = () => {
64
+ let obj = {};
113
65
 
114
- account = this.accounts[account];
115
- if (!account) return this;
66
+ obj.servers = this.servers;
67
+ obj.name = this.name;
68
+ obj.data_tracks = this.data_tracks;
69
+ };
116
70
 
117
- return account;
71
+ send = (data, cb, one) => {
72
+ if (!data) return;
73
+
74
+ let servers =
75
+ typeof one === "string" ? this.data_tracks[one] : this.servers;
76
+
77
+ data = data.stringify ? data.stringify() : data;
78
+
79
+ let should_break = false;
80
+ if (servers)
81
+ for (let s = 0; s < servers.length; s++) {
82
+ if (should_break) break;
83
+
84
+ let server = servers[s];
85
+
86
+ if (typeof one === "object")
87
+ if (one.hostname !== server.hostname || one.port !== server.port)
88
+ continue;
89
+
90
+ post_request(
91
+ {
92
+ options: {
93
+ ...server,
94
+ path: "/distribute",
95
+ },
96
+ data: JSON.stringify(data),
97
+ },
98
+ (res) => {
99
+ let track = this.data_tracks[data.hash];
100
+ if (!track) {
101
+ track = new Array();
102
+ this.data_tracks[data.hash] = track;
103
+ }
104
+ track.push(server);
105
+
106
+ this.vm.stdin(res);
107
+
108
+ if (typeof one === "boolean") {
109
+ should_break = true;
110
+ }
111
+ }
112
+ );
113
+
114
+ if (one) break;
115
+ }
118
116
  };
119
117
 
120
- create_account = ({ public_key, server }) => {
121
- let account = this.accounts[public_key];
122
- if (!account) {
123
- account = new Account(public_key);
118
+ account = (name, server) => {
119
+ let account = this.accounts[name];
124
120
 
121
+ if (!account) {
122
+ account = new Account(name, this);
125
123
  this.accounts[account.name] = account;
126
124
  }
127
- !account.servers.includes(server) && account.servers.push(server);
128
-
129
- !account.parents.find((p) => p.name === this.name) &&
130
- account.parents.push(this);
125
+ account.add_server(server);
131
126
 
132
127
  return account;
133
128
  };
134
-
135
- get = (opcode) => this[opcode];
136
129
  }
137
130
 
138
131
  export default Account;
139
- export { emitter };
@@ -0,0 +1,45 @@
1
+ class Block {
2
+ constructor(chain) {
3
+ this.chain = chain;
4
+ this.data = this.chain.txs;
5
+ this.metadata = {};
6
+ this.children = new Array();
7
+ }
8
+
9
+ store = () => {
10
+ let content = this.chain.buffs.splice(-1)[0];
11
+ if (!content) return;
12
+
13
+ let cursors = Object.keys(content).filter(
14
+ (c) => c.startsWith("{") && c.endsWith("}")
15
+ );
16
+ for (let c = 0; c < cursors.length; c++) {
17
+ let curs = cursors[c];
18
+
19
+ this.metadata[curs.slice(1, -1)] = content[curs];
20
+ delete content[curs];
21
+ }
22
+
23
+ let datapath = this.chain.parent.save(content);
24
+ this.datapath = datapath;
25
+ };
26
+
27
+ stringify = () => {
28
+ let obj = {};
29
+
30
+ obj.metadata = this.metadata;
31
+ obj.datapath = this.datapath;
32
+ obj.timelapse = this.timelapse;
33
+ obj.index = this.index;
34
+ obj.hash = this.hash;
35
+ obj.data = this.data;
36
+ obj.children = this.children.map(
37
+ (ch) => new Object({ hash: ch.hash, chain: ch.chain.hash })
38
+ );
39
+ obj.chain = this.chain.hash;
40
+
41
+ return obj;
42
+ };
43
+ }
44
+
45
+ export default Block;