2017-09-19 00:35:37 -07:00
|
|
|
require "lib/core.nom"
|
|
|
|
|
2017-09-20 03:06:15 -07:00
|
|
|
macro block [with secrets %block] =: ".."
|
2017-09-19 00:29:31 -07:00
|
|
|
|local secrets = {}
|
2017-09-21 02:33:04 -07:00
|
|
|
|\(%block's "value") as lua\
|
2017-09-19 00:29:31 -07:00
|
|
|
|
2017-09-20 03:06:15 -07:00
|
|
|
macro block [with secrets as %secret_name %block] =: ".."
|
2017-09-19 00:29:31 -07:00
|
|
|
|local \%secret_name as value\ = {}
|
2017-09-21 02:33:04 -07:00
|
|
|
|\(%block's "value") as lua\
|
2017-09-19 00:29:31 -07:00
|
|
|
|
2017-09-20 03:06:15 -07:00
|
|
|
# Access the lua variable that should be within scope
|
|
|
|
macro [secrets] =: "secrets"
|
2017-09-19 00:29:31 -07:00
|
|
|
|
2017-09-20 03:06:15 -07:00
|
|
|
macro [secret %key, secret value of %key, secret value for %key] =:
|
|
|
|
if ((%key's "type") != "Var"):
|
2017-09-19 00:29:31 -07:00
|
|
|
error ".."
|
2017-09-20 03:06:15 -07:00
|
|
|
|Wrong type, expected Var, but got: \%key's "type"\
|
|
|
|
".."|secrets[\repr (%key's "value")\]
|
2017-09-19 00:29:31 -07:00
|
|
|
|
2017-09-20 03:06:15 -07:00
|
|
|
macro block [secret %key = %new_value] =:
|
2017-09-19 00:29:31 -07:00
|
|
|
lua block ".."
|
2017-09-20 03:06:15 -07:00
|
|
|
|if vars.key.type ~= "Var" then
|
2017-09-22 11:56:46 -07:00
|
|
|
| nomsu:error("Assignment operation has the wrong type for the left hand side. "
|
2017-09-20 03:06:15 -07:00
|
|
|
| .."Expected Var, but got: "..vars.key.type)
|
2017-09-19 00:29:31 -07:00
|
|
|
|end
|
2017-09-20 03:06:15 -07:00
|
|
|
|if vars.new_value.type ~= "Thunk" then
|
2017-09-22 11:56:46 -07:00
|
|
|
| nomsu:error("Assignment operation has the wrong type for the right hand side. "
|
2017-09-20 03:06:15 -07:00
|
|
|
| .."Expected Thunk, but got: "..vars.new_value.type.."\\nMaybe you used '=' instead of '=:'?")
|
2017-09-19 00:29:31 -07:00
|
|
|
|end
|
2017-09-22 11:44:07 -07:00
|
|
|
".."
|
|
|
|
|local ret
|
2017-09-22 11:56:46 -07:00
|
|
|
|\lua expr "nomsu:tree_to_lua(vars.new_value.value)"\
|
2017-09-22 11:44:07 -07:00
|
|
|
|secrets[\repr (%key's "value")\] = ret
|