godprotocol 1.0.4 → 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 (92) 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 +20 -20
  59. package/Objects/Account.js +90 -91
  60. package/Objects/Block.js +45 -0
  61. package/Objects/Blockweb.js +31 -9
  62. package/Objects/Chain.js +96 -0
  63. package/Objects/Explorer.js +18 -62
  64. package/Objects/Filesystem.js +162 -15
  65. package/Objects/Frame.js +23 -31
  66. package/Objects/Manager.js +56 -0
  67. package/Objects/Opcodes.js +15 -11
  68. package/Objects/Oracle.js +35 -0
  69. package/Objects/Virtual_machine.js +76 -57
  70. package/Objects/folder.js +9 -93
  71. package/framer.js +28 -5
  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 +2 -5
  77. package/utils/create_server.js +24 -12
  78. package/utils/functions.js +8 -0
  79. package/utils/hash.js +2 -36
  80. package/utils/services.js +25 -15
  81. package/.keypair +0 -1
  82. package/Datatypes/Array.js +0 -57
  83. package/Datatypes/Number.js +0 -38
  84. package/Datatypes/String.js +0 -41
  85. package/Datatypes/Twain.js +0 -70
  86. package/Objects/Blockchain.js +0 -141
  87. package/Objects/Emitter.js +0 -38
  88. package/Objects/Queries.js +0 -13
  89. package/Objects/file.js +0 -213
  90. package/Socket.js +0 -83
  91. package/index.d.ts +0 -50
  92. 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,31 +1,31 @@
1
- import http from "http";
2
-
3
1
  import Account from "./Objects/Account";
2
+ import Manager from "./Objects/Manager";
4
3
  import framer from "./framer";
5
4
  import opcodes from "./opcodes";
6
- import Socket_server from "./Socket";
7
- import { manage_key_pair } from "./utils/gen_key_pair";
8
- import create_server, { PORT } from "./utils/create_server";
5
+ import create_server from "./utils/create_server";
6
+
7
+ let manager;
8
+
9
+ const start = (name, server) => {
10
+ if (!manager) manager = new Manager();
9
11
 
10
- manage_key_pair();
12
+ let initiator = new Account(name, manager);
11
13
 
12
- const initiator = new Account(process.env.PUBLIC_KEY);
13
- let cli_server = process.env.SERVER;
14
+ create_server(initiator, server);
14
15
 
15
- if (cli_server) {
16
- initiator.add_server(cli_server);
17
- } else {
18
- // console.warn("set SERVER in your env.");
19
- cli_server = `http://localhost:${PORT}`;
20
- initiator.add_server(cli_server);
21
- }
16
+ manager.set_intiator(initiator);
22
17
 
23
- framer(initiator);
18
+ framer(initiator);
19
+ opcodes(initiator);
24
20
 
25
- opcodes(initiator);
21
+ return initiator;
22
+ };
26
23
 
27
- create_server(initiator);
24
+ let immanuel = start("immanuel");
28
25
 
29
- Socket_server();
26
+ setTimeout(() => {
27
+ immanuel.compiler.run("parse 'Hello'");
28
+ }, 2000);
30
29
 
31
- export { initiator };
30
+ export default start;
31
+ export { manager };
@@ -1,132 +1,131 @@
1
- import { Blockchain } 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
8
 
9
- let emitter = new Emitter();
9
+ class Account extends Filesystem {
10
+ constructor(name, manager) {
11
+ super();
10
12
 
11
- class Account {
12
- constructor(name) {
13
13
  this.name = name;
14
+ this.hash = hash(this.name);
15
+ this.manager = manager;
14
16
 
15
- this.path = `./Accounts/${this.name}`;
17
+ this.physical_address = `${this.base_address}/${this.name}`;
18
+ this.set_paths();
16
19
 
17
- this.set_path();
18
-
19
- emitter.listen(this.path, (payload) => {
20
- let { aft } = payload;
21
-
22
- aft && aft(this);
23
- });
24
20
  this.account = this;
21
+ this.compiler = new Aircode(this);
25
22
 
26
- this.chain = new Blockchain(this);
27
- this.vm = new Virtual_machine(this.chain);
28
23
  this.accounts = new Object();
29
-
30
24
  this.servers = new Array();
31
25
 
32
- this.column = 0;
33
- this.folders = new Array();
34
- this.files = new Array();
35
- }
36
-
37
- add_server = (server) => {
38
- this.servers.push(server);
39
- };
40
-
41
- get_column = () => {
42
- return this.column;
43
- };
44
-
45
- set_column = (value) => {
46
- this.column = value;
47
- };
48
-
49
- get_active_file = () => {
50
- let par = this.vm.get_context().hash;
51
-
52
- let file = this.files.find((f) => f.name === par);
53
-
54
- if (!file) {
55
- file = new File(par, this);
56
- this.files.push(file);
57
- this.active_file = 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) => {
64
- let folder = new Folder(name, this);
65
- folder.account = this;
66
- this.folders.push(folder);
29
+ this.manager.oracle.tree[this.physical_address] = this;
67
30
 
68
- folder.context = this.vm.get_context();
31
+ this.chain.generate_hash();
69
32
 
70
- return folder;
71
- };
33
+ this.data_tracks = new Object();
34
+ }
72
35
 
73
- set_path = () => {
74
- !fs.existsSync(this.path) && fs.mkdirSync(this.path, { recursive: true });
36
+ init_folder = (name) => {
37
+ let fold = new Folder(name, this);
38
+ return fold;
75
39
  };
76
40
 
77
- frame = (struct) => {
78
- let frame = new Frame(struct);
79
- frame.to_instruction();
80
-
81
- return frame;
41
+ get_account = (name) => {
42
+ let account = this.accounts[name];
43
+ return account || this;
82
44
  };
83
45
 
84
46
  load = ({ instructions, account }) => {
85
- let mgr = this.get_account(account);
86
-
87
- if (!mgr) this.err(`Account:${account} does not exists!`);
88
- else mgr.vm.push(instructions);
89
- };
90
-
91
- run = (data) => {
92
- let { sequence, account } = data || {};
93
-
94
47
  account = this.get_account(account);
95
48
 
96
- account.vm.push(sequence);
49
+ this.manager.push({ sequence: instructions, account });
97
50
  };
98
51
 
99
- parse = (data) => {
100
- let { sequence, account } = data || {};
101
-
102
- 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;
103
59
 
104
- account.vm.push(sequence);
60
+ this.servers.push(server);
105
61
  };
106
62
 
107
- get_account = (account) => {
108
- if (!account || account === this.name) return this;
63
+ stringify = () => {
64
+ let obj = {};
109
65
 
110
- account = this.accounts[account];
111
- if (!account) return this;
66
+ obj.servers = this.servers;
67
+ obj.name = this.name;
68
+ obj.data_tracks = this.data_tracks;
69
+ };
112
70
 
113
- 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
+ }
114
116
  };
115
117
 
116
- create_account = ({ public_key, server }) => {
117
- let account = this.accounts[public_key];
118
- if (!account) {
119
- account = new Account(public_key);
118
+ account = (name, server) => {
119
+ let account = this.accounts[name];
120
120
 
121
+ if (!account) {
122
+ account = new Account(name, this);
121
123
  this.accounts[account.name] = account;
122
124
  }
123
- !account.servers.includes(server) && account.servers.push(server);
125
+ account.add_server(server);
124
126
 
125
127
  return account;
126
128
  };
127
-
128
- get = (opcode) => this[opcode];
129
129
  }
130
130
 
131
131
  export default Account;
132
- 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;