Files
mgmt/lang/interpret_test/TestAstFunc1/slow_unification0.txtar
James Shubin 28f5b8331a lang: funcs: structs: Improve naming
These could print nicer for debugging.
2024-12-08 16:24:42 -05:00

106 lines
2.1 KiB
Plaintext

-- main.mcl --
# state machine that previously experienced unusable slow type unification
import "world"
$ns = "estate"
$exchanged = world.kvlookup($ns)
$state = $exchanged[$hostname] || "default"
if $state == "one" or $state == "default" {
file "/tmp/mgmt/state" {
content => "state: one\n",
}
exec "timer" {
cmd => "/usr/bin/sleep 1s",
}
kv "${ns}" {
key => $ns,
value => "two",
}
Exec["timer"] -> Kv["${ns}"]
}
if $state == "two" {
file "/tmp/mgmt/state" {
content => "state: two\n",
}
exec "timer" {
cmd => "/usr/bin/sleep 1s",
}
kv "${ns}" {
key => $ns,
value => "three",
}
Exec["timer"] -> Kv["${ns}"]
}
if $state == "three" {
file "/tmp/mgmt/state" {
content => "state: three\n",
}
exec "timer" {
cmd => "/usr/bin/sleep 1s",
}
kv "${ns}" {
key => $ns,
value => "one",
}
Exec["timer"] -> Kv["${ns}"]
}
-- OUTPUT --
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Edge: FuncValue -> call # fn
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: FuncValue
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: call
Vertex: const: str("")
Vertex: const: str("/tmp/mgmt/state")
Vertex: const: str("/tmp/mgmt/state")
Vertex: const: str("/tmp/mgmt/state")
Vertex: const: str("/usr/bin/sleep 1s")
Vertex: const: str("/usr/bin/sleep 1s")
Vertex: const: str("/usr/bin/sleep 1s")
Vertex: const: str("==")
Vertex: const: str("==")
Vertex: const: str("==")
Vertex: const: str("==")
Vertex: const: str("default")
Vertex: const: str("default")
Vertex: const: str("estate")
Vertex: const: str("one")
Vertex: const: str("one")
Vertex: const: str("or")
Vertex: const: str("state: one\n")
Vertex: const: str("state: three\n")
Vertex: const: str("state: two\n")
Vertex: const: str("three")
Vertex: const: str("three")
Vertex: const: str("timer")
Vertex: const: str("timer")
Vertex: const: str("timer")
Vertex: const: str("timer")
Vertex: const: str("timer")
Vertex: const: str("timer")
Vertex: const: str("two")
Vertex: const: str("two")