Skip to content

Java @WasmTextCode methods can/should be declared as native. #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class ReplacementForDouble {
@WasmTextCode( "local.get 0 " //
+ "i64.reinterpret_f64 " //
+ "return" )
static long doubleToRawLongBits(double value) {
return 0; // for Java compiler
}
static native long doubleToRawLongBits(double value);

/**
* Replacement for Double.longBitsToDouble(long)
Expand All @@ -43,7 +41,5 @@ static long doubleToRawLongBits(double value) {
@WasmTextCode( "local.get 0 " //
+ "f64.reinterpret_i64 " //
+ "return" )
static double longBitsToDouble(long value) {
return 0; // for Java compiler
}
static native double longBitsToDouble(long value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class ReplacementForFloat {
@WasmTextCode( "local.get 0 " //
+ "i32.reinterpret_f32 " //
+ "return" )
static int floatToRawIntBits(float value) {
return 0; // for Java compiler
}
static native int floatToRawIntBits(float value);

/**
* Replacement for Float.intBitsToFloat(int)
Expand All @@ -43,7 +41,5 @@ static int floatToRawIntBits(float value) {
@WasmTextCode( "local.get 0 " //
+ "f32.reinterpret_i32 " //
+ "return" )
static float intBitsToFloat(int value) {
return 0; // for Java compiler
}
static native float intBitsToFloat(int value);
}
124 changes: 31 additions & 93 deletions src/de/inetsoftware/jwebassembly/api/java/lang/ReplacementForMath.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class ReplacementForMath {
*/
@Replace( "java/lang/Math.sin(D)D" )
@Import( module = "Math", name = "sin" )
static double sin( double x ) {
return 0; // for Java compiler
}
static native double sin( double x );

/**
* Replacement for {@link Math#cos(double)}
Expand All @@ -49,9 +47,7 @@ static double sin( double x ) {
*/
@Replace( "java/lang/Math.cos(D)D" )
@Import( module = "Math", name = "cos" )
static double cos( double x ) {
return 0; // for Java compiler
}
static native double cos( double x );

/**
* Replacement for {@link Math#tan(double)}
Expand All @@ -62,9 +58,7 @@ static double cos( double x ) {
*/
@Replace( "java/lang/Math.tan(D)D" )
@Import( module = "Math", name = "tan" )
static double tan( double x ) {
return 0; // for Java compiler
}
static native double tan( double x );

/**
* Replacement for {@link Math#asin(double)}
Expand All @@ -75,9 +69,7 @@ static double tan( double x ) {
*/
@Replace( "java/lang/Math.asin(D)D" )
@Import( module = "Math", name = "asin" )
static double asin( double x ) {
return 0; // for Java compiler
}
static native double asin( double x );

/**
* Replacement for {@link Math#acos(double)}
Expand All @@ -88,9 +80,7 @@ static double asin( double x ) {
*/
@Replace( "java/lang/Math.acos(D)D" )
@Import( module = "Math", name = "acos" )
static double acos( double x ) {
return 0; // for Java compiler
}
static native double acos( double x );

/**
* Replacement for {@link Math#atan(double)}
Expand All @@ -101,9 +91,7 @@ static double acos( double x ) {
*/
@Replace( "java/lang/Math.atan(D)D" )
@Import( module = "Math", name = "atan" )
static double atan( double x ) {
return 0; // for Java compiler
}
static native double atan( double x );

/**
* Replacement for {@link Math#exp(double)}
Expand All @@ -114,9 +102,7 @@ static double atan( double x ) {
*/
@Replace( "java/lang/Math.exp(D)D" )
@Import( module = "Math", name = "exp" )
static double exp( double x ) {
return 0; // for Java compiler
}
static native double exp( double x );

/**
* Replacement for {@link Math#log(double)}
Expand All @@ -127,9 +113,7 @@ static double exp( double x ) {
*/
@Replace( "java/lang/Math.log(D)D" )
@Import( module = "Math", name = "log" )
static double log( double x ) {
return 0; // for Java compiler
}
static native double log( double x );

