@@ -194,6 +194,9 @@ export async function includeVariableDeclaration (tree: InternalCallTree, step,
194194 for ( const variableDeclaration of variableDeclarations ) {
195195 if ( variableDeclaration ) {
196196 try {
197+ // check if already processed
198+ if ( tree . scopes [ scopeId ] && tree . scopes [ scopeId ] . locals && tree . scopes [ scopeId ] . locals [ variableDeclaration . name ] ) continue
199+
197200 const stack = tree . traceManager . getStackAt ( step )
198201 // the stack length at this point is where the value of the new local variable will be stored.
199202 // so, either this is the direct value, or the offset in memory. That depends on the type.
@@ -253,21 +256,22 @@ export async function includeVariableDeclaration (tree: InternalCallTree, step,
253256 Without the fix below the second PUSH will register the var at index 4.
254257 That isn't a really good way of fixing this, need to find a better solution.
255258 */
259+ /*
256260 try {
257261 const symbolicStack = tree.symbolicStackManager.getStackAtStep(step)
258262 if (symbolicStack && symbolicStack.length && symbolicStack[symbolicStack.length - 1] &&
259263 symbolicStack && symbolicStack.length && symbolicStack[symbolicStack.length - 2]) {
260264 const testDup = symbolicStack[symbolicStack.length - 1]
261265 const testPush = symbolicStack[symbolicStack.length - 2]
262266 if (testDup.originOp && testDup.kind && testDup.kind === 'intermediate' && testDup.originOp.startsWith('DUP') &&
263- testPush . kind && testPush . kind === 'variable' && testPush . originStep === step - 2 ) {
267+ testPush.kind && ( testPush.kind === 'variable' || testPush.kind === 'return_value') ) {
264268 console.warn('applying stack fix', step, symbolicStack)
265269 stackIndex = stack.length - 1
266270 }
267271 }
268272 } catch (e) {
269273 console.warn(e)
270- }
274+ }*/
271275
272276 // Bind variable to symbolic stack with appropriate lifecycle
273277 const variable = isReturnParamDeclaration ? existingReturnParam : newVar
0 commit comments