mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-13 23:11:41 +00:00
More built-in constants; Get/set parsing fixes; I64.toF64 fixes
This commit is contained in:
12
std/assembly.d.ts
vendored
12
std/assembly.d.ts
vendored
@ -98,14 +98,26 @@ declare namespace bool {
|
||||
/** Converts any other numeric value to a 32-bit float. */
|
||||
declare function f32(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): f32;
|
||||
declare namespace f32 {
|
||||
export const MIN_VALUE: f32;
|
||||
export const MAX_VALUE: f32;
|
||||
/** Smallest safely representable integer value. */
|
||||
export const MIN_SAFE_INTEGER: f32;
|
||||
/** Largest safely representable integer value. */
|
||||
export const MAX_SAFE_INTEGER: f32;
|
||||
/** Difference between 1 and the smallest representable value greater than 1. */
|
||||
export const EPSILON: f32;
|
||||
}
|
||||
/** Converts any other numeric value to a 64-bit float. */
|
||||
declare function f64(value: i8 | i16 | i32 | i64 | isize | u8 | u16 | u32 | u64 | usize | bool | f32 | f64): f64;
|
||||
declare namespace f64 {
|
||||
export const MIN_VALUE: f64;
|
||||
export const MAX_VALUE: f64;
|
||||
/** Smallest safely representable integer value. */
|
||||
export const MIN_SAFE_INTEGER: f64;
|
||||
/** Largest safely representable integer value. */
|
||||
export const MAX_SAFE_INTEGER: f64;
|
||||
/** Difference between 1 and the smallest representable value greater than 1. */
|
||||
export const EPSILON: f64;
|
||||
}
|
||||
|
||||
// Built-ins
|
||||
|
@ -17,6 +17,18 @@ export class Array<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@operator("[]")
|
||||
get(index: i32): T {
|
||||
assert(index > 0 && index < this.capacity);
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
@operator("[]=")
|
||||
set(index: i32, value: T): void {
|
||||
assert(index > 0 && index < this.capacity);
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
store<i64>(changetype<usize>(this), 0);
|
||||
Heap.dispose(this.ptr);
|
||||
|
8
std/portable.d.ts
vendored
8
std/portable.d.ts
vendored
@ -78,14 +78,22 @@ declare namespace bool {
|
||||
/** Converts any other numeric value to a 32-bit float. */
|
||||
declare function f32(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): f32;
|
||||
declare namespace f32 {
|
||||
/** Smallest safely representable integer value. */
|
||||
export const MIN_SAFE_INTEGER: f32;
|
||||
/** Largest safely representable integer value. */
|
||||
export const MAX_SAFE_INTEGER: f32;
|
||||
/** Difference between 1 and the smallest representable value greater than 1. */
|
||||
export const EPSILON: f32;
|
||||
}
|
||||
/** Converts any other numeric value to a 64-bit float. */
|
||||
declare function f64(value: i8 | i16 | i32 | isize | u8 | u16 | u32 | usize | bool | f32 | f64): f64;
|
||||
declare namespace f64 {
|
||||
/** Smallest safely representable integer value. */
|
||||
export const MIN_SAFE_INTEGER: f64;
|
||||
/** Largest safely representable integer value. */
|
||||
export const MAX_SAFE_INTEGER: f64;
|
||||
/** Difference between 1 and the smallest representable value greater than 1. */
|
||||
export const EPSILON: f64;
|
||||
}
|
||||
|
||||
// Portable built-ins
|
||||
|
@ -46,13 +46,15 @@ Object.defineProperties(
|
||||
globalScope["f32"] = function f32(value) { return Math.fround(value); }
|
||||
, {
|
||||
"MIN_SAFE_INTEGER": { value: -16777215, writable: false },
|
||||
"MAX_SAFE_INTEGER": { value: 16777215, writable: false }
|
||||
"MAX_SAFE_INTEGER": { value: 16777215, writable: false },
|
||||
"EPSILON": { value: Math.fround(1.19209290e-07), writable: false }
|
||||
});
|
||||
Object.defineProperties(
|
||||
globalScope["f64"] = function f64(value) { return +value; }
|
||||
, {
|
||||
"MIN_SAFE_INTEGER": { value: -9007199254740991, writable: false },
|
||||
"MAX_SAFE_INTEGER": { value: 9007199254740991, writable: false }
|
||||
"MAX_SAFE_INTEGER": { value: 9007199254740991, writable: false },
|
||||
"EPSILON": { value: 2.2204460492503131e-16, writable: false }
|
||||
});
|
||||
|
||||
globalScope["clz"] = Math.clz32;
|
||||
|
Reference in New Issue
Block a user