229c739342/vm/golang/ngaro.go
| fbec8f49aece25bf72a68c06ecb0cd01dd84f757 | 229c7393422c788b47fb6fe491fad591fe049d3f | ||
|---|---|---|---|
33 | : ->c ( xy- ) 2 out wait ; ( send x to channel y ) | 33 | : ->c ( xy- ) 2 out wait ; ( send x to channel y ) |
34 | : c-> ( x-y ) 1 out wait 1 in ; ( receive y from channel x ) | 34 | : c-> ( x-y ) 1 out wait 1 in ; ( receive y from channel x ) |
35 | : delchan ( x- ) dup 1 out 2 out wait ; ( delete channel ) | 35 | : delchan ( x- ) dup 1 out 2 out wait ; ( delete channel ) |
36 | : cores ( -x ) -7 5 out wait 5 in ; ( number of running cores ) | 36 | : cores ( -x ) 1 5 out wait 5 in ; ( number of running cores ) |
37 | : chans ( -x ) -8 5 out wait 5 in ; ( number of channels in use ) | 37 | : chans ( -x ) 2 5 out wait 5 in ; ( number of channels in use ) |
38 | 38 | ||
39 | Example: | 39 | Example: |
40 | 40 | ||
... | ... | ||
188 | return vm.channel[id] | 188 | return vm.channel[id] |
189 | } | 189 | } |
190 | 190 | ||
191 | func (vm *NgaroVM) wait(port *[nports]int, tos int) (spdec int) { | 191 | func (vm *NgaroVM) wait(port *[nports]int, tos int, ip int) (spdec int) { |
192 | if port[0] == 1 { | 192 | if port[0] == 1 { |
193 | return | 193 | return |
194 | } | 194 | } |
... | ... | ||
265 | port[5] = stackDepth | 265 | port[5] = stackDepth |
266 | port[0] = 1 | 266 | port[0] = 1 |
267 | 267 | ||
268 | case -7: // Number of cores | 268 | case -9: |
269 | ip = vm.size | ||
270 | |||
271 | case 1: // Number of cores | ||
269 | port[5] = vm.cores | 272 | port[5] = vm.cores |
270 | port[0] = 1 | 273 | port[0] = 1 |
271 | 274 | ||
272 | case -8: // Number of channels | 275 | case 2: // Number of channels |
273 | port[5] = len(vm.channel) | 276 | port[5] = len(vm.channel) |
274 | port[0] = 1 | 277 | port[0] = 1 |
275 | 278 | ||
... | ... | ||
420 | port[data[sp]] = data[sp-1] | 423 | port[data[sp]] = data[sp-1] |
421 | sp = sp - 2 | 424 | sp = sp - 2 |
422 | case Wait: | 425 | case Wait: |
423 | sp -= vm.wait(&port, tos) | 426 | sp -= vm.wait(&port, tos, ip) |
424 | default: | 427 | default: |
425 | ip = vm.size | 428 | rsp++ |
429 | addr[rsp] = ip | ||
430 | ip = vm.img[ip] - 1 | ||
426 | } | 431 | } |
427 | // to avoid segfaults: | 432 | // to avoid segfaults: |
428 | if sp < 0 { | 433 | if sp < 0 { |
Download diff