mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 10:44:47 +01:00
Does not save reused variables. Does not increment the maxLocals count.
This commit is contained in:
parent
6246840f90
commit
b4ca501f4c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2011 - 2018 Volker Berlin (i-net software)
|
||||
Copyright 2011 - 2019 Volker Berlin (i-net software)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -62,22 +62,24 @@ public class LocalVariableTable {
|
||||
*/
|
||||
void read( DataInputStream input, boolean withPositions ) throws IOException {
|
||||
count = input.readUnsignedShort();
|
||||
if( count > table.length ) {
|
||||
table = new LocalVariable[count];
|
||||
tablePosition = new LocalVariable[count];
|
||||
}
|
||||
boolean[] wasSet = new boolean[table.length];
|
||||
for( int i = 0; i < count; i++ ) {
|
||||
LocalVariable var = new LocalVariable( input, i, constantPool );
|
||||
int idx = var.getIndex();
|
||||
if( withPositions ) {
|
||||
tablePosition[i] = var;
|
||||
}
|
||||
if( !wasSet[idx] ) { // does not use index of reused variable
|
||||
table[idx] = var;
|
||||
wasSet[idx] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( withPositions ) {
|
||||
for( int i = 0, t = 0; i < table.length; i++ ) {
|
||||
LocalVariable var = table[i];
|
||||
if( var != null ) {
|
||||
tablePosition[t++] = var;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,7 +87,7 @@ public class LocalVariableTable {
|
||||
* @return the count
|
||||
*/
|
||||
public int getPositionSize() {
|
||||
return count;
|
||||
return tablePosition.length;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user