diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-28 17:49:15 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-09-28 17:49:15 -0700 |
| commit | ac25e20b9f94505175841d9a8da7253f8996926d (patch) | |
| tree | 965a766f89b826f80a61569e1c7084e5e669558a /lib/secrets.nom | |
| parent | 10d61df78bdbf002a3701e468b0a3c88be2cad03 (diff) | |
Kinda mostly working, except for closure vars like in lib/secrets.nom.
Diffstat (limited to 'lib/secrets.nom')
| -rw-r--r-- | lib/secrets.nom | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/lib/secrets.nom b/lib/secrets.nom index 052ee6c..b6274ab 100644 --- a/lib/secrets.nom +++ b/lib/secrets.nom @@ -1,33 +1,30 @@ require "lib/core.nom" -macro block [with secrets %block] =: ".." +compile (with secrets %block) to block: ".." |local secrets = {} - |\(%block's "value") as lua\ - -macro block [with secrets as %secret_name %block] =: ".." - |local \%secret_name as value\ = {} - |\(%block's "value") as lua\ + |\(%block as lua statements) # Access the lua variable that should be within scope -macro [secrets] =: "secrets" +compile (secrets) to: "secrets" + +compile (secret %key; secret value of %key; secret value for %key) to: + assert ((%key's "type") == "Var") ".." + |Wrong type, expected Var, but got: \(%key's "type") + "secrets[\(repr (%key's "value"))]" + +compile (secret %key = %new_value) to code: + assert ((%key's "type") == "Var") ".." + |Wrong type, expected Var, but got: \(%key's "type") + "secrets[\(repr (%key's "value"))] = \(%new_value as lua)" -macro [secret %key, secret value of %key, secret value for %key] =: - if ((%key's "type") != "Var"): - error ".." - |Wrong type, expected Var, but got: \%key's "type"\ - ".."|secrets[\repr (%key's "value")\] +enable debugging +with secrets: + secret %foo = 5 + rule (plumb %) =: + secret %foo = % + rule (frop) =: + secret %foo -macro block [secret %key = %new_value] =: - lua block ".." - |if vars.key.type ~= "Var" then - | nomsu:error("Assignment operation has the wrong type for the left hand side. " - | .."Expected Var, but got: "..vars.key.type) - |end - |if vars.new_value.type ~= "Thunk" then - | nomsu:error("Assignment operation has the wrong type for the right hand side. " - | .."Expected Thunk, but got: "..vars.new_value.type.."\\nMaybe you used '=' instead of '=:'?") - |end - ".." - |local ret - |\lua expr "nomsu:tree_to_lua(vars.new_value.value)"\ - |secrets[\repr (%key's "value")\] = ret +say (frop) +pumb 99 +say (frop) |
