rm map/set

This commit is contained in:
2026-01-15 14:39:37 -06:00
parent 66a9ca27e2
commit 78a46b4a72
3 changed files with 10 additions and 958 deletions

View File

@@ -158,7 +158,8 @@ function disrupt(err)
}
if (underlings) {
for (var id of underlings) {
var unders = array(underlings)
for (var id of unders) {
log.console(`calling on ${id} to disrupt too`)
$_.stop(create_actor({id}))
}
@@ -319,7 +320,7 @@ $_.clock = function(fn) {
})
}
var underlings = new Set() // this is more like "all actors that are notified when we die"
var underlings = {} // this is more like "all actors that are notified when we die"
var overling = null
var root = null
@@ -454,7 +455,7 @@ $_.stop = function stop(actor) {
}
if (!is_actor(actor))
throw Error('Can only call stop on an actor.')
if (!underlings.has(actor[ACTORDATA].id))
if (is_null(underlings[actor[ACTORDATA].id]))
throw Error('Can only call stop on an underling or self.')
sys_msg(actor, {kind:"stop"})
@@ -483,10 +484,10 @@ $_.delay = function delay(fn, seconds = 0) {
var enet = use_core('enet')
// causes this actor to stop when another actor stops.
var couplings = new Set()
var couplings = {}
$_.couple = function couple(actor) {
if (actor == $_.self) return // can't couple to self
couplings.add(actor[ACTORDATA].id)
couplings[actor[ACTORDATA].id] = true
sys_msg(actor, {kind:'couple', from: $_.self})
log.system(`coupled to ${actor}`)
}
@@ -676,7 +677,7 @@ function handle_actor_disconnect(id) {
delete greeters[id]
}
log.system(`actor ${id} disconnected`)
if (couplings.has(id)) disrupt("coupled actor died") // couplings now disrupts instead of stop
if (!is_null(couplings[id])) disrupt("coupled actor died") // couplings now disrupts instead of stop
}
function handle_sysym(msg)
@@ -691,7 +692,7 @@ function handle_sysym(msg)
var greeter = greeters[from[ACTORDATA].id]
if (greeter) greeter(msg.message)
if (msg.message.type == 'disrupt')
underlings.delete(from[ACTORDATA].id)
delete underlings[from[ACTORDATA].id]
break
case 'contact':
if (portal_fn) {
@@ -703,7 +704,7 @@ function handle_sysym(msg)
break
case 'couple': // from must be notified when we die
from = msg.from
underlings.add(from[ACTORDATA].id)
underlings[from[ACTORDATA].id] = true
log.system(`actor ${from} is coupled to me`)
break
}

View File

@@ -128,7 +128,6 @@ void script_startup(cell_rt *prt)
JS_AddIntrinsicEval(js);
JS_AddIntrinsicRegExp(js);
JS_AddIntrinsicJSON(js);
JS_AddIntrinsicMapSet(js);
JS_SetContextOpaque(js, prt);
prt->context = js;

File diff suppressed because it is too large Load Diff