More built-in constants; Get/set parsing fixes; I64.toF64 fixes

This commit is contained in:
dcodeIO
2018-01-02 21:41:25 +01:00
parent 2b182b505e
commit 1221ff129d
14 changed files with 448 additions and 47 deletions

12
std/assembly.d.ts vendored
View File

@ -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

View File

@ -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
View File

@ -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

View File

@ -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;