Skip to content

Commit

Permalink
<bugfix> fixed pasted-copy bug in __addmissingcopy - where hasdtor sh…
Browse files Browse the repository at this point in the history
…ould have been hascopy.
  • Loading branch information
hiemstar committed Sep 7, 2024
1 parent 8109b94 commit 477ba23
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/terralibext.t
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
--local io = terralib.includec("stdio.h")

local function addmissinginit(T)

--flag that signals that a missing __init method needs to
Expand Down Expand Up @@ -56,6 +58,7 @@ local function addmissinginit(T)
if T:isstruct() and T.methods.__init == nil then
local method = terra(self : &T)
generateinit(@self)
--io.printf("generated __init()\n")
end
if generate then
T.methods.__init = method
Expand Down Expand Up @@ -121,6 +124,7 @@ local function addmissingdtor(T)

if T:isstruct() and T.methods.__dtor==nil then
local method = terra(self : &T)
--io.printf("generated __dtor()\n")
generatedtor(@self)
end
if generate then
Expand Down Expand Up @@ -163,11 +167,11 @@ local function addmissingcopy(T)
to = from
end
end
elseif V:isarray() and hasdtor(V) then
elseif V:isarray() and hascopy(V) then
return quote
var pa = &self
for i = 0,V.N do
rundtor((@pa)[i])
runcopy((@pa)[i])
end
end
else
Expand Down Expand Up @@ -196,6 +200,7 @@ local function addmissingcopy(T)
if T:isstruct() and T.methods.__copy==nil then
local method = terra(from : &T, to : &T)
generatecopy(@from, @to)
--io.printf("generated __copy()\n")
end
if generate then
T.methods.__copy = method
Expand Down

0 comments on commit 477ba23

Please sign in to comment.