From 8cc81dcffe2a798109fb58f27d2643d215a7e21f Mon Sep 17 00:00:00 2001 From: JCWasmx86 Date: Mon, 25 May 2020 16:40:25 +0200 Subject: [PATCH] Typo, replaced crlf with lf in some files --- .../inetsoftware/classparser/Attributes.java | 190 ++++++++-------- .../classparser/ConstantClass.java | 62 +++--- .../classparser/ConstantFieldRef.java | 52 ++--- .../classparser/ConstantInterfaceRef.java | 54 ++--- .../classparser/ConstantMethodRef.java | 54 ++--- .../classparser/ConstantNameAndType.java | 86 ++++---- .../inetsoftware/classparser/Exceptions.java | 104 ++++----- .../classparser/LineNumberTable.java | 208 +++++++++--------- .../classparser/TryCatchFinally.java | 142 ++++++------ .../jwebassembly/module/CodeOptimizer.java | 2 +- .../jwebassembly/module/ModuleGenerator.java | 2 +- 11 files changed, 478 insertions(+), 478 deletions(-) diff --git a/src/de/inetsoftware/classparser/Attributes.java b/src/de/inetsoftware/classparser/Attributes.java index f99848e..c60429c 100644 --- a/src/de/inetsoftware/classparser/Attributes.java +++ b/src/de/inetsoftware/classparser/Attributes.java @@ -1,95 +1,95 @@ -/* - Copyright 2011 - 2017 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. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ -package de.inetsoftware.classparser; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.IOException; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -/** - * @author Volker Berlin - */ -public class Attributes { - - private final AttributeInfo[] attributes; - - private final ConstantPool constantPool; - - Attributes( @Nonnull DataInputStream input, @Nonnull ConstantPool constantPool ) throws IOException { - this.constantPool = constantPool; - this.attributes = readAttributs( input ); - } - - private AttributeInfo[] readAttributs( @Nonnull DataInputStream input ) throws IOException { - AttributeInfo[] attrs = new AttributeInfo[input.readUnsignedShort()]; - for( int i = 0; i < attrs.length; i++ ) { - attrs[i] = new AttributeInfo( input, constantPool ); - } - return attrs; - } - - @Nullable - AttributeInfo get( String name ) { - for( AttributeInfo attr : attributes ) { - if( attr.getName().equals( name ) ) { - return attr; - } - } - return null; - } - - static class AttributeInfo { - - private final String name; - - private final byte[] info; - - AttributeInfo( @Nonnull DataInputStream input, @Nonnull ConstantPool constantPool ) throws IOException { - this.name = (String)constantPool.get( input.readUnsignedShort() ); - this.info = new byte[input.readInt()]; - input.readFully( this.info ); - } - - String getName() { - return name; - } - - byte[] getData() { - return info; - } - - DataInputStream getDataInputStream(){ - return new DataInputStream( new ByteArrayInputStream( info ) ); - } - } - - /** - * Get value of SourceFile if available. - * @return the source file name or null. - * @throws IOException if an I/O error occurs. - */ - public String getSourceFile() throws IOException{ - AttributeInfo data = get( "SourceFile" ); - if( data == null ) { - return null; - } - return (String)constantPool.get( data.getDataInputStream().readUnsignedShort() ); - } -} +/* + Copyright 2011 - 2017 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ +package de.inetsoftware.classparser; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * @author Volker Berlin + */ +public class Attributes { + + private final AttributeInfo[] attributes; + + private final ConstantPool constantPool; + + Attributes( @Nonnull DataInputStream input, @Nonnull ConstantPool constantPool ) throws IOException { + this.constantPool = constantPool; + this.attributes = readAttributs( input ); + } + + private AttributeInfo[] readAttributs( @Nonnull DataInputStream input ) throws IOException { + AttributeInfo[] attrs = new AttributeInfo[input.readUnsignedShort()]; + for( int i = 0; i < attrs.length; i++ ) { + attrs[i] = new AttributeInfo( input, constantPool ); + } + return attrs; + } + + @Nullable + AttributeInfo get( String name ) { + for( AttributeInfo attr : attributes ) { + if( attr.getName().equals( name ) ) { + return attr; + } + } + return null; + } + + static class AttributeInfo { + + private final String name; + + private final byte[] info; + + AttributeInfo( @Nonnull DataInputStream input, @Nonnull ConstantPool constantPool ) throws IOException { + this.name = (String)constantPool.get( input.readUnsignedShort() ); + this.info = new byte[input.readInt()]; + input.readFully( this.info ); + } + + String getName() { + return name; + } + + byte[] getData() { + return info; + } + + DataInputStream getDataInputStream(){ + return new DataInputStream( new ByteArrayInputStream( info ) ); + } + } + + /** + * Get value of SourceFile if available. + * @return the source file name or null. + * @throws IOException if an I/O error occurs. + */ + public String getSourceFile() throws IOException{ + AttributeInfo data = get( "SourceFile" ); + if( data == null ) { + return null; + } + return (String)constantPool.get( data.getDataInputStream().readUnsignedShort() ); + } +} diff --git a/src/de/inetsoftware/classparser/ConstantClass.java b/src/de/inetsoftware/classparser/ConstantClass.java index 7a2be0e..ff32511 100644 --- a/src/de/inetsoftware/classparser/ConstantClass.java +++ b/src/de/inetsoftware/classparser/ConstantClass.java @@ -1,32 +1,32 @@ -/* - Copyright 2011 - 2017 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. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ -package de.inetsoftware.classparser; - -/** - * @author Volker Berlin - */ -public class ConstantClass { - private final String name; - - ConstantClass( String name ) { - this.name = name; - } - - public String getName() { - return name; - } +/* + Copyright 2011 - 2017 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ +package de.inetsoftware.classparser; + +/** + * @author Volker Berlin + */ +public class ConstantClass { + private final String name; + + ConstantClass( String name ) { + this.name = name; + } + + public String getName() { + return name; + } } \ No newline at end of file diff --git a/src/de/inetsoftware/classparser/ConstantFieldRef.java b/src/de/inetsoftware/classparser/ConstantFieldRef.java index 2d36eb1..467fb4d 100644 --- a/src/de/inetsoftware/classparser/ConstantFieldRef.java +++ b/src/de/inetsoftware/classparser/ConstantFieldRef.java @@ -1,27 +1,27 @@ -/* - Copyright 2011 - 2017 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. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ -package de.inetsoftware.classparser; - -/** - * @author Volker Berlin - */ -public class ConstantFieldRef extends ConstantRef { - - ConstantFieldRef( ConstantClass constClass, ConstantNameAndType nameAndType ) { - super( constClass, nameAndType ); - } +/* + Copyright 2011 - 2017 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ +package de.inetsoftware.classparser; + +/** + * @author Volker Berlin + */ +public class ConstantFieldRef extends ConstantRef { + + ConstantFieldRef( ConstantClass constClass, ConstantNameAndType nameAndType ) { + super( constClass, nameAndType ); + } } \ No newline at end of file diff --git a/src/de/inetsoftware/classparser/ConstantInterfaceRef.java b/src/de/inetsoftware/classparser/ConstantInterfaceRef.java index 461488f..986084d 100644 --- a/src/de/inetsoftware/classparser/ConstantInterfaceRef.java +++ b/src/de/inetsoftware/classparser/ConstantInterfaceRef.java @@ -1,27 +1,27 @@ -/* - Copyright 2017 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. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ -package de.inetsoftware.classparser; - -/** - * @author Volker Berlin - */ -public class ConstantInterfaceRef extends ConstantRef { - - ConstantInterfaceRef( ConstantClass constClass, ConstantNameAndType nameAndType ) { - super( constClass, nameAndType ); - } -} +/* + Copyright 2017 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ +package de.inetsoftware.classparser; + +/** + * @author Volker Berlin + */ +public class ConstantInterfaceRef extends ConstantRef { + + ConstantInterfaceRef( ConstantClass constClass, ConstantNameAndType nameAndType ) { + super( constClass, nameAndType ); + } +} diff --git a/src/de/inetsoftware/classparser/ConstantMethodRef.java b/src/de/inetsoftware/classparser/ConstantMethodRef.java index 3745928..45b6727 100644 --- a/src/de/inetsoftware/classparser/ConstantMethodRef.java +++ b/src/de/inetsoftware/classparser/ConstantMethodRef.java @@ -1,27 +1,27 @@ -/* - Copyright 2011 - 2017 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. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ -package de.inetsoftware.classparser; - -/** - * @author Volker Berlin - */ -public class ConstantMethodRef extends ConstantRef { - - ConstantMethodRef( ConstantClass constClass, ConstantNameAndType nameAndType ) { - super( constClass, nameAndType ); - } -} +/* + Copyright 2011 - 2017 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ +package de.inetsoftware.classparser; + +/** + * @author Volker Berlin + */ +public class ConstantMethodRef extends ConstantRef { + + ConstantMethodRef( ConstantClass constClass, ConstantNameAndType nameAndType ) { + super( constClass, nameAndType ); + } +} diff --git a/src/de/inetsoftware/classparser/ConstantNameAndType.java b/src/de/inetsoftware/classparser/ConstantNameAndType.java index d8909c6..78b070f 100644 --- a/src/de/inetsoftware/classparser/ConstantNameAndType.java +++ b/src/de/inetsoftware/classparser/ConstantNameAndType.java @@ -1,43 +1,43 @@ -/* - Copyright 2011 - 2017 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. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ -package de.inetsoftware.classparser; - -/** - * @author Volker Berlin - */ -public class ConstantNameAndType{ - - private final String name; - private final String type; - - public ConstantNameAndType(String name, String type){ - this.name = name; - this.type = type; - } - - public String getName(){ - return name; - } - - /** - * The type of the variable in class file syntax. - * @return the type - */ - public String getType(){ - return type; - } -} +/* + Copyright 2011 - 2017 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ +package de.inetsoftware.classparser; + +/** + * @author Volker Berlin + */ +public class ConstantNameAndType{ + + private final String name; + private final String type; + + public ConstantNameAndType(String name, String type){ + this.name = name; + this.type = type; + } + + public String getName(){ + return name; + } + + /** + * The type of the variable in class file syntax. + * @return the type + */ + public String getType(){ + return type; + } +} diff --git a/src/de/inetsoftware/classparser/Exceptions.java b/src/de/inetsoftware/classparser/Exceptions.java index 3ffdd4d..cee98b9 100644 --- a/src/de/inetsoftware/classparser/Exceptions.java +++ b/src/de/inetsoftware/classparser/Exceptions.java @@ -1,52 +1,52 @@ -/* - Copyright 2017 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. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ -package de.inetsoftware.classparser; - -import java.io.DataInputStream; -import java.io.IOException; - -/** - * Exceptions attribute of methods. - * - * @author Volker Berlin - */ -public class Exceptions { - - ConstantClass[] classes; - - /** - * Read the Exceptions structure. - * http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.5 - * http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#3129 - * - * @param input - * @param constantPool - * @throws IOException - */ - Exceptions( DataInputStream input, ConstantPool constantPool ) throws IOException { - int count = input.readUnsignedShort(); - classes = new ConstantClass[count]; - for( int i = 0; i < count; i++ ) { - int idx = input.readUnsignedShort(); - classes[i] = (ConstantClass)constantPool.get( idx ); - } - } - - public ConstantClass[] getClasses() { - return classes; - } -} +/* + Copyright 2017 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ +package de.inetsoftware.classparser; + +import java.io.DataInputStream; +import java.io.IOException; + +/** + * Exceptions attribute of methods. + * + * @author Volker Berlin + */ +public class Exceptions { + + ConstantClass[] classes; + + /** + * Read the Exceptions structure. + * http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.5 + * http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#3129 + * + * @param input + * @param constantPool + * @throws IOException + */ + Exceptions( DataInputStream input, ConstantPool constantPool ) throws IOException { + int count = input.readUnsignedShort(); + classes = new ConstantClass[count]; + for( int i = 0; i < count; i++ ) { + int idx = input.readUnsignedShort(); + classes[i] = (ConstantClass)constantPool.get( idx ); + } + } + + public ConstantClass[] getClasses() { + return classes; + } +} diff --git a/src/de/inetsoftware/classparser/LineNumberTable.java b/src/de/inetsoftware/classparser/LineNumberTable.java index dda3d21..58be1f1 100644 --- a/src/de/inetsoftware/classparser/LineNumberTable.java +++ b/src/de/inetsoftware/classparser/LineNumberTable.java @@ -1,104 +1,104 @@ -/* - Copyright 2011 - 2017 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. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ -package de.inetsoftware.classparser; - -import java.io.DataInputStream; -import java.io.IOException; - -/** - * @author Volker Berlin - */ -public class LineNumberTable { - - private final int start_pc[]; - - private final int line_number[]; - - /** - * http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.12 - * http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#22856 - * - * @param input - * the stream of the class - * @throws IOException - */ - LineNumberTable( DataInputStream input ) throws IOException { - int count = input.readUnsignedShort(); - start_pc = new int[count]; - line_number = new int[count]; - for( int i = 0; i < count; i++ ) { - start_pc[i] = input.readUnsignedShort(); - line_number[i] = input.readUnsignedShort(); - } - } - - /** - * Count of entries - * - * @return the count - */ - public int size() { - return start_pc.length; - } - - /** - * Get the offset of the code - * - * @param idx - * the table position - * @return the code offset - */ - public int getStartOffset( int idx ) { - return start_pc[idx]; - } - - /** - * Get the line number - * - * @param idx - * the table position - * @return the line number - */ - public int getLineNumber( int idx ) { - return line_number[idx]; - } - - /** - * Get the line number of the last code block. - * @return - */ - public int getLastLineNr() { - return line_number[line_number.length - 1]; - } - - public int getMinLineNr(){ - int min = 0xFFFF; - for( int nr : line_number ){ - min = Math.min( min, nr ); - } - return min; - } - - public int getMaxLineNr(){ - int max = -1; - for( int nr : line_number ){ - max = Math.max( max, nr ); - } - return max; - } - -} +/* + Copyright 2011 - 2017 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ +package de.inetsoftware.classparser; + +import java.io.DataInputStream; +import java.io.IOException; + +/** + * @author Volker Berlin + */ +public class LineNumberTable { + + private final int start_pc[]; + + private final int line_number[]; + + /** + * http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.12 + * http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#22856 + * + * @param input + * the stream of the class + * @throws IOException + */ + LineNumberTable( DataInputStream input ) throws IOException { + int count = input.readUnsignedShort(); + start_pc = new int[count]; + line_number = new int[count]; + for( int i = 0; i < count; i++ ) { + start_pc[i] = input.readUnsignedShort(); + line_number[i] = input.readUnsignedShort(); + } + } + + /** + * Count of entries + * + * @return the count + */ + public int size() { + return start_pc.length; + } + + /** + * Get the offset of the code + * + * @param idx + * the table position + * @return the code offset + */ + public int getStartOffset( int idx ) { + return start_pc[idx]; + } + + /** + * Get the line number + * + * @param idx + * the table position + * @return the line number + */ + public int getLineNumber( int idx ) { + return line_number[idx]; + } + + /** + * Get the line number of the last code block. + * @return + */ + public int getLastLineNr() { + return line_number[line_number.length - 1]; + } + + public int getMinLineNr(){ + int min = 0xFFFF; + for( int nr : line_number ){ + min = Math.min( min, nr ); + } + return min; + } + + public int getMaxLineNr(){ + int max = -1; + for( int nr : line_number ){ + max = Math.max( max, nr ); + } + return max; + } + +} diff --git a/src/de/inetsoftware/classparser/TryCatchFinally.java b/src/de/inetsoftware/classparser/TryCatchFinally.java index 07a8d8c..fc8d3af 100644 --- a/src/de/inetsoftware/classparser/TryCatchFinally.java +++ b/src/de/inetsoftware/classparser/TryCatchFinally.java @@ -1,71 +1,71 @@ -/* - Copyright 2017 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. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -*/ -package de.inetsoftware.classparser; - -import java.io.DataInputStream; -import java.io.IOException; - -import javax.annotation.Nonnull; - -/** - * @author Volker Berlin - */ -public class TryCatchFinally { - - private final int start; - - private final int end; - - private final int handler; - - private final ConstantClass type; - - /** - * http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.3 - * http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#1546 - * - * @param input - * @param constantPool - * @throws IOException - */ - TryCatchFinally( DataInputStream input, @Nonnull ConstantPool constantPool ) throws IOException { - start = input.readUnsignedShort(); - end = input.readUnsignedShort(); - handler = input.readUnsignedShort(); - type = (ConstantClass)constantPool.get( input.readUnsignedShort() ); - } - - public int getStart() { - return start; - } - - public int getEnd() { - return end; - } - - public int getHandler() { - return handler; - } - - public ConstantClass getType() { - return type; - } - - public boolean isFinally() { - return type == null; - } -} +/* + Copyright 2017 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. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +*/ +package de.inetsoftware.classparser; + +import java.io.DataInputStream; +import java.io.IOException; + +import javax.annotation.Nonnull; + +/** + * @author Volker Berlin + */ +public class TryCatchFinally { + + private final int start; + + private final int end; + + private final int handler; + + private final ConstantClass type; + + /** + * http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.3 + * http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#1546 + * + * @param input + * @param constantPool + * @throws IOException + */ + TryCatchFinally( DataInputStream input, @Nonnull ConstantPool constantPool ) throws IOException { + start = input.readUnsignedShort(); + end = input.readUnsignedShort(); + handler = input.readUnsignedShort(); + type = (ConstantClass)constantPool.get( input.readUnsignedShort() ); + } + + public int getStart() { + return start; + } + + public int getEnd() { + return end; + } + + public int getHandler() { + return handler; + } + + public ConstantClass getType() { + return type; + } + + public boolean isFinally() { + return type == null; + } +} diff --git a/src/de/inetsoftware/jwebassembly/module/CodeOptimizer.java b/src/de/inetsoftware/jwebassembly/module/CodeOptimizer.java index 0b46606..bdd33a8 100644 --- a/src/de/inetsoftware/jwebassembly/module/CodeOptimizer.java +++ b/src/de/inetsoftware/jwebassembly/module/CodeOptimizer.java @@ -33,7 +33,7 @@ class CodeOptimizer { * @param instructions * the list of instructions */ - void optimze( List instructions ) { + void optimize( List instructions ) { for( int i = instructions.size()-1; i >= 0; i-- ) { WasmInstruction instr = instructions.get( i ); switch( instr.getType() ) { diff --git a/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java b/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java index 7374818..f3c03b0 100644 --- a/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java +++ b/src/de/inetsoftware/jwebassembly/module/ModuleGenerator.java @@ -574,7 +574,7 @@ public class ModuleGenerator { writeMethodSignature( name, FunctionType.Code, codeBuilder ); List instructions = codeBuilder.getInstructions(); - optimizer.optimze( instructions ); + optimizer.optimize( instructions ); int lastJavaSourceLine = -1; for( WasmInstruction instruction : instructions ) {