mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 23:12:19 +00:00
Add portable sincos polyfill (#529)
This commit is contained in:
parent
783dd32c2e
commit
f841f0fe1f
@ -2329,18 +2329,21 @@ export namespace NativeMathf {
|
|||||||
}
|
}
|
||||||
return tan_kernf(x, 0);
|
return tan_kernf(x, 0);
|
||||||
}
|
}
|
||||||
if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */
|
|
||||||
if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */
|
if (ASC_SHRINK_LEVEL < 1) {
|
||||||
return tan_kernf((sign ? x + t1pio2 : x - t1pio2), 1);
|
if (ix <= 0x407b53d1) { /* |x| ~<= 5π/4 */
|
||||||
} else {
|
if (ix <= 0x4016cbe3) { /* |x| ~<= 3π/4 */
|
||||||
return tan_kernf((sign ? x + t2pio2 : x - t2pio2), 0);
|
return tan_kernf((sign ? x + t1pio2 : x - t1pio2), 1);
|
||||||
|
} else {
|
||||||
|
return tan_kernf((sign ? x + t2pio2 : x - t2pio2), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */
|
||||||
if (ix <= 0x40e231d5) { /* |x| ~<= 9π/4 */
|
if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */
|
||||||
if (ix <= 0x40afeddf) { /* |x| ~<= 7π/4 */
|
return tan_kernf((sign ? x + t3pio2 : x - t3pio2), 1);
|
||||||
return tan_kernf((sign ? x + t3pio2 : x - t3pio2), 1);
|
} else {
|
||||||
} else {
|
return tan_kernf((sign ? x + t4pio2 : x - t4pio2), 0);
|
||||||
return tan_kernf((sign ? x + t4pio2 : x - t4pio2), 0);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
std/portable/index.d.ts
vendored
11
std/portable/index.d.ts
vendored
@ -100,13 +100,17 @@ declare function isFinite<T = f32 | f64>(value: T): bool;
|
|||||||
declare function isInteger(value: any): value is number;
|
declare function isInteger(value: any): value is number;
|
||||||
/** Tests if the specified value is a valid float. Can't distinguish a float from an integer. */
|
/** Tests if the specified value is a valid float. Can't distinguish a float from an integer. */
|
||||||
declare function isFloat(value: any): value is number;
|
declare function isFloat(value: any): value is number;
|
||||||
|
/** Tests if the specified value is of a nullable reference type. */
|
||||||
|
declare function isNullable(value: any): bool;
|
||||||
/** Tests if the specified value is of a reference type. */
|
/** Tests if the specified value is of a reference type. */
|
||||||
declare function isReference(value: any): value is object | string;
|
declare function isReference(value: any): value is object | string;
|
||||||
|
/** Tests if the specified value is of a function type */
|
||||||
|
declare function isFunction(value: any): value is Function;
|
||||||
/** Tests if the specified value can be used as a string. */
|
/** Tests if the specified value can be used as a string. */
|
||||||
declare function isString(value: any): value is string | String;
|
declare function isString(value: any): value is string | String;
|
||||||
/** Tests if the specified value can be used as an array. */
|
/** Tests if the specified value can be used as an array. */
|
||||||
declare function isArray(value: any): value is Array<any>;
|
declare function isArray(value: any): value is Array<any>;
|
||||||
/** Tests if the specified type *or* expression can be used as an array like object. Compiles to a constant. */
|
/** Tests if the specified type *or* expression can be used as an array like object. */
|
||||||
declare function isArrayLike(value: any): value is ArrayLike<any>;
|
declare function isArrayLike(value: any): value is ArrayLike<any>;
|
||||||
/** Tests if the specified expression resolves to a defined element. */
|
/** Tests if the specified expression resolves to a defined element. */
|
||||||
declare function isDefined(expression: any): bool;
|
declare function isDefined(expression: any): bool;
|
||||||
@ -567,6 +571,10 @@ interface IMath {
|
|||||||
readonly PI: f64;
|
readonly PI: f64;
|
||||||
readonly SQRT1_2: f64;
|
readonly SQRT1_2: f64;
|
||||||
readonly SQRT2: f64;
|
readonly SQRT2: f64;
|
||||||
|
|
||||||
|
sincos_sin: f64;
|
||||||
|
sincos_cos: f64;
|
||||||
|
|
||||||
abs(x: f64): f64;
|
abs(x: f64): f64;
|
||||||
acos(x: f64): f64;
|
acos(x: f64): f64;
|
||||||
acosh(x: f64): f64;
|
acosh(x: f64): f64;
|
||||||
@ -598,6 +606,7 @@ interface IMath {
|
|||||||
sign(x: f64): f64;
|
sign(x: f64): f64;
|
||||||
signbit(x: f64): bool;
|
signbit(x: f64): bool;
|
||||||
sin(x: f64): f64;
|
sin(x: f64): f64;
|
||||||
|
sincos(x: f64): f64;
|
||||||
sinh(x: f64): f64;
|
sinh(x: f64): f64;
|
||||||
sqrt(x: f64): f64;
|
sqrt(x: f64): f64;
|
||||||
tan(x: f64): f64;
|
tan(x: f64): f64;
|
||||||
|
@ -206,10 +206,18 @@ globalScope["isFloat"] = function isFloat(arg) {
|
|||||||
return typeof arg === "number";
|
return typeof arg === "number";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
globalScope["isNullable"] = function isNullable(arg) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
globalScope["isReference"] = function isReference(arg) {
|
globalScope["isReference"] = function isReference(arg) {
|
||||||
return typeof arg === "object" || typeof arg === "string";
|
return typeof arg === "object" || typeof arg === "string";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
globalScope["isFunction"] = function isFunction(arg) {
|
||||||
|
return typeof arg === "function";
|
||||||
|
}
|
||||||
|
|
||||||
globalScope["isString"] = function isString(arg) {
|
globalScope["isString"] = function isString(arg) {
|
||||||
return typeof arg === "string" || arg instanceof String;
|
return typeof arg === "string" || arg instanceof String;
|
||||||
};
|
};
|
||||||
@ -244,9 +252,22 @@ globalScope["fmodf"] = function fmodf(x, y) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
globalScope["JSMath"] = Math;
|
globalScope["JSMath"] = Math;
|
||||||
globalScope["JSMath"].signbit = function signbit(x) {
|
|
||||||
F64[0] = x; return Boolean((U64[1] >>> 31) & (x == x));
|
Object.defineProperties(globalScope["JSMath"], {
|
||||||
}
|
sincos_sin: { value: 0.0, writable: true },
|
||||||
|
sincos_cos: { value: 0.0, writable: true },
|
||||||
|
signbit: {
|
||||||
|
value: function signbit(x) {
|
||||||
|
F64[0] = x; return Boolean((U64[1] >>> 31) & (x == x));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sincos: {
|
||||||
|
value: function sincos(x) {
|
||||||
|
this.sincos_sin = Math.sin(x);
|
||||||
|
this.sincos_cos = Math.cos(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
globalScope["memory"] = (() => {
|
globalScope["memory"] = (() => {
|
||||||
var HEAP = new Uint8Array(0);
|
var HEAP = new Uint8Array(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user