From 758557f76bc8cc35d91b1e58c13a61e4c46ec7eb Mon Sep 17 00:00:00 2001 From: Volker Date: Sat, 11 Aug 2018 20:36:09 +0200 Subject: [PATCH] Fix getTempI32() that it work without the removed prepare phase. --- .../jwebassembly/module/LocaleVariableManager.java | 13 +++++-------- .../jwebassembly/module/ModuleGenerator.java | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/de/inetsoftware/jwebassembly/module/LocaleVariableManager.java b/src/de/inetsoftware/jwebassembly/module/LocaleVariableManager.java index 7c0abd2..01d08d5 100644 --- a/src/de/inetsoftware/jwebassembly/module/LocaleVariableManager.java +++ b/src/de/inetsoftware/jwebassembly/module/LocaleVariableManager.java @@ -83,13 +83,6 @@ class LocaleVariableManager { var.valueType = valueType; } - /** - * We need an extra temporary variable inn the WebAssembly code. - */ - void useTempI32() { - needTempI32 = true; - } - /** * Calculate the WebAssembly index position on the consumed data. */ @@ -131,7 +124,8 @@ class LocaleVariableManager { * @return the slot */ int getTempI32() { - return size - 1; + needTempI32 = true; + return -1; } /** @@ -142,6 +136,9 @@ class LocaleVariableManager { * @return the variable index in WebAssembly */ int get( int slot ) { + if( slot < 0 ) { + slot = size - 1; // temp i32 + } return variables[slot].idx; } diff --git a/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java b/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java index 9680e8c..3b6708c 100644 --- a/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java +++ b/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java @@ -751,7 +751,6 @@ public class ModuleGenerator { int[] keys; int[] positions; if( isLookupSwitch ) { // lookupswitch - localVariables.useTempI32(); //TODO int count = byteCode.readInt(); keys = new int[count]; positions = new int[count];