godprotocol 1.1.32 → 1.2.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.
- package/Datatypes/arr.js +559 -254
- package/Datatypes/bool.js +8 -5
- package/Datatypes/callable.js +1 -1
- package/Datatypes/cls.js +193 -24
- package/Datatypes/conf.js +2 -2
- package/Datatypes/err.js +25 -0
- package/Datatypes/func.js +89 -13
- package/Datatypes/functions/storage.js +572 -12
- package/Datatypes/functions/wallet.js +49 -0
- package/Datatypes/instance.js +87 -122
- package/Datatypes/num.js +192 -153
- package/Datatypes/str.js +188 -122
- package/Datatypes/twa.js +346 -71
- package/Datatypes/voi.js +9 -4
- package/Index.js +1 -1
- package/Instances/account.js +0 -0
- package/Instances/event.js +0 -0
- package/Instances/fold.js +103 -0
- package/Instances/folder_queries.js +46 -0
- package/Instances/response.js +31 -0
- package/Objects/Account.js +160 -110
- package/Objects/Blockweb.js +6 -11
- package/Objects/Callable.js +223 -188
- package/Objects/Chain.js +127 -142
- package/Objects/Datatypes.js +114 -588
- package/Objects/Manager.js +349 -39
- package/Objects/Oracle.js +283 -210
- package/Objects/Repository.js +12 -33
- package/Objects/Trinity.js +9 -7
- package/Objects/Utils.js +8 -8
- package/Objects/Virtual_machine.js +320 -320
- package/README.md +0 -0
- package/callables/functions/assert.js +10 -0
- package/callables/functions/display.js +2 -3
- package/callables/functions/env.js +5 -0
- package/callables/functions/event.js +14 -0
- package/callables/functions/exit.js +3 -2
- package/callables/functions/folder.js +15 -0
- package/callables/functions/get_uid.js +6 -0
- package/callables/functions/hash.js +7 -0
- package/callables/functions/import_.js +62 -0
- package/callables/functions/local.js +9 -0
- package/callables/functions/net.js +33 -18
- package/callables/functions/parse.js +35 -0
- package/callables/functions/query.js +12 -0
- package/callables/functions/render.js +9 -13
- package/callables/functions/servers.js +10 -0
- package/callables/functions/spawn.js +7 -0
- package/callables/functions/store.js +75 -0
- package/callables/functions/super_.js +24 -0
- package/callables/functions/typeof.js +32 -0
- package/callables/functions/wait.js +9 -0
- package/callables/register.js +193 -8
- package/html/create.js +110 -0
- package/html/index.js +114 -0
- package/html/load.js +165 -0
- package/html/parse.js +171 -0
- package/html/run.js +151 -0
- package/html/util.js +5 -0
- package/package.json +5 -3
- package/repos/fs.js +114 -0
- package/repos/github.js +73 -0
- package/repos/ram.js +47 -0
- package/utils/create_server.js +66 -26
- package/utils/hash.js +3 -2
- package/utils/ops.js +2 -0
- package/utils/oracle_handlers.js +7 -0
- package/utils/services.js +18 -51
- package/utils/socket_server.js +36 -0
- package/utils/vm_utils.js +241 -137
- package/callables/functions/assign.js +0 -6
|
@@ -1,376 +1,376 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Ram from "godprotocol/repos/ram.js";
|
|
2
|
+
import Callable from "./Callable.js";
|
|
2
3
|
|
|
3
4
|
class Virtual_machine extends Callable {
|
|
4
5
|
constructor(account) {
|
|
5
6
|
super();
|
|
6
7
|
|
|
8
|
+
this.envs = new Object()
|
|
7
9
|
this.account = account;
|
|
8
|
-
this.contexts = new Array();
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
let oracle = this.account.manager.oracle;
|
|
16
|
-
|
|
17
|
-
let result = await oracle.read(addr, { current: true, config: true });
|
|
18
|
-
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
12
|
+
nodelist = async(config, options={}) => {
|
|
13
|
+
let {call, list} = options
|
|
14
|
+
list = list || new Array()
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
const flatten = async (config, no_call) =>{
|
|
17
|
+
if (typeof config === 'string'){
|
|
18
|
+
config = await this.read_config(config)
|
|
19
|
+
}
|
|
20
|
+
switch(config.type){
|
|
21
|
+
case 'module':
|
|
22
|
+
for (let b=0; b< config.body.length; b++){
|
|
23
|
+
let bdy = config.body[b]
|
|
24
|
+
config.body[b] = await flatten(bdy)
|
|
25
|
+
}
|
|
26
|
+
list.push(config)
|
|
27
|
+
return list
|
|
28
|
+
break
|
|
29
|
+
case 'function':
|
|
30
|
+
if (call && !no_call){
|
|
31
|
+
for (let p=0; p < config.parameters.length; p++){
|
|
32
|
+
let param = config.parameters[p]
|
|
33
|
+
param.location = `${config.address}/${param.identifier}`
|
|
34
|
+
config.parameters[p] = await flatten(param)
|
|
35
|
+
}
|
|
36
|
+
for (let b=0; b < config.body.length; b++){
|
|
37
|
+
let bdy = config.body[b]
|
|
38
|
+
await flatten(bdy, true)
|
|
39
|
+
}
|
|
40
|
+
}else {
|
|
41
|
+
list.push({type: 'function', _id: config._id, address: config.address, module: config.module})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return list.length-1
|
|
45
|
+
case 'class':
|
|
46
|
+
if(call){
|
|
23
47
|
|
|
24
|
-
|
|
48
|
+
}else {
|
|
49
|
+
list.push({type: 'class', _id: config._id, address: config.address, module: config.module})
|
|
50
|
+
}
|
|
51
|
+
return list.length-1
|
|
52
|
+
case 'return':
|
|
53
|
+
config.output = await flatten(config.output)
|
|
54
|
+
list.push(config)
|
|
55
|
+
return list.length - 1
|
|
56
|
+
case 'raise':
|
|
57
|
+
return await flatten(config.object)
|
|
58
|
+
case 'assignment':
|
|
59
|
+
let val = await flatten(config.value)
|
|
60
|
+
|
|
61
|
+
config.value = val
|
|
62
|
+
list.push(config)
|
|
63
|
+
return list.length - 1
|
|
64
|
+
break;
|
|
65
|
+
case 'nest':
|
|
66
|
+
for (let n=0; n< config.nests.length; n++){
|
|
67
|
+
let nst = config.nests[n]
|
|
68
|
+
let val = await flatten(nst)
|
|
69
|
+
config.nests[n] = val
|
|
70
|
+
}
|
|
71
|
+
if(config.assignment){
|
|
72
|
+
config.assignment = await flatten(config.assignment)
|
|
73
|
+
}
|
|
74
|
+
list.push(config)
|
|
75
|
+
return list.length-1
|
|
76
|
+
case 'call':
|
|
77
|
+
let id = await this.read_config(config.identifier)
|
|
78
|
+
if (id && ['call', 'nest'].includes(id.type)){
|
|
79
|
+
config.identifier = await flatten(id)
|
|
80
|
+
}
|
|
81
|
+
for (let a=0; a< config.arguments.length; a++){
|
|
82
|
+
let arg = config.arguments[a]
|
|
83
|
+
config.arguments[a] = await flatten(arg)
|
|
84
|
+
}
|
|
85
|
+
list.push(config)
|
|
86
|
+
return list.length-1
|
|
87
|
+
case 'trycatch':
|
|
88
|
+
let try_index = list.length
|
|
89
|
+
let try_conf = {type:'try', alias: config.alias, location: config.location}
|
|
90
|
+
list.push(try_conf)
|
|
91
|
+
for(let i=0; i < config.try_body.length; i++){
|
|
92
|
+
let bdy = config.try_body[i]
|
|
93
|
+
let b = await flatten(bdy)
|
|
94
|
+
config.try_body[i] = b
|
|
95
|
+
}
|
|
96
|
+
let catch_index = list.length
|
|
97
|
+
try_conf.catch_index = catch_index
|
|
98
|
+
list.push({type:'catch', objects: config.objects, try_index})
|
|
99
|
+
for (let i=0; i< config.catch_body.length; i++){
|
|
100
|
+
let bdy = config.catch_body[i]
|
|
101
|
+
config.catch_body[i] = await flatten(bdy)
|
|
102
|
+
}
|
|
103
|
+
try_conf.catch_offset = -1 + list.length - catch_index;
|
|
104
|
+
return try_index
|
|
105
|
+
case 'variable':
|
|
106
|
+
list.push(config)
|
|
107
|
+
return list.length-1
|
|
108
|
+
case 'reference':
|
|
109
|
+
list.push(config)
|
|
110
|
+
return list.length -1
|
|
111
|
+
case 'address':
|
|
112
|
+
list.push(config)
|
|
113
|
+
return list.length -1
|
|
114
|
+
case 'loop':
|
|
115
|
+
let loop_config = {type: 'loop', kind: config.loop_type || 'while'}
|
|
116
|
+
let loop_index = list.length
|
|
117
|
+
list.push(loop_config)
|
|
118
|
+
if (config.loop_type === 'for')
|
|
119
|
+
await flatten(config.iterator)
|
|
120
|
+
loop_config.condition_index = list.length
|
|
121
|
+
let cond_index = await flatten(config.condition)
|
|
122
|
+
|
|
123
|
+
for (let b=0; b< config.body.length; b++){
|
|
124
|
+
let bdy = config.body[b]
|
|
125
|
+
await flatten(bdy)
|
|
126
|
+
}
|
|
127
|
+
if (loop_config.kind === 'while'){
|
|
128
|
+
loop_config.update_jmp = loop_config.condition_index
|
|
129
|
+
}else loop_config.update_jmp = list.length
|
|
130
|
+
if (config.loop_type === 'for'){
|
|
131
|
+
await flatten(config.update)
|
|
132
|
+
}
|
|
133
|
+
list.push({jmp: loop_config.condition_index})
|
|
134
|
+
list[cond_index].conditional_jmp = list.length
|
|
135
|
+
list[cond_index].invert = true
|
|
136
|
+
loop_config.conditional_jmp = list.length;
|
|
137
|
+
list.push({type: 'endloop', kind: 'unloop'})
|
|
138
|
+
return loop_index
|
|
139
|
+
case 'condition':
|
|
140
|
+
let prior_index, bdys = new Array(), indexx, prior_bdy;
|
|
141
|
+
for (let b=0; b< config.blocks.length; b++){
|
|
142
|
+
let blk = config.blocks[b];
|
|
143
|
+
|
|
144
|
+
indexx = list.length
|
|
145
|
+
let index = await flatten(blk.predicate)
|
|
146
|
+
if (prior_index){
|
|
147
|
+
list[prior_index].conditional_jmp = indexx
|
|
148
|
+
}
|
|
149
|
+
prior_index = index
|
|
25
150
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
151
|
+
prior_bdy;
|
|
152
|
+
for (let d = 0; d< blk.body.length; d++){
|
|
153
|
+
let bdy = blk.body[d]
|
|
154
|
+
prior_bdy = await flatten(bdy)
|
|
155
|
+
}
|
|
30
156
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
157
|
+
bdys.push(blk.body.length? prior_bdy: index)
|
|
158
|
+
list.push({})
|
|
159
|
+
}
|
|
160
|
+
if (config.blocks.length === 1){
|
|
161
|
+
list[prior_index].conditional_jmp = prior_bdy + 1
|
|
162
|
+
}
|
|
163
|
+
bdys.map(dy=>{
|
|
164
|
+
list[dy+1].jmp = list.length
|
|
165
|
+
})
|
|
166
|
+
return list.length - 1
|
|
167
|
+
case 'twain':
|
|
168
|
+
for (let key in config.value){
|
|
169
|
+
let [prop, val] = config.value[key]
|
|
170
|
+
prop = await flatten(prop)
|
|
171
|
+
val = await flatten(val)
|
|
172
|
+
config.value[key][0] = prop
|
|
173
|
+
config.value[key][1] = val
|
|
174
|
+
}
|
|
175
|
+
list.push(config)
|
|
176
|
+
return list.length - 1
|
|
177
|
+
case 'array':
|
|
178
|
+
for (let i=0; i< config.value.length; i++){
|
|
179
|
+
config.value[i] = await flatten(config.value[i])
|
|
180
|
+
}
|
|
181
|
+
list.push(config)
|
|
182
|
+
return list.length - 1
|
|
183
|
+
default:
|
|
184
|
+
if (['number', 'string', 'void', 'boolean'].includes(config.type)){
|
|
185
|
+
list.push(config)
|
|
186
|
+
return list.length-1
|
|
187
|
+
}else if (['continue', 'break'].includes(config.type)){
|
|
188
|
+
list.push(config)
|
|
189
|
+
return list.length-1
|
|
38
190
|
}
|
|
39
|
-
line = res;
|
|
40
|
-
}
|
|
41
|
-
}else if(typeof line.value === 'string' || line.value.type){
|
|
42
|
-
let res = await this.execute(line.value, {chain, caught: true, cloth:true})
|
|
43
|
-
line = res;
|
|
44
191
|
}
|
|
192
|
+
}
|
|
193
|
+
let result = await flatten(config)
|
|
45
194
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
let classifier = await line.get('_classifier_')
|
|
49
|
-
|
|
50
|
-
caught = err === classifier
|
|
51
|
-
if (config.alias){
|
|
52
|
-
let conf = await this.read_config(config.alias);
|
|
53
|
-
let hash = await this.account.manager.oracle.hash(conf);
|
|
54
|
-
await this.execute({...conf, value: {type: 'address', value: line.value.path}}, {chain, hash})
|
|
55
|
-
}
|
|
195
|
+
return list
|
|
196
|
+
}
|
|
56
197
|
|
|
198
|
+
read_config = async (addr, options={}) => {
|
|
199
|
+
if (typeof addr !== "string") {
|
|
200
|
+
return addr;
|
|
201
|
+
}
|
|
202
|
+
addr = addr.split('/')
|
|
203
|
+
let folder = await this.account.ds.folder(addr.slice(0,-1).join('/'))
|
|
204
|
+
let result = await folder.readone({_id: addr.slice(-1)[0]})
|
|
205
|
+
|
|
206
|
+
return result;
|
|
207
|
+
};
|
|
57
208
|
|
|
58
|
-
|
|
59
|
-
caught = err.endsWith(line.value.name)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
209
|
+
sync = async () => {};
|
|
62
210
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
211
|
+
throw_error = async(payload)=>{
|
|
212
|
+
return {
|
|
213
|
+
__interrupt__: true,
|
|
214
|
+
payload,
|
|
67
215
|
}
|
|
68
216
|
}
|
|
69
217
|
|
|
70
|
-
execute_body = async (body, options)=>{
|
|
71
|
-
let
|
|
72
|
-
let
|
|
73
|
-
|
|
74
|
-
let line = body[b];
|
|
75
|
-
|
|
76
|
-
line = await this.execute(line, {...options, line});
|
|
77
|
-
|
|
78
|
-
if (line){
|
|
79
|
-
if (line.interrupt_loop){
|
|
80
|
-
result =line
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
else if (line.done){
|
|
84
|
-
result = line.value;
|
|
85
|
-
break;
|
|
86
|
-
}else if (line.exit){
|
|
87
|
-
result = line;
|
|
88
|
-
break
|
|
89
|
-
}else if (line.error){
|
|
90
|
-
if (config.type === 'trycatch'){
|
|
91
|
-
let res = !config.caught && await this.handle_error(line, {chain, config})
|
|
218
|
+
execute_body = async (body, options) => {
|
|
219
|
+
let res;
|
|
220
|
+
for (let b=0; b < body.length; b++){
|
|
221
|
+
let line = body[b]
|
|
92
222
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
break
|
|
97
|
-
}else {
|
|
98
|
-
result = line;
|
|
99
|
-
break
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
result = line
|
|
223
|
+
res = await this.execute(line, options)
|
|
224
|
+
if(res){
|
|
225
|
+
if (res.done || res.__interrupt__) break
|
|
103
226
|
}
|
|
104
227
|
}
|
|
228
|
+
return res;
|
|
229
|
+
};
|
|
105
230
|
|
|
106
|
-
|
|
107
|
-
}
|
|
231
|
+
modules = new Array()
|
|
108
232
|
|
|
109
|
-
|
|
110
|
-
let prev_config = config
|
|
111
|
-
config = await this.read_config(config);
|
|
112
|
-
// console.log(config, 'EXE')
|
|
233
|
+
times = new Array()
|
|
113
234
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
235
|
+
curr_field = ()=>{
|
|
236
|
+
let curr = this.modules.slice(-1)[0]
|
|
237
|
+
return curr && curr.address
|
|
238
|
+
}
|
|
117
239
|
|
|
118
|
-
|
|
119
|
-
case "module":
|
|
120
|
-
result = await this.execute_body(config.body, {chain, config})
|
|
240
|
+
spawns = new Array();
|
|
121
241
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (call_config) {
|
|
125
|
-
let instance_chain = await chain.chain(call_config.location);
|
|
126
|
-
let object = {
|
|
127
|
-
content: [${config.name}],
|
|
128
|
-
_classifier_: config.address,
|
|
129
|
-
uid: this.gen_uid(),
|
|
130
|
-
};
|
|
131
|
-
for (let name in config.methods) {
|
|
132
|
-
let addr = config.methods[name];
|
|
133
|
-
object[name] = addr;
|
|
134
|
-
}
|
|
135
|
-
let res = await instance_chain.write(object, { is_instance: true });
|
|
136
|
-
result = { type: "address", value: res };
|
|
137
|
-
|
|
138
|
-
if (object._init_) {
|
|
139
|
-
await this.execute(
|
|
140
|
-
{ ...call_config, object: result, identifier: object._init_ },
|
|
141
|
-
{ chain }
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
break;
|
|
146
|
-
case 'adm':
|
|
147
|
-
let props = await this.execute(config.props, {chain})
|
|
148
|
-
if(config.name.includes('/')){
|
|
149
|
-
result = await this.execute({
|
|
150
|
-
type:'call',
|
|
151
|
-
identifier: config.name,
|
|
152
|
-
arguments: [{...props, position: 0}],
|
|
153
|
-
location: config.location
|
|
154
|
-
}, {chain})
|
|
155
|
-
}else {
|
|
156
|
-
result = await this.native_components(config, chain)
|
|
157
|
-
result = await this.parse_aircode(result, {config, chain})
|
|
158
|
-
}
|
|
159
|
-
break
|
|
160
|
-
case "function":
|
|
161
|
-
if (call_config) {
|
|
162
|
-
let fn_chain = await chain.chain(config.address);
|
|
163
|
-
let params = new Array();
|
|
164
|
-
for (let a = 0; a < call_config.arguments.length; a++) {
|
|
165
|
-
let arg = call_config.arguments[a];
|
|
166
|
-
|
|
167
|
-
for (let p = 0; p < config.parameters.length; p++) {
|
|
168
|
-
let param = await this.read_config(config.parameters[p]);
|
|
169
|
-
|
|
170
|
-
if (arg.identifier) {
|
|
171
|
-
} else {
|
|
172
|
-
if (p === arg.position) {
|
|
173
|
-
param.hash = await this.account.manager.oracle.hash(param);
|
|
174
|
-
param.value = arg;
|
|
175
|
-
params.push(param);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
for (let p = 0; p < params.length; p++) {
|
|
181
|
-
let param = params[p];
|
|
242
|
+
execute = async (config, options = {}) => {
|
|
243
|
+
let {chain, cloth, thread} = options
|
|
182
244
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
let conf = {
|
|
187
|
-
type: "assignment",
|
|
188
|
-
identifier: "this",
|
|
189
|
-
value: call_config.object,
|
|
190
|
-
};
|
|
191
|
-
let r = await fn_chain.add_config(conf);
|
|
192
|
-
|
|
193
|
-
await this.execute(r, { chain: fn_chain });
|
|
194
|
-
}
|
|
245
|
+
config = await this.read_config(config, chain)
|
|
246
|
+
this.running_thread = thread
|
|
247
|
+
// console.log(config, 'EXE')
|
|
195
248
|
|
|
196
|
-
|
|
197
|
-
}else result = {type:'address', value: prev_config}
|
|
249
|
+
let result;
|
|
198
250
|
|
|
199
|
-
|
|
200
|
-
case "return":
|
|
201
|
-
let ret_value = await this.execute(config.output, { chain });
|
|
251
|
+
if (!config) return config;
|
|
202
252
|
|
|
203
|
-
|
|
253
|
+
switch (config.type) {
|
|
254
|
+
case 'module':
|
|
255
|
+
let mod_chain = await chain.chain(config.location)
|
|
256
|
+
// result = await this.execute_body(config.body, {chain: mod_chain, config})
|
|
257
|
+
result = config.body
|
|
204
258
|
break;
|
|
205
|
-
case
|
|
206
|
-
let
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
value = { type: "address", value: value.value.path };
|
|
214
|
-
} else if (typeof value === "string")
|
|
215
|
-
value = { type: "address", value };
|
|
216
|
-
result = await ass_chain.write(value, { hash });
|
|
259
|
+
case 'class':
|
|
260
|
+
let cls_chn = await chain.chain(config.address)
|
|
261
|
+
result = await (await cls_chn.folder()).write(config, {replace: true})
|
|
262
|
+
result = {
|
|
263
|
+
type: 'function',
|
|
264
|
+
address: config.address,
|
|
265
|
+
value: config.address,
|
|
266
|
+
_id: result._id
|
|
217
267
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
268
|
+
break
|
|
269
|
+
case 'function':
|
|
270
|
+
let fn_chn = await chain.chain(config.address)
|
|
271
|
+
result = await (await fn_chn.folder()).write(config, {replace: true})
|
|
272
|
+
result = {
|
|
273
|
+
type: 'function',
|
|
274
|
+
address: config.address,
|
|
275
|
+
value: config.address,
|
|
276
|
+
_id: result._id
|
|
225
277
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
);
|
|
233
|
-
if (obj.account) {
|
|
234
|
-
obj = { type: "address", value: obj.value.path };
|
|
235
|
-
}
|
|
236
|
-
if (arg.type === "assignment") {
|
|
237
|
-
obj.identifier = arg.identifier;
|
|
238
|
-
}
|
|
239
|
-
obj.position = a;
|
|
240
|
-
config.arguments[a] = obj;
|
|
278
|
+
break
|
|
279
|
+
case 'return':
|
|
280
|
+
result = {
|
|
281
|
+
__interrupt__: true,
|
|
282
|
+
type: 'return',
|
|
283
|
+
output: config.output
|
|
241
284
|
}
|
|
242
|
-
|
|
243
|
-
result = await this.execute_call(config, { chain , obj});
|
|
244
|
-
|
|
245
285
|
break;
|
|
246
286
|
case 'loop':
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
break;
|
|
259
|
-
} else{
|
|
260
|
-
result = null
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
if(loop_type === 'for'){
|
|
264
|
-
await this.execute(config.update, {chain})
|
|
265
|
-
}
|
|
266
|
-
cond = await this.execute(config.condition, {chain , cloth: true})
|
|
267
|
-
}
|
|
287
|
+
|
|
288
|
+
break;
|
|
289
|
+
case 'condition':
|
|
290
|
+
|
|
291
|
+
break
|
|
292
|
+
case 'assignment':
|
|
293
|
+
let ass_chain = await chain.chain(config.location)
|
|
294
|
+
|
|
295
|
+
result = await ass_chain.write(config.value, {addr: true})
|
|
296
|
+
|
|
297
|
+
result = {...config.value, identifier: config.identifier}
|
|
268
298
|
|
|
269
299
|
break
|
|
270
|
-
case '
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
cloth: true
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
let prev = await this.execute(config.nests[0], { chain, cloth: true }),
|
|
292
|
-
pprev;
|
|
293
|
-
|
|
294
|
-
for (
|
|
295
|
-
let n = 1;
|
|
296
|
-
n < config.nests.length - (config.assignment ? 1 : 0);
|
|
297
|
-
n++
|
|
298
|
-
) {
|
|
299
|
-
let nst = await this.read_config(config.nests[n]);
|
|
300
|
-
pprev = prev;
|
|
301
|
-
|
|
302
|
-
if (nst.type === "call") {
|
|
303
|
-
let conf =prev.type === 'function'? prev.value: await prev.get(nst.identifier, {obj: prev, config: nst, chain});
|
|
304
|
-
if (!conf) await this.throw_error();
|
|
305
|
-
nst.object = { value: prev.value.path, type: "address" };
|
|
306
|
-
conf.prev_name = nst.identifier
|
|
307
|
-
prev = await this.execute(
|
|
308
|
-
{ ...nst, identifier: conf.type ==='function'?conf.address:conf },
|
|
309
|
-
{ chain, cloth: true, obj:prev }
|
|
310
|
-
);
|
|
311
|
-
if(prev && prev.error){
|
|
312
|
-
break;
|
|
300
|
+
case 'nest':
|
|
301
|
+
let prev = await this.cloth(config.nests[0])
|
|
302
|
+
result = config.nests[0]
|
|
303
|
+
for (let i=1; i < config.nests.length - (config.assignment?1:0); i++){
|
|
304
|
+
let nst = await this.read_config(config.nests[i]), obj;
|
|
305
|
+
|
|
306
|
+
if(nst.type === 'call'){
|
|
307
|
+
obj = await this.execute({
|
|
308
|
+
type: "string",
|
|
309
|
+
value: nst.identifier,
|
|
310
|
+
location: `${nst.location}_`,
|
|
311
|
+
}, { chain, cloth: true })
|
|
312
|
+
obj = await prev.get(nst.identifier, {chain, obj, config: nst})
|
|
313
|
+
if(obj.__interrupt__){
|
|
314
|
+
result = obj
|
|
315
|
+
break
|
|
316
|
+
}else{
|
|
317
|
+
result = await this.execute({
|
|
318
|
+
...nst, identifier: obj
|
|
319
|
+
}, {chain})
|
|
320
|
+
prev = await this.cloth(result)
|
|
313
321
|
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
if(prev.
|
|
319
|
-
|
|
320
|
-
|
|
322
|
+
}else{
|
|
323
|
+
obj = await this.cloth(nst)
|
|
324
|
+
prev = await prev.get(await obj.literal(), {chain, obj, config: nst})
|
|
325
|
+
|
|
326
|
+
if (prev.__interrupt__){
|
|
327
|
+
result = prev
|
|
328
|
+
break
|
|
329
|
+
}else {
|
|
330
|
+
result = prev;
|
|
331
|
+
prev = await this.cloth(prev)
|
|
321
332
|
}
|
|
322
|
-
prev = await prev.get(prop, {obj: res, config: nst, chain});
|
|
323
333
|
}
|
|
324
334
|
}
|
|
325
|
-
if (config.assignment) {
|
|
326
|
-
let ass = await this.execute(config.assignment, { chain });
|
|
327
|
-
let last = config.nests.slice(-1)[0];
|
|
328
|
-
last = await this.execute(last, { chain, cloth: true });
|
|
329
335
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
336
|
+
if (config.assignment){
|
|
337
|
+
let bull = thread.bullets[thread.pointer]
|
|
338
|
+
if (result && result.__interrupt__){
|
|
339
|
+
}else {
|
|
340
|
+
let last = await this.cloth(config.nests.slice(-1)[0], {just_content: true})
|
|
341
|
+
if (this.datatypes.includes(last.type)) {
|
|
342
|
+
let r = await prev.set(config.nests.slice(-1)[0], config.assignment, {chain})
|
|
343
|
+
bull.assignment_location = r
|
|
344
|
+
result = config.assignment
|
|
345
|
+
}
|
|
346
|
+
}
|
|
340
347
|
}
|
|
341
|
-
|
|
348
|
+
break
|
|
349
|
+
case 'call':
|
|
350
|
+
result = await this.execute_call(config, {chain, thread})
|
|
342
351
|
break;
|
|
343
352
|
default:
|
|
344
|
-
if (
|
|
345
|
-
result = await this.instantiate(config, {
|
|
346
|
-
|
|
347
|
-
|
|
353
|
+
if (this.datatypes.includes(config.type)){
|
|
354
|
+
result = await this.instantiate(config, {chain})
|
|
355
|
+
} else if (config.type === 'variable' || config.type === 'reference'){
|
|
356
|
+
if (!!await this.callable(config.value) || this.datatypes.includes(config.value)){
|
|
357
|
+
result = {
|
|
358
|
+
type: 'address',
|
|
359
|
+
value: config.value,
|
|
360
|
+
_id: config.value,
|
|
361
|
+
config: true,
|
|
362
|
+
}
|
|
363
|
+
} else result = await this.variable(config.location, {chain, config})
|
|
364
|
+
} else if(["continue", "break"].includes(config.type)) {
|
|
365
|
+
config.__interrupt__ = config.type;
|
|
348
366
|
result = config;
|
|
349
|
-
} else if (config.type === "variable") {
|
|
350
|
-
let var_chain = await chain.chain(config.location);
|
|
351
|
-
let res = await var_chain.read({ sibling: true });
|
|
352
|
-
if (!res) {
|
|
353
|
-
res = await this.account.manager.oracle.fs.read(
|
|
354
|
-
${var_chain.path}/.config
|
|
355
|
-
);
|
|
356
|
-
res = { type: "address", value: res.current };
|
|
357
|
-
}
|
|
358
|
-
result = res;
|
|
359
|
-
} else if (config.type === "reference") {
|
|
360
|
-
let oracle = this.account.manager.oracle;
|
|
361
|
-
let i_chain = await chain.chain(config.value);
|
|
362
|
-
let conf = await oracle.fs.read(${i_chain.path}/.config);
|
|
363
|
-
result = { type: "address", value: conf.current };
|
|
364
|
-
}else if (['continue', 'break'].includes(config.type)){
|
|
365
|
-
result = {interrupt_loop: config.type}
|
|
366
367
|
}
|
|
367
368
|
}
|
|
368
369
|
|
|
369
|
-
if
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
if (result && !result.error) result = await this.cloth_content(result);
|
|
370
|
+
if(result && cloth && !result.__interrupt__){
|
|
371
|
+
result = await this.cloth(result)
|
|
372
|
+
}else if (result && config.conditional_jmp){
|
|
373
|
+
result = await this.cloth(result)
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
return result;
|