From 765e06d34180d9dfc5195ed7d9bfaba59d98b0e4 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 3 Aug 2017 10:56:48 +0200 Subject: [PATCH] improve solidity reduced trace --- src/util/internalCallTree.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/util/internalCallTree.js b/src/util/internalCallTree.js index 00641104b1..10c28fac16 100644 --- a/src/util/internalCallTree.js +++ b/src/util/internalCallTree.js @@ -116,14 +116,21 @@ async function buildTree (tree, step, scopeId) { return false } - var currentSourceLocation = {} + function includedSource (source, included) { + return (included.start !== -1 && + included.length !== -1 && + included.file !== -1 && + included.start >= source.start && + included.start + included.length <= source.start + source.length && + included.file === source.file) + } + + var currentSourceLocation = {start: -1, length: -1, file: -1} while (step < tree.traceManager.trace.length) { var sourceLocation try { sourceLocation = await tree.extractSourceLocation(step) - if (sourceLocation.start !== currentSourceLocation.start || - sourceLocation.length !== currentSourceLocation.length || - sourceLocation.file !== currentSourceLocation.file) { + if (!includedSource(sourceLocation, currentSourceLocation)) { tree.reducedTrace.push(step) currentSourceLocation = sourceLocation }