/**
* Replacement for {@link Math#log10(double)}
Expand All @@ -140,9 +124,7 @@ static double log( double x ) {
*/
@Replace( "java/lang/Math.log10(D)D" )
@Import( module = "Math", name = "log10" )
static double log10( double x ) {
return 0; // for Java compiler
}
static native double log10( double x );

/**
* Replacement for {@link Math#sqrt(double)}
Expand All @@ -155,9 +137,7 @@ static double log10( double x ) {
@WasmTextCode( "local.get 0 " //
+ "f64.sqrt " //
+ "return" )
static double sqrt( double x ) {
return 0; // for Java compiler
}
static native double sqrt( double x );

/**
* Replacement for {@link Math#cbrt(double)}
Expand All @@ -168,9 +148,7 @@ static double sqrt( double x ) {
*/
@Replace( "java/lang/Math.cbrt(D)D" )
@Import( module = "Math", name = "cbrt" )
static double cbrt( double x ) {
return 0; // for Java compiler
}
static native double cbrt( double x );

/**
* Replacement for {@link Math#IEEEremainder(double,double)}
Expand All @@ -195,9 +173,7 @@ static double IEEEremainder( double f1, double f2 ) {
@WasmTextCode( "local.get 0 " //
+ "f64.ceil " //
+ "return" )
static double ceil( double x ) {
return 0; // for Java compiler
}
static native double ceil( double x );

/**
* Replacement for {@link Math#floor(double)}
Expand All @@ -210,9 +186,7 @@ static double ceil( double x ) {
@WasmTextCode( "local.get 0 " //
+ "f64.floor " //
+ "return" )
static double floor( double x ) {
return 0; // for Java compiler
}
static native double floor( double x );

/**
* Replacement for {@link Math#rint(double)}
Expand All @@ -225,9 +199,7 @@ static double floor( double x ) {
@WasmTextCode( "local.get 0 " //
+ "f64.nearest " //
+ "return" )
static double rint( double x ) {
return 0; // for Java compiler
}
static native double rint( double x );

/**
* Replacement for {@link Math#atan2(double, double)}
Expand All @@ -241,9 +213,7 @@ static double rint( double x ) {
*/
@Replace( "java/lang/Math.atan2(DD)D" )
@Import( module = "Math", name = "atan2" )
static double atan2( double y, double x ) {
return 0; // for Java compiler
}
static native double atan2( double y, double x );

/**
* Replacement for {@link Math#pow(double, double)}
Expand All @@ -254,9 +224,7 @@ static double atan2( double y, double x ) {
*/
@Replace( "java/lang/Math.pow(DD)D" )
@Import( module = "Math", name = "pow" )
static double pow( double a, double b ) {
return 0; // for Java compiler
}
static native double pow( double a, double b );

/**
* Replacement for {@link Math#random()}
Expand All @@ -265,9 +233,7 @@ static double pow( double a, double b ) {
*/
@Replace( "java/lang/Math.random()D" )
@Import( module = "Math", name = "random" )
static double random() {
return 0; // for Java compiler
}
static native double random();

