Skip to content

Commit 5611797

Browse files
committed
more Math function replacements
1 parent 37b553d commit 5611797

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

src/de/inetsoftware/jwebassembly/api/java/lang/ReplacementForMath.java

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,4 +401,78 @@ static double cosh( double x ) {
401401
static double tanh( double x ) {
402402
return 0; // for Java compiler
403403
}
404+
405+
/**
406+
* Replacement for {@link Math#hypot(double, double)}
407+
*
408+
* @param a
409+
* a value
410+
* @param b
411+
* a value
412+
* @return sqrt(a<sup>2</sup>+b<sup>2</sup>)
413+
*/
414+
@Replace( "java/lang/Math.hypot(DD)D" )
415+
@Import( module = "Math", name = "hypot" )
416+
static double hypot( double a, double b ) {
417+
return 0; // for Java compiler
418+
}
419+
420+
/**
421+
* Replacement for {@link Math#expm1(double)}
422+
*
423+
* @param x
424+
* the exponent
425+
* @return the value e<sup>x</sup> - 1.
426+
*/
427+
@Replace( "java/lang/Math.expm1(D)D" )
428+
@Import( module = "Math", name = "expm1" )
429+
static double expm1( double a, double b ) {
430+
return 0; // for Java compiler
431+
}
432+
433+
/**
434+
* Replacement for {@link Math#log1p(double)}
435+
*
436+
* @param x
437+
* a value
438+
* @return the result
439+
*/
440+
@Replace( "java/lang/Math.log1p(D)D" )
441+
@Import( module = "Math", name = "log1p" )
442+
static double log1p( double a, double b ) {
443+
return 0; // for Java compiler
444+
}
445+
446+
/**
447+
* Replacement for {@link Math#copySign(double,double)}
448+
*
449+
* @param a an argument.
450+
* @param b another argument.
451+
* @return the result
452+
*/
453+
@Replace( "java/lang/Math.copySign(DD)D" )
454+
@WasmTextCode( "local.get 0 " //
455+
+ "local.get 1 " //
456+
+ "f64.copysign " //
457+
+ "return" )
458+
static double copySign( double a, double b ) {
459+
return 0; // for Java compiler
460+
}
461+
462+
/**
463+
* Replacement for {@link Math#copySign(float,float)}
464+
*
465+
* @param a an argument.
466+
* @param b another argument.
467+
* @return the result
468+
*/
469+
@Replace( "java/lang/Math.copySign(FF)F" )
470+
@WasmTextCode( "local.get 0 " //
471+
+ "local.get 1 " //
472+
+ "f32.copysign " //
473+
+ "return" )
474+
static float copySign( float a, float b ) {
475+
return 0; // for Java compiler
476+
}
477+
404478
}

0 commit comments

Comments
 (0)