prevent overriding foundational definitions

[?]
Apr 10, 2023, 5:29 AM
WYKKFV2GP7JRPN4SCWTHECFCQCHCIOMUP2TNNX5YACQAEKJ5QP5QC

Dependencies

  • [2] QFURHRTP rename globals to have a single uppercase letter
  • [*] LRDM35CE app running again

Change contents

  • edit in live.lua at line 38
    [2.221]
    [4.1988]
    live.freeze_all_existing_definitions()
  • edit in live.lua at line 43
    [4.2048]
    [4.2048]
    end
    -- Everything that exists before we start loading the live files is frozen and
    -- can't be edited live.
    function live.freeze_all_existing_definitions()
    Live.frozen_definitions = {on=true} -- special case for version 1
    local done = {}
    done[Live.frozen_definitions]=true
    live.freeze_all_existing_definitions_in(_G, {}, done)
    end
    function live.freeze_all_existing_definitions_in(tab, scopes, done)
    -- track duplicates to avoid cycles like _G._G, _G._G._G, etc.
    if done[tab] then return end
    done[tab] = true
    for name,binding in pairs(tab) do
    local full_name = live.full_name(scopes, name)
    --? print(full_name)
    Live.frozen_definitions[full_name] = true
    if type(binding) == 'table' and full_name ~= 'package' then -- var 'package' contains copies of all modules, but not the best name; rely on people to not modify package.loaded.io.open, etc.
    table.insert(scopes, name)
    live.freeze_all_existing_definitions_in(binding, scopes, done)
    table.remove(scopes)
    end
    end
    end
    function live.full_name(scopes, name)
    local ns = table.concat(scopes, '.')
    if #ns == 0 then return name end
    return ns..'.'..name
  • edit in live.lua at line 291
    [4.7150]
    [2.1125]
    if Live.frozen_definitions[binding] then
    live.send_to_driver('ERROR definition '..binding..' is part of Freewheeling infrastructure and cannot be safely edited live.')
    return
    end