Skip to content

Commit fec6972

Browse files
committed
remove unused funcitonality
1 parent 92c5f8b commit fec6972

File tree

4 files changed

+10
-87
lines changed

4 files changed

+10
-87
lines changed

nattlua/analyzer/control_flow.lua

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ local debug_getinfo = _G.debug.getinfo
1111
-- this turns out to be really hard so I'm trying
1212
-- naive approaches while writing tests
1313
return function(META)
14+
META:AddInitializer(function(self)
15+
self.call_stack_map = {}
16+
self.recursively_called = {}
17+
end)
18+
1419
function META:AnalyzeStatements(statements)
1520
for _, statement in ipairs(statements) do
1621
self:AnalyzeStatement(statement)
@@ -402,9 +407,7 @@ return function(META)
402407
end
403408

404409
function META:PushCallFrame(obj, call_node, not_recursive_call)
405-
self.call_stack_map = self.call_stack_map or {}
406-
407-
if obj.recursively_called then return obj.recursively_called end
410+
if self.recursively_called[obj] then return self.recursively_called[obj] end
408411

409412
if
410413
self:IsRuntime() and
@@ -416,13 +419,13 @@ return function(META)
416419
if self.call_stack_map[call_node] then
417420
if obj:IsExplicitOutputSignature() then
418421
-- so if we have explicit return types, just return those
419-
obj.recursively_called = obj:GetOutputSignature():Copy()
420-
return obj.recursively_called
422+
self.recursively_called[obj] = obj:GetOutputSignature():Copy()
423+
return self.recursively_called[obj]
421424
else
422425
-- if not we sadly have to resort to any
423426
-- TODO: error?
424-
obj.recursively_called = Tuple():AddRemainder(Tuple({Any()}):SetRepeat(math_huge))
425-
return obj.recursively_called
427+
self.recursively_called[obj] = Tuple():AddRemainder(Tuple({Any()}):SetRepeat(math_huge))
428+
return self.recursively_called[obj]
426429
end
427430
end
428431
end

nattlua/analyzer/operators/function_call_body.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,6 @@ return function(self, obj, input)
442442
self:ClearScopedTrackedObjects(scope)
443443
self:PopStashedTrackedChanges()
444444
restore_mutated_types(self)
445-
-- used for analyzing side effects
446-
obj:AddScope(scope)
447445

448446
-- if the function is untyped we warn about untyped arguments
449447
-- and we also merge merge the input into the function's input signature

nattlua/types/function.lua

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ local META = require("nattlua.types.base")()
1111
--[[#type META.@Name = "TFunction"]]
1212
--[[#type TFunction = META.@Self]]
1313
--[[#type TFunction.scopes = List<|any|>]]
14-
--[[#type TFunction.scope = any]]
1514
--[[#type TFunction.suppress = boolean]]
1615
META.Type = "function"
1716
META:IsSet("Called", false)
@@ -201,34 +200,6 @@ function META.IsCallbackSubsetOf(a--[[#: TFunction]], b--[[#: TFunction]])
201200
return true
202201
end
203202

204-
do
205-
function META:AddScope(scope--[[#: any]])
206-
table.insert(self.scopes, scope)
207-
end
208-
209-
function META:GetSideEffects()
210-
local out = {}
211-
212-
for _, scope in ipairs(self.scopes) do
213-
for _, val in ipairs(scope:GetDependencies()) do
214-
if (val.Type == "upvalue" and val:GetScope() or val.scope) ~= scope then
215-
table.insert(out, val)
216-
end
217-
end
218-
end
219-
220-
return out
221-
end
222-
223-
function META:GetCallCount()
224-
return #self.scopes
225-
end
226-
227-
function META:IsPure()
228-
return #self:GetSideEffects() == 0
229-
end
230-
end
231-
232203
function META:HasReferenceTypes()
233204
for i, v in ipairs(self:GetInputSignature():GetData()) do
234205
if self:IsInputModifier(i, "ref") then return true end
@@ -281,11 +252,8 @@ function META.New(input--[[#: TTuple]], output--[[#: TTuple]])
281252
ExplicitOutputSignature = false,
282253
ArgumentsInferred = false,
283254
PreventInputArgumentExpansion = false,
284-
scopes = {},
285-
scope = false,
286255
InputSignature = input or false,
287256
OutputSignature = output or false,
288-
recursively_called = false,
289257
AnalyzerFunction = false,
290258
FunctionBodyNode = false,
291259
Upvalue = false,

test/tests/nattlua/analyzer/side_effects.lua

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)