lang: funcs: core: Add value functions

This adds a new series of "get*" functions which can read values from
the associated "value" resources. The key name of the function must
match the name value of the resource for things to work.

Type unification isn't yet perfect in these scenarios, so you should use
casually and with caution.
This commit is contained in:
James Shubin
2023-12-03 16:48:42 -05:00
parent c05af3b9b3
commit b7d8a769db
7 changed files with 734 additions and 7 deletions

View File

@@ -0,0 +1,30 @@
import "value"
value "hello1" {
#any => 42, # can be any type
any => "wow", # can be any type
}
value "hello2" {
any => "whatever", # TODO: remove the temporary placeholder here
#any => "", # XXX: remove any placeholder to see the bug when absent
}
test "test" {
#anotherstr => "", # get it from send/recv
}
Value["hello1"].any -> Value["hello2"].any
Value["hello2"].any -> Test["test"].anotherstr
$ret1 = value.get_str("hello1") # name of value resource
$ret2 = value.get_str("hello2") # name of value resource
test "get1" {
anotherstr => $ret1->value,
onlyshow => ["AnotherStr",], # displays nicer
}
test "get2" {
anotherstr => $ret2->value,
onlyshow => ["AnotherStr",],
}

View File

@@ -0,0 +1,19 @@
value "hello" {
any => "whatever",
}
test "test" {
#anotherstr => "", # get it from send/recv
onlyshow => ["AnotherStr",], # displays nicer
}
Value["hello"].any -> Test["test"].anotherstr
import "value"
$ret = value.get_str("hello") # name of value resource
test "get" {
anotherstr => $ret->value,
onlyshow => ["AnotherStr",], # displays nicer
}