1
0
mirror of https://github.com/fluencelabs/assemblyscript synced 2025-07-18 15:52:07 +00:00

Initial static arrays of basic element types; Fixed member names in generic contexts

This commit is contained in:
dcodeIO
2018-03-20 23:41:37 +01:00
parent 2c0ddf4f80
commit be66abbd78
25 changed files with 6444 additions and 283 deletions

6
src/glue/js/float.d.ts vendored Normal file

@@ -0,0 +1,6 @@
/** @module glue/js *//***/
declare function f32_as_i32(value: f32): i32;
declare function i32_as_f32(value: i32): f32;
declare function f64_as_i64(value: f64): I64;
declare function i64_as_f64(value: I64): f64;

24
src/glue/js/float.js Normal file

@@ -0,0 +1,24 @@
const F64 = new Float64Array(1);
const F32 = new Float32Array(F64.buffer);
const I32 = new Int32Array(F64.buffer);
global.f32_as_i32 = function(value) {
F32[0] = value;
return I32[0];
};
global.i32_as_f32 = function(value) {
I32[0] = value;
return F32[0];
};
global.f64_as_i64 = function(value) {
F64[0] = value;
return i64_new(I32[0], I32[1]);
};
global.i64_as_f64 = function(value) {
I32[0] = i64_low(value);
I32[1] = i64_high(value);
return F64[0];
};

@@ -7,3 +7,4 @@
import "../../../std/portable";
import "./binaryen";
import "./i64";
import "./float";

19
src/glue/wasm/float.ts Normal file

@@ -0,0 +1,19 @@
@global
function f32_as_i32(value: f32): i32 {
return reinterpret<i32>(value);
}
@global
function i32_as_f32(value: i32): f32 {
return reinterpret<f32>(value);
}
@global
function f64_as_i64(value: f64): i64 {
return reinterpret<i64>(value);
}
@global
function i64_as_f64(value: i64): f64 {
return reinterpret<f64>(value);
}

@@ -5,3 +5,4 @@
*//***/
import "./i64";
import "./float";