diff --git a/src/de/inetsoftware/jwebassembly/module/JavaMethodWasmCodeBuilder.java b/src/de/inetsoftware/jwebassembly/module/JavaMethodWasmCodeBuilder.java index e07ac26..d2d3980 100644 --- a/src/de/inetsoftware/jwebassembly/module/JavaMethodWasmCodeBuilder.java +++ b/src/de/inetsoftware/jwebassembly/module/JavaMethodWasmCodeBuilder.java @@ -224,6 +224,8 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder { addBlockInstruction( WasmBlockOperator.DROP, null, codePos ); break; case 89: // dup: duplicate the value on top of the stack + addCallInstruction( new SyntheticMember( "de/inetsoftware/jwebassembly/module/NativeHelperCode", "dup_i32", "(I)II" ), codePos ); + break; case 90: // dup_x1 case 91: // dup_x2 case 92: // dup2 diff --git a/src/de/inetsoftware/jwebassembly/module/NativeHelperCode.java b/src/de/inetsoftware/jwebassembly/module/NativeHelperCode.java new file mode 100644 index 0000000..c583ad9 --- /dev/null +++ b/src/de/inetsoftware/jwebassembly/module/NativeHelperCode.java @@ -0,0 +1,25 @@ +/* + * Copyright 2018 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.jwebassembly.module; + +import de.inetsoftware.jwebassembly.api.annotation.WasmTextCode; + +public class NativeHelperCode { + + @WasmTextCode( signature = "(I)II", value = "get_local 0 get_local 0 return" ) + native static void dup_i32(); + + } diff --git a/src/de/inetsoftware/jwebassembly/module/SyntheticMember.java b/src/de/inetsoftware/jwebassembly/module/SyntheticMember.java new file mode 100644 index 0000000..73d6b0d --- /dev/null +++ b/src/de/inetsoftware/jwebassembly/module/SyntheticMember.java @@ -0,0 +1,72 @@ +/* + Copyright 2018 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.jwebassembly.module; + +import de.inetsoftware.classparser.Member; + +/** + * A generated member that come not from the Java class parser. + * + * @author Volker Berlin + */ +public class SyntheticMember implements Member { + + + private final String className; + private final String name; + private final String type; + + /** + * Create a new instance + * + * @param className + * the className + * @param name + * the name + * @param type + * the Java signature + */ + SyntheticMember( String className, String name, String type ) { + this.className = className; + this.name = name; + this.type = type; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return name; + } + + /** + * {@inheritDoc} + */ + @Override + public String getClassName() { + return className; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return type; + } +}