mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 10:44:47 +01:00
expand the hierarchy of SyntheticFunctionName for future improvements
This commit is contained in:
parent
9692b3b98f
commit
1fdcae5191
@ -19,7 +19,7 @@ package de.inetsoftware.jwebassembly.javascript;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import de.inetsoftware.jwebassembly.module.SyntheticFunctionName;
|
||||
import de.inetsoftware.jwebassembly.module.ArraySyntheticFunctionName;
|
||||
import de.inetsoftware.jwebassembly.wasm.AnyType;
|
||||
|
||||
/**
|
||||
@ -28,7 +28,7 @@ import de.inetsoftware.jwebassembly.wasm.AnyType;
|
||||
* @author Volker Berlin
|
||||
*
|
||||
*/
|
||||
public class JavaScriptSyntheticFunctionName extends SyntheticFunctionName {
|
||||
public class JavaScriptSyntheticFunctionName extends ArraySyntheticFunctionName {
|
||||
|
||||
private final Supplier<String> js;
|
||||
|
||||
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright 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.
|
||||
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 java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import de.inetsoftware.jwebassembly.wasm.AnyType;
|
||||
|
||||
/**
|
||||
* Synthetic/dynamic method with a signature as array of types.
|
||||
*
|
||||
* @author Volker Berlin
|
||||
*/
|
||||
public abstract class ArraySyntheticFunctionName extends SyntheticFunctionName {
|
||||
|
||||
private final AnyType[] signature;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param className
|
||||
* the Java class name
|
||||
* @param name
|
||||
* the function name
|
||||
* @param signature
|
||||
* the method signature, first the parameters, then null and the the return types
|
||||
*/
|
||||
public ArraySyntheticFunctionName( String className, String name, AnyType... signature ) {
|
||||
super( className, name, "()V" ); //TODO better signature name
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Iterator<AnyType> getSignature( TypeManager types ) {
|
||||
return Arrays.asList( signature ).iterator();
|
||||
}
|
||||
}
|
@ -16,11 +16,8 @@
|
||||
*/
|
||||
package de.inetsoftware.jwebassembly.module;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Function;
|
||||
|
||||
import de.inetsoftware.jwebassembly.wasm.AnyType;
|
||||
import de.inetsoftware.jwebassembly.watparser.WatParser;
|
||||
|
||||
/**
|
||||
@ -30,8 +27,6 @@ import de.inetsoftware.jwebassembly.watparser.WatParser;
|
||||
*/
|
||||
public abstract class SyntheticFunctionName extends FunctionName {
|
||||
|
||||
private final AnyType[] signature;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
@ -42,17 +37,8 @@ public abstract class SyntheticFunctionName extends FunctionName {
|
||||
* @param signature
|
||||
* the method signature, first the parameters, then null and the the return types
|
||||
*/
|
||||
public SyntheticFunctionName( String className, String name, AnyType... signature ) {
|
||||
super( className, name, "()V" ); //TODO better signature name
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Iterator<AnyType> getSignature( TypeManager types ) {
|
||||
return Arrays.asList( signature ).iterator();
|
||||
public SyntheticFunctionName( String className, String name, String signature ) {
|
||||
super( className, name, signature );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@ import de.inetsoftware.jwebassembly.watparser.WatParser;
|
||||
*
|
||||
* @author Volker Berlin
|
||||
*/
|
||||
class WatCodeSyntheticFunctionName extends SyntheticFunctionName {
|
||||
class WatCodeSyntheticFunctionName extends ArraySyntheticFunctionName {
|
||||
|
||||
private final String code;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user