[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Comparing the binary chunk of two functions for equality
- From: Tom N Harris <telliamed@...>
- Date: Wed, 19 Feb 2014 14:24:08 -0500
On Wednesday, February 19, 2014 08:53:05 AM Joachim Bürmann wrote:
> I'm trying to compare the binary chunk of two functions for equality.
> The background:
> I have to know if the body of a given function was changed. If so, the
> function must new applied to the recorded data.
> The difficulty: Changed comments or the insertion of some syntax
> irrelevant white spaces must ignored!
> Otherwise every additional line feed or corrected comment forces a new
> call and redisplay of the protocol data (which sometimes is a time
> consuming process).
You should be able to do this with an AST compiled by metalua. Which should be
easier to use now that it's been split into a metalua-parser rock. Here's a
function ast_compare(ast1, ast2)
if ast1.tag ~= ast2.tag then
if #ast1 ~= #ast2 then
for i = 1, #ast1 do
if type(ast1[i]) ~= type(ast2[i]) then
if type(ast1[i]) == 'table' then
if not ast_compare(ast1[i], ast2[i]) then
if ast1[i] ~= ast2[i] then
Completely untested, but that's the idea. Metalua stores debugging information
in a 'lineinfo' field that can be ignored.