A simple experiment Lua function that generates stubs of provided Terra functions.
Last active
August 1, 2019 09:03
-
-
Save DarkWiiPlayer/3ade4827ccc692c244af9a71bf9ace78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function tmap(tab, func) | |
local new = {} | |
for key, value in pairs(tab) do | |
new[key] = func(value) | |
end | |
return new | |
end | |
local terra add(a : int, b : int) | |
return a + b | |
end | |
local function stub(func, ret) | |
return terra([tmap(add:gettype().parameters, symbol)]) | |
return [ret] | |
end | |
end | |
print(stub(add, 0)(1, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment