mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Fix functions defined in code injection conflict due to reference reuse
This commit is contained in:
parent
b89095bbd2
commit
eb3a1d3f2c
2 changed files with 9 additions and 8 deletions
|
|
@ -116,7 +116,7 @@ local interpreter_methods = {
|
||||||
return self
|
return self
|
||||||
end,
|
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
|
-- returns self
|
||||||
interrupt = function(self, expr)
|
interrupt = function(self, expr)
|
||||||
self.state.interpreter.interrupt = expr or true
|
self.state.interpreter.interrupt = expr or true
|
||||||
|
|
|
||||||
|
|
@ -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
|
local parse_indented
|
||||||
|
|
||||||
|
|
@ -202,23 +202,23 @@ local function parse_line(line, state, namespace)
|
||||||
if r.scoped then
|
if r.scoped then
|
||||||
if state.inject.scoped_function_start then
|
if state.inject.scoped_function_start then
|
||||||
for i, ll in ipairs(state.inject.scoped_function_start) do
|
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
|
||||||
end
|
end
|
||||||
if state.inject.scoped_function_end then
|
if state.inject.scoped_function_end then
|
||||||
for _, ll in ipairs(state.inject.scoped_function_end) do
|
for _, ll in ipairs(state.inject.scoped_function_end) do
|
||||||
table.insert(line.children, ll)
|
table.insert(line.children, copy(ll))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if state.inject.function_start then
|
if state.inject.function_start then
|
||||||
for i, ll in ipairs(state.inject.function_start) do
|
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
|
||||||
end
|
end
|
||||||
if state.inject.function_end then
|
if state.inject.function_end then
|
||||||
for _, ll in ipairs(state.inject.function_end) do
|
for _, ll in ipairs(state.inject.function_end) do
|
||||||
table.insert(line.children, ll)
|
table.insert(line.children, copy(ll))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -233,12 +233,12 @@ local function parse_line(line, state, namespace)
|
||||||
-- custom code injection
|
-- custom code injection
|
||||||
if state.inject.checkpoint_start then
|
if state.inject.checkpoint_start then
|
||||||
for i, ll in ipairs(state.inject.checkpoint_start) do
|
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
|
||||||
end
|
end
|
||||||
if state.inject.checkpoint_end then
|
if state.inject.checkpoint_end then
|
||||||
for _, ll in ipairs(state.inject.checkpoint_end) do
|
for _, ll in ipairs(state.inject.checkpoint_end) do
|
||||||
table.insert(line.children, ll)
|
table.insert(line.children, copy(ll))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -530,5 +530,6 @@ end
|
||||||
package.loaded[...] = parse
|
package.loaded[...] = parse
|
||||||
local common = require((...):gsub("preparser$", "common"))
|
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
|
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
|
return parse
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue