Differences From
Artifact [05a21ff4d9]:
105 105 self.ptr = self.ptr + n
106 106 self.ct = self.ct - n
107 107 return self.ptr
108 108 end
109 109 terra t.methods.null(): t return t { ptr = nil, ct = 0 } end -- maybe should be a macro?
110 110 terra t:ref() return self.ptr ~= nil end
111 111 t.metamethods.__not = macro(function(self) return `not self:ref() end)
112 - t.metamethods.__apply = macro(function(self,idx) return `self.ptr[idx] end)
112 + t.metamethods.__apply = macro(function(self,idx) return `self.ptr[ [idx or 0] ] end)
113 + t.metamethods.__update = macro(function(self,idx,rhs)
114 + return quote self.ptr[idx] = rhs end end)
115 +
113 116 if not ty:isstruct() then
114 117 terra t:cmp_raw(other: &ty)
115 118 for i=0, self.ct do
116 119 if self.ptr[i] ~= other[i] then return false end
117 120 end
118 121 return true
119 122 end