diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-08-22 03:28:44 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-08-22 03:28:44 -0700 |
| commit | 039c620df270e88f6d50df677b7dedd65b868449 (patch) | |
| tree | 0a101402e6ccd51aeb4e517f0904b150ea3511e9 | |
| parent | a5863030ec0f729080f7407dbfa9970c8829fe69 (diff) | |
Macro macro macro macro.
| -rwxr-xr-x | core.moon | 13 | ||||
| -rw-r--r-- | nomic.moon | 1 |
2 files changed, 14 insertions, 0 deletions
@@ -194,5 +194,18 @@ if (not %condition) %body g\def [[do %action]], (vars)=> return vars.action(self,vars) +g\defmacro [[lua %lua_code]], (vars,helpers,ftype)=> + with helpers + lua_code = vars.lua_code.value + switch lua_code.type + when "List" + .lua table.concat[i.value.value for i in *lua_code.value] + else + .lua(lua_code.value) + return nil + +g\defmacro [[macro %spec %body]], (vars,helpers,ftype)=> + self\simplemacro vars.spec.value.value, vars.body.value.value.src + return g @@ -187,6 +187,7 @@ class Game return invocations, arg_names defmacro: (spec, fn)=> + assert fn, "No function supplied" invocations,arg_names = self\get_invocations spec for invocation in *invocations @macros[invocation] = {fn, arg_names} |
