godprotocol 1.0.842 → 1.1.0

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 (64) hide show
  1. package/Executables/callables.js +131 -0
  2. package/Executables/executables.js +230 -0
  3. package/Executables/functions/adminstrator/adm_register.js +29 -0
  4. package/Executables/functions/adminstrator/native_components.js +10 -0
  5. package/Executables/functions/adminstrator/query_selectors.js +10 -0
  6. package/Executables/functions/adminstrator/render.js +24 -0
  7. package/Executables/functions/array_register.js +161 -0
  8. package/Executables/functions/assign.js +19 -0
  9. package/Executables/functions/display.js +55 -0
  10. package/Executables/functions/folder.js +95 -0
  11. package/Executables/functions/folder_register.js +87 -0
  12. package/Executables/functions/importcheck.js +13 -0
  13. package/Executables/functions/indices.js +56 -0
  14. package/Executables/functions/len.js +22 -0
  15. package/Executables/functions/methods/array.js +272 -0
  16. package/Executables/functions/methods/string.js +197 -0
  17. package/Executables/functions/methods/twain.js +148 -0
  18. package/Executables/functions/op.js +15 -0
  19. package/Executables/functions/price_register.js +30 -0
  20. package/Executables/functions/pricing.js +26 -0
  21. package/Executables/functions/servers/account.js +81 -0
  22. package/Executables/functions/servers/account_register.js +56 -0
  23. package/Executables/functions/servers/block.js +21 -0
  24. package/Executables/functions/servers/block_register.js +18 -0
  25. package/Executables/functions/servers/chain.js +42 -0
  26. package/Executables/functions/servers/chain_register.js +28 -0
  27. package/Executables/functions/set_error_catch.js +34 -0
  28. package/Executables/functions/string_register.js +130 -0
  29. package/Executables/functions/twain_register.js +56 -0
  30. package/Executables/functions/typecast.js +43 -0
  31. package/Executables/functions/utils.js +9 -0
  32. package/Executables/stack.js +53 -0
  33. package/Index.js +2 -55
  34. package/Loader_sequence/main.js +371 -124
  35. package/Loader_sequence/repository.js +1 -1
  36. package/Objects/Account.js +101 -34
  37. package/Objects/Block.js +24 -18
  38. package/Objects/Blockweb.js +1 -1
  39. package/Objects/Chain.js +127 -29
  40. package/Objects/Explorer.js +3 -17
  41. package/Objects/Fee.js +33 -0
  42. package/Objects/Filesystem.js +98 -25
  43. package/Objects/Frame.js +10 -3
  44. package/Objects/Manager.js +193 -23
  45. package/Objects/Opcodes.js +48 -10
  46. package/Objects/Oracle.js +11 -8
  47. package/Objects/Protocol.js +5 -0
  48. package/Objects/Virtual_machine.js +130 -59
  49. package/Trinity.js +20 -0
  50. package/callables.js +172 -0
  51. package/framer.js +65 -12
  52. package/opcodes/add.js +6 -1
  53. package/opcodes/indices.js +60 -6
  54. package/opcodes/jmp.js +2 -0
  55. package/opcodes/std.js +5 -2
  56. package/opcodes.js +56 -18
  57. package/package.json +2 -2
  58. package/starter_scripts/constants.seq +11 -0
  59. package/utils/create_server.js +15 -7
  60. package/utils/hash.js +2 -2
  61. package/utils/logger.js +79 -0
  62. package/utils/services.js +5 -3
  63. package/utils/type_coersion.js +3 -0
  64. package/utils/vm_utils.js +292 -0
@@ -6,60 +6,123 @@ class Virtual_machine extends Opcodes {
6
6
 
7
7
  this.account = context.account;
8
8
  this.contexts = [context];
9
- this.stack = new Array();
10
9
  this.flags = {
11
10
  neg: false,
12
11
  equal: false,
13
12
  zero: false,
14
13
  void: false,
15
14
  };
15
+
16
+ this.stacktrace = new Array()
17
+
18
+ this.error_manager = new Object()
16
19
  }
