mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
Pass maxLocals ever to the LocalVariableTable
This commit is contained in:
parent
5ea58e30f8
commit
275db31ab3
@ -104,10 +104,12 @@ public class Code {
|
|||||||
}
|
}
|
||||||
AttributeInfo data = attributes.get( "LocalVariableTable" );
|
AttributeInfo data = attributes.get( "LocalVariableTable" );
|
||||||
if( data != null ) {
|
if( data != null ) {
|
||||||
localVariableTable = new LocalVariableTable( maxLocals, constantPool );
|
localVariableTable = new LocalVariableTable( maxLocals, constantPool, data.getDataInputStream() );
|
||||||
localVariableTable.read( data.getDataInputStream() );
|
|
||||||
// we does not need any generics information
|
// we does not need any generics information
|
||||||
// data = attributes.get( "LocalVariableTypeTable" );
|
// data = attributes.get( "LocalVariableTypeTable" );
|
||||||
|
} else {
|
||||||
|
// return only the maxLocals
|
||||||
|
localVariableTable = new LocalVariableTable( maxLocals );
|
||||||
}
|
}
|
||||||
return localVariableTable;
|
return localVariableTable;
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,6 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public class LocalVariableTable {
|
public class LocalVariableTable {
|
||||||
|
|
||||||
private final ConstantPool constantPool;
|
|
||||||
|
|
||||||
private final int maxLocals;
|
private final int maxLocals;
|
||||||
|
|
||||||
private LocalVariable[] table;
|
private LocalVariable[] table;
|
||||||
@ -33,26 +31,21 @@ public class LocalVariableTable {
|
|||||||
/**
|
/**
|
||||||
* Create a new instance of the code attribute "LocalVariableTable".
|
* Create a new instance of the code attribute "LocalVariableTable".
|
||||||
*
|
*
|
||||||
|
* http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.13
|
||||||
|
* http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#5956
|
||||||
|
|
||||||
* @param maxLocals
|
* @param maxLocals
|
||||||
* the count of local variables in the memory
|
* the count of local variables in the memory
|
||||||
* @param constantPool
|
* @param constantPool
|
||||||
* Reference to the current ConstantPool
|
* Reference to the current ConstantPool
|
||||||
*/
|
|
||||||
LocalVariableTable( int maxLocals, ConstantPool constantPool ) {
|
|
||||||
this.maxLocals = maxLocals;
|
|
||||||
this.constantPool = constantPool;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.13
|
|
||||||
* http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#5956
|
|
||||||
*
|
|
||||||
* @param input
|
* @param input
|
||||||
* the stream of the class
|
* the stream of the class
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* if any I/O error occurs.
|
* if any I/O error occurs.
|
||||||
*/
|
*/
|
||||||
void read( DataInputStream input ) throws IOException {
|
LocalVariableTable( int maxLocals, ConstantPool constantPool, DataInputStream input ) throws IOException {
|
||||||
|
this.maxLocals = maxLocals;
|
||||||
|
|
||||||
int count = input.readUnsignedShort();
|
int count = input.readUnsignedShort();
|
||||||
table = new LocalVariable[count];
|
table = new LocalVariable[count];
|
||||||
for( int i = 0; i < count; i++ ) {
|
for( int i = 0; i < count; i++ ) {
|
||||||
@ -60,6 +53,18 @@ public class LocalVariableTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance without any debug details.
|
||||||
|
*
|
||||||
|
* @param maxLocals
|
||||||
|
* the count of local variables in the memory
|
||||||
|
*/
|
||||||
|
LocalVariableTable( int maxLocals ) {
|
||||||
|
this.maxLocals = maxLocals;
|
||||||
|
|
||||||
|
table = new LocalVariable[0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the count of variables/slots. This is not the count of declared LocalVariable in this table. There can be
|
* Get the count of variables/slots. This is not the count of declared LocalVariable in this table. There can be
|
||||||
* unnamed helper variables for the compiler which are not in the table. There can be reused slots for different
|
* unnamed helper variables for the compiler which are not in the table. There can be reused slots for different
|
||||||
|
Loading…
x
Reference in New Issue
Block a user