/**
* Replacement for {@link Math#abs(double)}
Expand All @@ -280,9 +246,7 @@ static double random() {
@WasmTextCode( "local.get 0 " //
+ "f64.abs " //
+ "return" )
static double abs( double x ) {
return 0; // for Java compiler
}
static native double abs( double x );

/**
* Replacement for {@link Math#abs(float)}
Expand All @@ -295,9 +259,7 @@ static double abs( double x ) {
@WasmTextCode( "local.get 0 " //
+ "f32.abs " //
+ "return" )
static float abs( float x ) {
return 0; // for Java compiler
}
static native float abs( float x );

/**
* Replacement for {@link Math#max(double,double)}
Expand All @@ -311,9 +273,7 @@ static float abs( float x ) {
+ "local.get 1 " //
+ "f64.max " //
+ "return" )
static double max( double a, double b ) {
return 0; // for Java compiler
}
static native double max( double a, double b );

/**
* Replacement for {@link Math#max(float,float)}
Expand All @@ -327,9 +287,7 @@ static double max( double a, double b ) {
+ "local.get 1 " //
+ "f32.max " //
+ "return" )
static float max( float a, float b ) {
return 0; // for Java compiler
}
static native float max( float a, float b );

/**
* Replacement for {@link Math#min(double,double)}
Expand All @@ -343,9 +301,7 @@ static float max( float a, float b ) {
+ "local.get 1 " //
+ "f64.min " //
+ "return" )
static double min( double a, double b ) {
return 0; // for Java compiler
}
static native double min( double a, double b );

/**
* Replacement for {@link Math#min(float,float)}
Expand All @@ -359,9 +315,7 @@ static double min( double a, double b ) {
+ "local.get 1 " //
+ "f32.min " //
+ "return" )
static float min( float a, float b ) {
return 0; // for Java compiler
}
static native float min( float a, float b );

/**
* Replacement for {@link Math#sinh(double)}
Expand All @@ -372,9 +326,7 @@ static float min( float a, float b ) {
*/
@Replace( "java/lang/Math.sinh(D)D" )
@Import( module = "Math", name = "sinh" )
static double sinh( double x ) {
return 0; // for Java compiler
}
static native double sinh( double x );

/**
* Replacement for {@link Math#cosh(double)}
Expand All @@ -385,9 +337,7 @@ static double sinh( double x ) {
*/
@Replace( "java/lang/Math.cosh(D)D" )
@Import( module = "Math", name = "cosh" )
static double cosh( double x ) {
return 0; // for Java compiler
}
static native double cosh( double x );

/**
* Replacement for {@link Math#tanh(double)}
Expand All @@ -398,9 +348,7 @@ static double cosh( double x ) {
*/
@Replace( "java/lang/Math.tanh(D)D" )
@Import( module = "Math", name = "tanh" )
static double tanh( double x ) {
return 0; // for Java compiler
}
static native double tanh( double x );

/**
* Replacement for {@link Math#hypot(double, double)}
Expand All @@ -413,9 +361,7 @@ static double tanh( double x ) {
*/
@Replace( "java/lang/Math.hypot(DD)D" )
@Import( module = "Math", name = "hypot" )
static double hypot( double a, double b ) {
return 0; // for Java compiler
}
static native double hypot( double a, double b );

/**
* Replacement for {@link Math#expm1(double)}
Expand All @@ -426,9 +372,7 @@ static double hypot( double a, double b ) {
*/
@Replace( "java/lang/Math.expm1(D)D" )
@Import( module = "Math", name = "expm1" )
static double expm1( double a, double b ) {
return 0; // for Java compiler
}
static native double expm1( double a, double b );

/**
* Replacement for {@link Math#log1p(double)}
Expand All @@ -439,9 +383,7 @@ static double expm1( double a, double b ) {
*/
@Replace( "java/lang/Math.log1p(D)D" )
@Import( module = "Math", name = "log1p" )
static double log1p( double a, double b ) {
return 0; // for Java compiler
}
static native double log1p( double a, double b );

/**
* Replacement for {@link Math#copySign(double,double)}
Expand All @@ -455,9 +397,7 @@ static double log1p( double a, double b ) {
+ "local.get 1 " //
+ "f64.copysign " //
+ "return" )
static double copySign( double a, double b ) {
return 0; // for Java compiler
}
static native double copySign( double a, double b );

/**
* Replacement for {@link Math#copySign(float,float)}
Expand All @@ -471,8 +411,6 @@ static double copySign( double a, double b ) {
+ "local.get 1 " //
+ "f32.copysign " //
+ "return" )
static float copySign( float a, float b ) {
return 0; // for Java compiler
}
static native float copySign( float a, float b );

}