20
+
21
+ push_int = (name, payload)=>{
22
+ let stacks = this.error_manager[name]
23
+ if (!stacks){
24
+ stacks = new Array()
25
+ this.error_manager[name] = stacks;
26
+ }
17
27
 
18
- get_context = (index) => {
19
- return this.contexts.slice(index == null ? -1 : index)[0];
20
- };
28
+ stacks.push(payload)
29
+ }
21
30
 
22
- parse_arg = (arg, is_cursor) => {
23
- let context = this.get_context();
31
+ quit = (payload)=>{
32
+ let instruction = this.track.sequence[this.track.pointer-1]
33
+ if(instruction==='ret'){
34
+ this.account.buff({ret:payload.op0}, this.track.pid)
35
+ }
24
36
 
25
- let args = arg.split("/"),
26
- i = 0;
37
+ this.account.flush_buffer(this.track.pid, payload);
38
+ this.track.pointer = this.track.sequence.length;
39
+ this.pop_context()
40
+ }
27
41
 
28
- while (args[0] === "..") {
29
- i++;
42
+ stderr = (err_object)=>{
43
+ console.log(err_object)
44
+ let{name, message} = err_object;
30
45
 
31
- args.splice(0, 1);
46
+ if (!name){
47
+ return this.quit(err_object)
32
48
  }
33
49
 
34
- i = (i + 1) * -1;
35
- context = i ? this.get_context(i) : context;
50
+ let all = this.error_manager['*']
51
+ let stacks = this.error_manager[name]
52
+
53
+ if (!stacks){
54
+ if(all){
55
+ all = all.slice(-1)[0]
56
+ let object = this.read_chain(`${this.error_instance_address}/${name}_`)
57
+ stacks = [{object, metadata: all.metadata, catch_pointer: all.catch_pointer}]
58
+
59
+ if(!object)return this.quit({message: `Unknown Error instance - ${name}`})
60
+ }
61
+
62
+ if (!stacks)
63
+ return this.quit(err_object)
64
+ }else if(all){
65
+ // Check precedence within all and stacks name, how?
66
+ }
36
67
 
37
- arg = args.join("/");
68
+ let obj_payload, s;
69
+ for(s = this.stacktrace.length - 1; s >= 0; s--){
70
+ let trace = this.stacktrace[s]
71
+ let should_break;
38
72
 
39
- while (arg.includes("^")) {
40
- let blk = context.connections.slice(-1)[0];
41
- if (!blk) break;
42
- context = blk.chain;
43
- let i = arg.indexOf("^");
44
- arg = `${arg.slice(0, i)}${arg.slice(i + 1)}`;
73
+ for (let t = stacks.length-1; t >= 0; t--){
74
+ obj_payload = stacks[t]
75
+ if(obj_payload.metadata.namespace === trace){
76
+ should_break = true
77
+ break;
78
+ }
79
+ }
80
+ if (should_break) break;
45
81
  }
46
82
 
47
- if (arg.startsWith("{*") && is_cursor) {
48
- arg = context.explore(arg.slice(2, -1));
49
- } else if (arg.startsWith("{") && !is_cursor) {
50
- arg = context.explore(arg.slice(1, -1));
51
- }
52
83
 
53
- return arg;
54
- };
84
+ if (!obj_payload){
85
+ return this.quit(err_object)
86
+ }
55
87
 
56
- split_instruction = (instruction) => {
57
- let split = instruction.split(" ");
58
- let opcode = split[0],
59
- args = split.slice(1).join(" ");
88
+ if(obj_payload.metadata.alias){
89
+ // Instantiate error message as an aircode string object.
90
+ let message_string = `${obj_payload.metadata.namespace}/${this.id_hash(
91
+ message
92
+ )}`;
93
+ this.air_object(message, {
94
+ location: message_string,
95
+ callback: () => {
96
+ this.exec({
97
+ executable: obj_payload.object.set_message,
98
+ location: obj_payload.metadata.alias,
99
+ metadata: {
100
+ callback: () => {
101
+ this.slice_trace(s+1)
102
+
103
+ this.track = this.account.manager.set_track({account: this.account.name, physical_address: obj_payload.metadata.namespace, pointer: obj_payload.catch_pointer}, true)
104
+ },
105
+ },
106
+ arguments: {
107
+ argv: [
108
+ {
109
+ address: message_string,
110
+ position: 0,
111
+ },
112
+ ],
113
+ argc: 1,
114
+ },
115
+ });
116
+ },
117
+ });
118
+
119
+ }else {
120
+ this.slice_trace(s-3)
121
+
122
+ this.track = this.account.manager.set_track({account: this.account.name, physical_address: obj_payload.metadata.namespace, pointer: obj_payload.catch_pointer}, true)
60
123
 
61
- return { opcode, args };
62
- };
124
+ }
125
+ }
63
126
 
64
127
  execute = (instruction, track) => {
65
128
  this.track = track;
@@ -68,22 +131,26 @@ class Virtual_machine extends Opcodes {
68
131
 
69
132
  let { opcode, args } = this.split_instruction(instruction);
70
133
 
71
- let context = this.get_context();
134
+ let context = this.get_context(-1);
72
135
 
73
136
  if (!context) return;
74
137
 
75
138
  context.add_tx(instruction);
76
139
 
77
- // console.log(instruction);
140
+ // console.log(`(${track.pointer}/${track.sequence.length})>> ${instruction}`)
141
+ // this.account.log_output(`>> ${instruction}`);
78
142
 
79
143
  let chain;
80
144
 
81
- args = this.parse_arg(args, opcode === "cursor");
145
+ args = this.parse_arg(args, opcode);
82
146
 
83
147
  switch (opcode) {
84
148
  case "chain":
85
- chain = context.account.add_chain(args, context);
86
- this.contexts.push(chain);
149
+ chain = this.handle_chain(args, context)
150
+
151
+ if(!chain)return this.stderr(`Chain error - ${args}`)
152
+
153
+ this.push_context(chain);
87
154
 
88
155
  let dim = context.folder.config.dimensions;
89
156
  if (!dim) {
@@ -96,28 +163,15 @@ class Virtual_machine extends Opcodes {
96
163
 
97
164
  break;
98
165
  case "link":
99
- chain = context.account.manager.web.get(args);
166
+ chain = this.handle_chain(args, context)
100
167
 
101
168
  if (!chain) {
102
- this.account.flush_buffer(this.track.pid, {
103
- error: true,
104
- error_message: `LINKing Failed. - ${args}`,
105
- });
106
- this.track.pointer = this.track.sequence.length;
107
-
108
- console.log(`LINKing Failed. - ${args}`);
109
- return;
169
+ return this.stderr(`LINKing Failed. - ${args}`)
110
170
  }
111
171
 
112
172
  chain.append_buffer();
113
173
 
114
- this.contexts.push(chain);
115
-
116
- break;
117
- case "mine":
118
- let bloc = context.mine(this, true);
119
-
120
- this.account.buff(bloc, this.track.pid);
174
+ this.push_context(chain);
121
175
 
122
176
  break;
123
177
  case "pop":
@@ -125,14 +179,31 @@ class Virtual_machine extends Opcodes {
125
179
  if (context.txs.length > 1) {
126
180
  blk = context.mine(this);
127
181
  } else {
128
- blk = context.get_latest_block();
129
- if (blk) this.get_context(-2).connections.push(blk);
130
-
131
- context.txs = [];
182
+ if (this.account.initiated&& this.account.is_datatype(context)){
183
+ blk= context.mine(this)
184
+ }else {
185
+ blk = context.get_latest_block();
186
+ if(!blk || context.datapath){
187
+ if(context.datapath){
188
+ blk = context.fabricate_datapath_block()
189
+ }else blk = this.get_voided_block()
190
+ }
191
+
192
+ if (blk){
193
+ if (blk.chain.physical_address!== `${this.account.physical_address}/Datatypes/Void`) this.flags.void = false
194
+
195
+ this.get_context(-2).connections.push(blk);
196
+ }
197
+
198
+ context.get_buffer()
199
+ context.txs = [];
200
+ }
201
+
132
202
  }
203
+
133
204
  blk && this.account.buff(blk, this.track.pid);
134
205
 
135
- this.contexts.pop();
206
+ this.pop_context();
136
207
  break;
137
208
  case "cursor":
138
209
  context.set_cursor(args);
package/Trinity.js ADDED
@@ -0,0 +1,20 @@
1
+ import create_server from "./utils/create_server"
2
+ import Manager from "./Objects/Manager";
3
+
4
+ class Trinity{
5
+ constructor(){
6
+ this.manager = new Manager()
7
+ }
8
+
9
+ create_server = (app, settings)=>{
10
+ settings = settings||{}
11
+ create_server(app, {...settings, manager: this.manager})
12
+ }
13
+
14
+ account= name=>this.manager.get_account(name)
15
+
16
+ add_account = (name, meta) =>this.manager.add_account(name, meta)
17
+ }
18
+
19
+
20
+ export default Trinity
package/callables.js ADDED
@@ -0,0 +1,172 @@
1
+ import { get, set } from "./Executables/functions/indices";
2
+ import { display } from "./Executables/functions/display";
3
+ import typecast from "./Executables/functions/typecast";
4
+ import { ops } from "./opcodes/add";
5
+ import operation from "./Executables/functions/op";
6
+ import assign from "./Executables/functions/assign";
7
+ import importcheck from "./Executables/functions/importcheck";
8
+ import set_error_catch from "./Executables/functions/set_error_catch";
9
+ import string_register from "./Executables/functions/string_register";
10
+ import array_register from "./Executables/functions/array_register";
11
+ import twain_register from "./Executables/functions/twain_register";
12
+ import price_register from "./Executables/functions/price_register";
13
+ import folder_register from "./Executables/functions/folder_register";
14
+ import chain_register from "./Executables/functions/servers/chain_register";
15
+ import block_register from "./Executables/functions/servers/block_register";
16
+ import account_register from "./Executables/functions/servers/account_register";
17
+ import len from "./Executables/functions/len";
18
+ import { get_address, get_id } from "./Executables/functions/utils";
19
+ import adm_register from "./Executables/functions/adminstrator/adm_register";
20
+
21
+ const callables = account => {
22
+ let add_callable= account.vm.add_callable;
23
+
24
+ chain_register(account)
25
+ block_register(account)
26
+ account_register(account)
27
+ price_register(account)
28
+ folder_register(account)
29
+ string_register(account)
30
+ array_register(account)
31
+ twain_register(account)
32
+ adm_register(account)
33
+
34
+ add_callable('read_chain', {
35
+ callable:(args, vm, options)=> {
36
+ let res = account.vm.read_chain(args.address, args.options)
37
+
38
+ if (typeof options.location === 'string'){
39
+ vm.write_chain(res, options.location)
40
+ }
41
+ return res;
42
+ },
43
+ config: {
44
+ parameters: [
45
+ {name:'address', position:0,},
46
+ {name: 'options', position:1}
47
+ ]
48
+ }
49
+ })
50
+
51
+
52
+ add_callable('air_object', {
53
+ callable: (args, vm, options)=>{
54
+ vm.air_object(args.literal, options)
55
+ },
56
+ config:{
57
+ parameters: [
58
+ {name:'literal', position:0,}
59
+ ]
60
+ }
61
+ })
62
+
63
+ add_callable('display', {
64
+ callable: display,
65
+ config: {
66
+ parameters: [
67
+ {name:'data', position:0, spread: true}
68
+ ]
69
+ }
70
+ })
71
+
72
+ add_callable('importcheck', {
73
+ callable: importcheck,
74
+ config: {
75
+ parameters: [
76
+ {name:'address', position:0},
77
+ {name:'names', position:1, spread: true}
78
+ ]
79
+ }
80
+ })
81
+
82
+ add_callable('set_error_catch', {
83
+ callable: set_error_catch,
84
+ config: {
85
+ parameters: [
86
+ {name:'object', position:0},
87
+ {name:'metadata', position:1},
88
+ ]
89
+ }
90
+ })
91
+
92
+ add_callable('set', {
93
+ callable: set,
94
+ config: {
95
+ parameters: [
96
+ {name:'obj', position:0, },
97
+ {name:'prop', position:1, },
98
+ {name:'value', position:2, },
99
+ ]
100
+ }
101
+ })
102
+
103
+ add_callable('get', {
104
+ callable: get,
105
+ config: {
106
+ parameters: [
107
+ {name:'obj', position:0, },
108
+ {name:'prop', position:1, }
109
+ ]
110
+ }
111
+ })
112
+
113
+ add_callable('typecast', {
114
+ callable: typecast,
115
+ config: {
116
+ parameters: [
117
+ {name:'obj', position:0, },
118
+ {name:'type', position:1, }
119
+ ]
120
+ }
121
+ })
122
+
123
+ add_callable('assign', {
124
+ callable: assign,
125
+ config: {
126
+ parameters: [
127
+ {name:'value', position:0, }
128
+ ]
129
+ }
130
+ })
131
+
132
+ add_callable('get_address', {
133
+ callable: get_address,
134
+ config: {
135
+ parameters: [
136
+ {name:'object', position:0, }
137
+ ]
138
+ }
139
+ })
140
+
141
+ add_callable('get_id', {
142
+ callable: get_id,
143
+ config: {
144
+ parameters: [
145
+ {name:'object', position:0, }
146
+ ]
147
+ }
148
+ })
149
+
150
+ add_callable('len', {
151
+ callable: len,
152
+ config: {
153
+ parameters: [
154
+ {name:'object', position:0, }
155
+ ]
156
+ }
157
+ })
158
+
159
+ ops.map(op=>{
160
+ add_callable(`__${op.name}__`, {
161
+ callable: (args, vm, options)=> operation(args, vm, {...options, op: op.name}),
162
+ config: {
163
+ parameters: [
164
+ {name:'left', position:0},
165
+ {name:'right', position:1}
166
+ ]
167
+ }
168
+ })
169
+ })
170
+ }
171
+
172
+ export default callables;
package/framer.js CHANGED
@@ -29,6 +29,8 @@ let obj = {
29
29
  String: null,
30
30
  Twain: null,
31
31
  Array: null,
32
+ Void: null,
33
+ Boolean: null,
32
34
  },
33
35
  Objects: {
34
36
  Blockchain: {
@@ -47,24 +49,75 @@ let obj = {
47
49
  write: null,
48
50
  },
49
51
  },
52
+ CONSTANTS:{
53
+ overload: {
54
+ __add__: {__type:'twain', value: {type:'string', static_value:'__add__'}},
55
+ __multiply__: {__type:'twain', value: {type:'string', static_value:'__multiply__'}},
56
+ __subtract__: {__type:'twain', value: {type:'string', static_value:'__subtract__'}},
57
+ __divide__: {__type:'twain', value: {type:'string', static_value:'__divide__'}},
58
+ __exp__: {__type:'twain', value: {type:'string', static_value:'__exp__'}},
59
+ __equal__: {__type:'twain', value: {type:'string', static_value:'__equal__'}},
60
+ // __not_equal__: {__type:'twain', value: {type:'string', static_value:'__not_equal__'}},
61
+ __lt__: {__type:'twain', value: {type:'string', static_value:'__lt__'}},
62
+ __lte__: {__type:'twain', value: {type:'string', static_value:'__lte__'}},
63
+ __gt__: {__type:'twain', value: {type:'string', static_value:'__gt__'}},
64
+ __gte__: {__type:'twain', value: {type:'string', static_value:'__gte__'}},
65
+ },
66
+ types: {
67
+ instance: {__type: 'twain', value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/instance`, static_value: 'instance'}},
68
+ function: {__type:'string', value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/function`, static_value: 'function'}},
69
+ boolean: {__type:'string',value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/boolean`, static_value: 'boolean'}},
70
+ array: {__type:'string',value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/array`, static_value: 'array'}},
71
+ twain: {__type:'string',value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/twain`, static_value: 'twain'}},
72
+ number: { __type:'string', value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/number`, static_value: 'number'}},
73
+ string: {__type:'string', value: {type:'string', __address__:`Accounts/initiator/CONSTANTS/types/string`, static_value: 'string'}},
74
+ }
75
+ },
50
76
  };
51
77
 
52
78
  const framer = (initiator, cb) => {
53
79
  let frame = new Frame(obj);
54
- frame.to_instruction();
55
- let instructions = frame.flatten_instructions();
56
-
80
+ frame.account = initiator;
57
81
  let start = Date.now();
58
- initiator.load({
59
- program: { instructions },
60
- callback: (blks) => {
61
- console.log(
62
- `Account:${initiator.name} is ready in ${Date.now() - start}ms.`
63
- );
64
82
 
65
- cb && cb(blks);
66
- },
67
- });
83
+ let callback = (blks) => {
84
+ console.log(
85
+ `Account:${initiator.name} is ready in ${Date.now() - start}ms.`
86
+ );
87
+
88
+ initiator.initiated = true
89
+
90
+ cb&&cb(blks)
91
+ }
92
+
93
+ /* Quick due diligence */
94
+ let oracle = initiator.manager.oracle,
95
+ obj_hash = oracle.hash(obj),
96
+ globals = oracle.gds.folder('globals'),
97
+ quick_hashes = globals.readone({title:'quick_hashes'});
98
+
99
+ if(!quick_hashes){
100
+ quick_hashes = {title:"quick_hashes"}
101
+ let res = globals.write(quick_hashes)
102
+ quick_hashes._id = res._id
103
+ quick_hashes.created = res.created
104
+ }
105
+ if(quick_hashes.frame === obj_hash){
106
+ setTimeout(() => {
107
+ callback([])
108
+ }, 0);
109
+ }else {
110
+ frame.to_instruction();
111
+ let instructions = frame.flatten_instructions();
112
+
113
+ initiator.load({
114
+ program: { instructions },
115
+ callback,
116
+ });
117
+ globals.update({_id:quick_hashes._id}, {frame: obj_hash})
118
+ }
119
+
120
+
68
121
  };
69
122
 
70
123
  export default framer;
package/opcodes/add.js CHANGED
@@ -4,7 +4,12 @@ let ops = [
4
4
  { name: "subtract", sign: "-" },
5
5
  { name: "divide", sign: "/" },
6
6
  { name: "exp", sign: "**" },
7
- { name: "equal", sign: "==" },
7
+ { name: "equal", sign: "==", jmp:true},
8
+ { name: "not_equal", sign: "!=", jmp:true},
9
+ { name: "gt", sign: ">",jmp:true },
10
+ { name: "lt", sign: "<", jmp:true },
11
+ { name: "lte", sign: "<=" , jmp:true},
12
+ { name: "gte", sign: ">=", jmp:true },
8
13
  ];
9
14
 
10
15
  export { ops };
@@ -1,5 +1,9 @@
1
1
  const getter = (args) => {
2
2
  let base = args.op0;
3
+
4
+ // console.log(args, 'getter.args')
5
+ if(!base)return base === ''?null: base
6
+
3
7
  if (typeof base === "number") return base;
4
8
 
5
9
  if (typeof base === "string") return base[args.op1];
@@ -9,20 +13,70 @@ const getter = (args) => {
9
13
  return base[args.op1];
10
14
  };
11
15
 
12
- const setter = (args) => {
16
+ const setter = (args, vm) => {
13
17
  let base = args.op0;
18
+
14
19
  if (typeof base === "number") return base;
15
20
 
21
+ if(vm.is_readonly(args))return;
22
+
16
23
  if (typeof base === "string") {
17
- base = `${base.slice(0, args.op2)}${args.op1}${base.slice(args.op2 + 1)}`;
24
+ if (args.op1 ===0 && base.length <= 1){
25
+ base = `${args.op2}${base}`
26
+ } else if (args.op1 ===-1){
27
+ base = `${base}${args.op2}`
28
+ } else base = `${base.slice(0, args.op1)}${args.op2}${base.slice(args.op1)}`;
18
29
  } else {
19
30
  if (Array.isArray(base)) {
20
- if (args.op2 == null || args.op2 >= base.length) base.push(args.op1);
21
- else base[args.op2] = args.op1;
22
- } else base[args.op2] = args.op1;
31
+ if (args.op1<0|| args.op1 == null || args.op1 >= base.length) base.push(args.op2);
32
+ else base[args.op1] = args.op2;
33
+ } else base[args.op1] = args.op2;
23
34
  }
24
35
 
25
36
  return base;
26
37
  };
27
38
 
28
- export { setter, getter };
39
+ const del = (args, vm)=>{
40
+ let base = args.op0
41
+
42
+ if (typeof base === 'number')return;
43
+
44
+ if(vm.is_readonly(args))return;
45
+
46
+ if (typeof base === 'string'){
47
+ if (args.op1 === 0){
48
+ base = base.slice(1)
49
+ }else if (args === -1){
50
+ base = base.slice(0, -1)
51
+ }else {
52
+ base = `${base.slice(0, args.op1)}${base.slice(args.op1+1)}`
53
+ }
54
+ }
55
+ else {
56
+ if (Array.isArray(base)){
57
+ base.splice(args.op1, 1)
58
+ }else delete base[args.op1]
59
+ }
60
+ return base;
61
+ }
62
+
63
+ const slice = (args, vm)=>{
64
+ let obj = args.op0
65
+ let indexes = args.op1
66
+ if (!Array.isArray(indexes))return vm.stderr(`Indexes must be an array`)
67
+
68
+ let res;
69
+
70
+ if (typeof obj === 'number' ||!obj)return null;
71
+
72
+ if (typeof obj === 'object' && !Array.isArray(obj)){
73
+ res = {}
74
+ indexes.map(i=>{
75
+ res[i] = obj[i]
76
+ })
77
+ }else res = obj.slice(indexes[0], indexes[1])
78
+
79
+ return res;
80
+ }
81
+
82
+ export { setter, getter , del, slice};
package/opcodes/jmp.js CHANGED
@@ -8,6 +8,8 @@ const jmp = (args, vm, meta) => {
8
8
 
9
9
  if ((condition || !flag) && typeof args.op0 === "number") {
10
10
  vm.track.pointer = args.op0;
11
+
12
+ vm.pop_context()
11
13
  }
12
14
  };
13
15
 
package/opcodes/std.js CHANGED
@@ -1,9 +1,12 @@
1
1
  const stdout = (args, vm) => {
2
2
  if (!args) return;
3
3
 
4
- vm.account.stdout.push({ data: args, pid: vm.track.pid });
4
+ args&& args.op0&& vm.account.stdout.push({ data: args, pid: vm.track.pid });
5
5
 
6
- for (let v in args) console.log(args[v]);
6
+ let logs = []
7
+ for (let v in args) logs.push(args[v].static_value == null ? null :args[v].static_value);
8
+
9
+ console.log(...logs)
7
10
  };
8
11
 
9
12
  export { stdout };