Skip to content

Commit

Permalink
Fall back to tonumber for uniquely identifying types in LuaJIT.
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottslaughter committed Nov 30, 2018
1 parent fac6a35 commit f4cf845
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/asdl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -457,4 +457,4 @@ function Context:Define(text)
end
end
end
package.loaded["asdl"] = { NewContext = NewContext, List = List, iscdata = iscdata }
package.loaded["asdl"] = { NewContext = NewContext, List = List, isluajit = isluajit, iscdata = iscdata }
13 changes: 9 additions & 4 deletions src/terralib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local ffi = require("ffi")
local asdl = require("asdl")
local List = asdl.List

local isluajit = asdl.isluajit
local iscdata = asdl.iscdata

-- LINE COVERAGE INFORMATION, must run test script with luajit and not terra to avoid overwriting coverage with old version
Expand Down Expand Up @@ -1445,10 +1446,14 @@ do

--create a map from this ctype to the terra type to that we can implement terra.typeof(cdata)
local ctype = ffi.typeof(self.cachedcstring)
types.ctypetoterra[tostring(ctype)] = self
-- FIXME: This is unimplemented in FFI wrapper for Lua
-- local rctype = ffi.typeof(self.cachedcstring.."&")
-- types.ctypetoterra[tostring(rctype)] = self
-- tonumber(ctype) is LuaJIT-only, so rely on printed representation in PUC Lua
local ctype_key = tonumber(ctype) or tostring(ctype)
types.ctypetoterra[ctype_key] = self
if isluajit() then
local rctype = ffi.typeof(self.cachedcstring.."&")
local rctype_key = tonumber(rctype) or tostring(rctype)
types.ctypetoterra[rctype_key] = self
end

if self:isstruct() then
local function index(obj,idx)
Expand Down

0 comments on commit f4cf845

Please sign in to comment.