|
144 | 144 | elseif node.kind == "postfix_expression_index" then |
145 | 145 | local val = self:Assert(self:AnalyzeExpression(node.left)) |
146 | 146 | local obj = self:Assert(self:AnalyzeExpression(node.expression)) |
| 147 | + |
147 | 148 | if not self:IsTypesystem() then |
148 | 149 | val = self:GetFirstValue(val) |
149 | 150 | obj = self:GetFirstValue(obj) |
|
209 | 210 |
|
210 | 211 | function META:AnalyzeExpression(node) |
211 | 212 | self:PushCurrentExpression(node) |
| 213 | + self:CheckTimeout() |
212 | 214 | local obj, err = self:AnalyzeRuntimeExpression(node) |
213 | 215 | self:PopCurrentExpression() |
214 | 216 |
|
|
222 | 224 | node.scope = self:GetScope() |
223 | 225 | return obj, err |
224 | 226 | end |
| 227 | + |
| 228 | + function META:CheckTimeout() |
| 229 | + self.check_count = (self.check_count or 0) + 1 |
| 230 | + local count = self.check_count |
| 231 | + |
| 232 | + if count < 90000 then return end |
| 233 | + |
| 234 | + self.timeout = self.timeout or {} |
| 235 | + local node = self:GetCurrentStatement() or self:GetCurrentExpression() |
| 236 | + self.timeout[node] = (self.timeout[node] or 0) + 1 |
| 237 | + |
| 238 | + if count < 100000 then return end |
| 239 | + |
| 240 | + local top = {} |
| 241 | + |
| 242 | + for node, count in pairs(self.timeout) do |
| 243 | + if count > 5 then table.insert(top, {node = node, count = count}) end |
| 244 | + end |
| 245 | + |
| 246 | + table.sort(top, function(a, b) |
| 247 | + return a.count > b.count |
| 248 | + end) |
| 249 | + |
| 250 | + for i, info in ipairs(top) do |
| 251 | + if i > 10 then break end |
| 252 | + |
| 253 | + self:Warning({info.node, " was crawled ", info.count, " times"}) |
| 254 | + end |
| 255 | + |
| 256 | + self:FatalError("too many iterations, stopping execution") |
| 257 | + end |
225 | 258 | end |
226 | 259 |
|
227 | 260 | function META:OnDiagnostic() end |
|
0 commit comments