1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-27 08:39:30 +00:00

Fix functions defined in code injection conflict due to reference reuse

This commit is contained in:
Étienne Fildadut 2022-01-16 02:33:53 +01:00
parent b89095bbd2
commit eb3a1d3f2c
2 changed files with 9 additions and 8 deletions

View file

@ -116,7 +116,7 @@ local interpreter_methods = {
return self
end,
--- interrupt the vm on the next step, executing an expression if specified
--- interrupt the vm on the next step, executing an expression (if specified) in the current namespace
-- returns self
interrupt = function(self, expr)
self.state.interpreter.interrupt = expr or true

View file

@ -1,4 +1,4 @@
local format_identifier, identifier_pattern, escape, special_functions_names, pretty_signature, signature
local format_identifier, identifier_pattern, escape, special_functions_names, pretty_signature, signature, copy
local parse_indented
@ -202,23 +202,23 @@ local function parse_line(line, state, namespace)
if r.scoped then
if state.inject.scoped_function_start then
for i, ll in ipairs(state.inject.scoped_function_start) do
table.insert(line.children, 1+i, ll)
table.insert(line.children, 1+i, copy(ll))
end
end
if state.inject.scoped_function_end then
for _, ll in ipairs(state.inject.scoped_function_end) do
table.insert(line.children, ll)
table.insert(line.children, copy(ll))
end
end
else
if state.inject.function_start then
for i, ll in ipairs(state.inject.function_start) do
table.insert(line.children, 1+i, ll)
table.insert(line.children, 1+i, copy(ll))
end
end
if state.inject.function_end then
for _, ll in ipairs(state.inject.function_end) do
table.insert(line.children, ll)
table.insert(line.children, copy(ll))
end
end
end
@ -233,12 +233,12 @@ local function parse_line(line, state, namespace)
-- custom code injection
if state.inject.checkpoint_start then
for i, ll in ipairs(state.inject.checkpoint_start) do
table.insert(line.children, 1+i, ll)
table.insert(line.children, 1+i, copy(ll))
end
end
if state.inject.checkpoint_end then
for _, ll in ipairs(state.inject.checkpoint_end) do
table.insert(line.children, ll)
table.insert(line.children, copy(ll))
end
end
end
@ -530,5 +530,6 @@ end
package.loaded[...] = parse
local common = require((...):gsub("preparser$", "common"))
format_identifier, identifier_pattern, escape, special_functions_names, pretty_signature, signature = common.format_identifier, common.identifier_pattern, common.escape, common.special_functions_names, common.pretty_signature, common.signature
copy = require((...):gsub("parser%.preparser$", "common")).copy
return parse