mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 07:02:13 +00:00
Shortcut f32/f64/i64 conversions to bool
This commit is contained in:
parent
c30c62e383
commit
7596d73284
@ -2560,7 +2560,10 @@ export class Compiler extends DiagnosticEmitter {
|
||||
|
||||
// f32 to int
|
||||
if (fromType.kind == TypeKind.F32) {
|
||||
if (toType.is(TypeFlags.SIGNED)) {
|
||||
if (toType == Type.bool) {
|
||||
expr = module.createBinary(BinaryOp.NeF32, expr, module.createF32(0));
|
||||
wrapMode = WrapMode.NONE;
|
||||
} else if (toType.is(TypeFlags.SIGNED)) {
|
||||
if (toType.is(TypeFlags.LONG)) {
|
||||
expr = module.createUnary(UnaryOp.TruncF32ToI64, expr);
|
||||
} else {
|
||||
@ -2576,7 +2579,10 @@ export class Compiler extends DiagnosticEmitter {
|
||||
|
||||
// f64 to int
|
||||
} else {
|
||||
if (toType.is(TypeFlags.SIGNED)) {
|
||||
if (toType == Type.bool) {
|
||||
expr = module.createBinary(BinaryOp.NeF64, expr, module.createF64(0));
|
||||
wrapMode = WrapMode.NONE;
|
||||
} else if (toType.is(TypeFlags.SIGNED)) {
|
||||
if (toType.is(TypeFlags.LONG)) {
|
||||
expr = module.createUnary(UnaryOp.TruncF64ToI64, expr);
|
||||
} else {
|
||||
@ -2643,7 +2649,10 @@ export class Compiler extends DiagnosticEmitter {
|
||||
if (fromType.is(TypeFlags.LONG)) {
|
||||
|
||||
// i64 to i32 or smaller
|
||||
if (!toType.is(TypeFlags.LONG)) {
|
||||
if (toType == Type.bool) {
|
||||
expr = module.createBinary(BinaryOp.NeI64, expr, module.createI64(0));
|
||||
wrapMode = WrapMode.NONE;
|
||||
} else if (!toType.is(TypeFlags.LONG)) {
|
||||
expr = module.createUnary(UnaryOp.WrapI64, expr); // discards upper bits
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,8 @@
|
||||
unreachable
|
||||
end
|
||||
get_global $bool/I
|
||||
i32.wrap/i64
|
||||
i32.const 0
|
||||
i32.ne
|
||||
i64.const 0
|
||||
i64.ne
|
||||
i32.const 1
|
||||
i32.ne
|
||||
if
|
||||
@ -58,9 +57,8 @@
|
||||
unreachable
|
||||
end
|
||||
get_global $bool/U
|
||||
i32.wrap/i64
|
||||
i32.const 0
|
||||
i32.ne
|
||||
i64.const 0
|
||||
i64.ne
|
||||
i32.const 1
|
||||
i32.ne
|
||||
if
|
||||
@ -72,9 +70,8 @@
|
||||
unreachable
|
||||
end
|
||||
get_global $bool/f
|
||||
i32.trunc_u/f32
|
||||
i32.const 0
|
||||
i32.ne
|
||||
f32.const 0
|
||||
f32.ne
|
||||
i32.const 1
|
||||
i32.ne
|
||||
if
|
||||
@ -86,9 +83,8 @@
|
||||
unreachable
|
||||
end
|
||||
get_global $bool/F
|
||||
i32.trunc_u/f64
|
||||
i32.const 0
|
||||
i32.ne
|
||||
f64.const 0
|
||||
f64.ne
|
||||
i32.const 1
|
||||
i32.ne
|
||||
if
|
||||
|
@ -33,9 +33,8 @@
|
||||
unreachable
|
||||
end
|
||||
get_global $bool/I
|
||||
i32.wrap/i64
|
||||
i32.const 0
|
||||
i32.ne
|
||||
i64.const 0
|
||||
i64.ne
|
||||
i32.const 1
|
||||
i32.eq
|
||||
i32.eqz
|
||||
@ -62,9 +61,8 @@
|
||||
unreachable
|
||||
end
|
||||
get_global $bool/U
|
||||
i32.wrap/i64
|
||||
i32.const 0
|
||||
i32.ne
|
||||
i64.const 0
|
||||
i64.ne
|
||||
i32.const 1
|
||||
i32.eq
|
||||
i32.eqz
|
||||
@ -77,9 +75,8 @@
|
||||
unreachable
|
||||
end
|
||||
get_global $bool/f
|
||||
i32.trunc_u/f32
|
||||
i32.const 0
|
||||
i32.ne
|
||||
f32.const 0
|
||||
f32.ne
|
||||
i32.const 1
|
||||
i32.eq
|
||||
i32.eqz
|
||||
@ -92,9 +89,8 @@
|
||||
unreachable
|
||||
end
|
||||
get_global $bool/F
|
||||
i32.trunc_u/f64
|
||||
i32.const 0
|
||||
i32.ne
|
||||
f64.const 0
|
||||
f64.ne
|
||||
i32.const 1
|
||||
i32.eq
|
||||
i32.eqz
|
||||
|
@ -1,82 +1,620 @@
|
||||
(module
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(memory $0 0)
|
||||
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
|
||||
(memory $0 1)
|
||||
(data (i32.const 8) "\17\00\00\00p\00o\00r\00t\00a\00b\00l\00e\00-\00c\00o\00n\00v\00e\00r\00s\00i\00o\00n\00s\00.\00t\00s")
|
||||
(table $0 1 anyfunc)
|
||||
(elem (i32.const 0) $null)
|
||||
(global $portable-conversions/f (mut f32) (f32.const 0))
|
||||
(global $portable-conversions/F (mut f64) (f64.const 0))
|
||||
(global $portable-conversions/i (mut i32) (i32.const 1))
|
||||
(global $portable-conversions/I (mut i64) (i64.const 1))
|
||||
(global $portable-conversions/f (mut f32) (f32.const 1))
|
||||
(global $portable-conversions/F (mut f64) (f64.const 1))
|
||||
(export "memory" (memory $0))
|
||||
(export "table" (table $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
get_global $portable-conversions/i
|
||||
i32.const 255
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 6
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
i32.const 255
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 7
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_s/f32
|
||||
drop
|
||||
i32.const 255
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 8
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_s/f64
|
||||
drop
|
||||
i32.const 255
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 9
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
i32.const 65535
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 11
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
i32.const 65535
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 12
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_s/f32
|
||||
drop
|
||||
i32.const 65535
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 13
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_s/f64
|
||||
drop
|
||||
i32.const 65535
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 14
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 16
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 17
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_s/f32
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 18
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_s/f64
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 19
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
i64.extend_s/i32
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 21
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 22
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i64.trunc_s/f32
|
||||
drop
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 23
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i64.trunc_s/f64
|
||||
drop
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 24
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 26
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 27
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_s/f32
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 28
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_s/f64
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 29
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
i32.const 255
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 31
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
i32.const 255
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 32
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_u/f32
|
||||
drop
|
||||
i32.const 255
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 33
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_u/f64
|
||||
drop
|
||||
i32.const 255
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 34
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
i32.const 65535
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 36
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
i32.const 65535
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 37
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_u/f32
|
||||
drop
|
||||
i32.const 65535
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 38
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_u/f64
|
||||
drop
|
||||
i32.const 65535
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 39
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 41
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 42
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_u/f32
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 43
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_u/f64
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 44
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
i64.extend_s/i32
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 46
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 47
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i64.trunc_u/f32
|
||||
drop
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 48
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i64.trunc_u/f64
|
||||
drop
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 49
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 51
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 52
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_u/f32
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 53
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_u/f64
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 54
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 56
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i64.const 0
|
||||
i64.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 57
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_u/f32
|
||||
drop
|
||||
f32.const 0
|
||||
f32.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 58
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_u/f64
|
||||
drop
|
||||
f64.const 0
|
||||
f64.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 59
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
f32.convert_s/i32
|
||||
f32.const 0
|
||||
f32.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 61
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
f32.convert_s/i64
|
||||
f32.const 0
|
||||
f32.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 62
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
f32.const 0
|
||||
f32.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 63
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
f32.demote/f64
|
||||
f32.const 0
|
||||
f32.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 64
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
f64.convert_s/i32
|
||||
f64.const 0
|
||||
f64.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 66
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
f64.convert_s/i64
|
||||
f64.const 0
|
||||
f64.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 67
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
f64.promote/f32
|
||||
f64.const 0
|
||||
f64.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 68
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
f64.const 0
|
||||
f64.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 69
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
)
|
||||
(func $null (; 1 ;) (type $v)
|
||||
(func $null (; 2 ;) (type $v)
|
||||
nop
|
||||
)
|
||||
)
|
||||
|
@ -1,69 +1,69 @@
|
||||
var i: i32 = 0;
|
||||
var I: i64 = 0;
|
||||
var f: f32 = 0;
|
||||
var F: f64 = 0;
|
||||
var i: i32 = 1;
|
||||
var I: i64 = 1;
|
||||
var f: f32 = 1;
|
||||
var F: f64 = 1;
|
||||
|
||||
i8(i);
|
||||
i8(I);
|
||||
i8(f);
|
||||
i8(F);
|
||||
assert(i8(i));
|
||||
assert(i8(I));
|
||||
assert(i8(f));
|
||||
assert(i8(F));
|
||||
|
||||
i16(i);
|
||||
i16(I);
|
||||
i16(f);
|
||||
i16(F);
|
||||
assert(i16(i));
|
||||
assert(i16(I));
|
||||
assert(i16(f));
|
||||
assert(i16(F));
|
||||
|
||||
i32(i);
|
||||
i32(I);
|
||||
i32(f);
|
||||
i32(F);
|
||||
assert(i32(i));
|
||||
assert(i32(I));
|
||||
assert(i32(f));
|
||||
assert(i32(F));
|
||||
|
||||
i64(i);
|
||||
i64(I);
|
||||
i64(f);
|
||||
i64(F);
|
||||
assert(i64(i));
|
||||
assert(i64(I));
|
||||
assert(i64(f));
|
||||
assert(i64(F));
|
||||
|
||||
isize(i);
|
||||
isize(I);
|
||||
isize(f);
|
||||
isize(F);
|
||||
assert(isize(i));
|
||||
assert(isize(I));
|
||||
assert(isize(f));
|
||||
assert(isize(F));
|
||||
|
||||
u8(i);
|
||||
u8(I);
|
||||
u8(f);
|
||||
u8(F);
|
||||
assert(u8(i));
|
||||
assert(u8(I));
|
||||
assert(u8(f));
|
||||
assert(u8(F));
|
||||
|
||||
u16(i);
|
||||
u16(I);
|
||||
u16(f);
|
||||
u16(F);
|
||||
assert(u16(i));
|
||||
assert(u16(I));
|
||||
assert(u16(f));
|
||||
assert(u16(F));
|
||||
|
||||
u32(i);
|
||||
u32(I);
|
||||
u32(f);
|
||||
u32(F);
|
||||
assert(u32(i));
|
||||
assert(u32(I));
|
||||
assert(u32(f));
|
||||
assert(u32(F));
|
||||
|
||||
u64(i);
|
||||
u64(I);
|
||||
u64(f);
|
||||
u64(F);
|
||||
assert(u64(i));
|
||||
assert(u64(I));
|
||||
assert(u64(f));
|
||||
assert(u64(F));
|
||||
|
||||
usize(i);
|
||||
usize(I);
|
||||
usize(f);
|
||||
usize(F);
|
||||
assert(usize(i));
|
||||
assert(usize(I));
|
||||
assert(usize(f));
|
||||
assert(usize(F));
|
||||
|
||||
bool(i);
|
||||
bool(I);
|
||||
bool(f);
|
||||
bool(F);
|
||||
assert(bool(i));
|
||||
assert(bool(I));
|
||||
assert(bool(f));
|
||||
assert(bool(F));
|
||||
|
||||
f32(i);
|
||||
f32(I);
|
||||
f32(f);
|
||||
f32(F);
|
||||
assert(f32(i));
|
||||
assert(f32(I));
|
||||
assert(f32(f));
|
||||
assert(f32(F));
|
||||
|
||||
f64(i);
|
||||
f64(I);
|
||||
f64(f);
|
||||
f64(F);
|
||||
assert(f64(i));
|
||||
assert(f64(I));
|
||||
assert(f64(f));
|
||||
assert(f64(F));
|
||||
|
@ -1,161 +1,641 @@
|
||||
(module
|
||||
(type $iiiiv (func (param i32 i32 i32 i32)))
|
||||
(type $v (func))
|
||||
(memory $0 0)
|
||||
(import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32)))
|
||||
(memory $0 1)
|
||||
(data (i32.const 8) "\17\00\00\00p\00o\00r\00t\00a\00b\00l\00e\00-\00c\00o\00n\00v\00e\00r\00s\00i\00o\00n\00s\00.\00t\00s\00")
|
||||
(table $0 1 anyfunc)
|
||||
(elem (i32.const 0) $null)
|
||||
(global $portable-conversions/i (mut i32) (i32.const 0))
|
||||
(global $portable-conversions/I (mut i64) (i64.const 0))
|
||||
(global $portable-conversions/f (mut f32) (f32.const 0))
|
||||
(global $portable-conversions/F (mut f64) (f64.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 8))
|
||||
(global $portable-conversions/i (mut i32) (i32.const 1))
|
||||
(global $portable-conversions/I (mut i64) (i64.const 1))
|
||||
(global $portable-conversions/f (mut f32) (f32.const 1))
|
||||
(global $portable-conversions/F (mut f64) (f64.const 1))
|
||||
(global $HEAP_BASE i32 (i32.const 60))
|
||||
(export "memory" (memory $0))
|
||||
(export "table" (table $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(func $start (; 1 ;) (type $v)
|
||||
get_global $portable-conversions/i
|
||||
drop
|
||||
i32.const 24
|
||||
i32.shl
|
||||
i32.const 24
|
||||
i32.shr_s
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 6
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
drop
|
||||
i32.const 24
|
||||
i32.shl
|
||||
i32.const 24
|
||||
i32.shr_s
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 7
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_s/f32
|
||||
drop
|
||||
i32.const 24
|
||||
i32.shl
|
||||
i32.const 24
|
||||
i32.shr_s
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 8
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_s/f64
|
||||
drop
|
||||
i32.const 24
|
||||
i32.shl
|
||||
i32.const 24
|
||||
i32.shr_s
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 9
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
drop
|
||||
i32.const 16
|
||||
i32.shl
|
||||
i32.const 16
|
||||
i32.shr_s
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 11
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
drop
|
||||
i32.const 16
|
||||
i32.shl
|
||||
i32.const 16
|
||||
i32.shr_s
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 12
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_s/f32
|
||||
drop
|
||||
i32.const 16
|
||||
i32.shl
|
||||
i32.const 16
|
||||
i32.shr_s
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 13
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_s/f64
|
||||
drop
|
||||
i32.const 16
|
||||
i32.shl
|
||||
i32.const 16
|
||||
i32.shr_s
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 14
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 16
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 17
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_s/f32
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 18
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_s/f64
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 19
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
i64.extend_s/i32
|
||||
drop
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 21
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
drop
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 22
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i64.trunc_s/f32
|
||||
drop
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 23
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i64.trunc_s/f64
|
||||
drop
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 24
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 26
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 27
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_s/f32
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 28
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_s/f64
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 29
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
drop
|
||||
i32.const 255
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 31
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
drop
|
||||
i32.const 255
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 32
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_u/f32
|
||||
drop
|
||||
i32.const 255
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 33
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_u/f64
|
||||
drop
|
||||
i32.const 255
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 34
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
drop
|
||||
i32.const 65535
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 36
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
drop
|
||||
i32.const 65535
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 37
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_u/f32
|
||||
drop
|
||||
i32.const 65535
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 38
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_u/f64
|
||||
drop
|
||||
i32.const 65535
|
||||
i32.and
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 39
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 41
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 42
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_u/f32
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 43
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_u/f64
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 44
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
i64.extend_s/i32
|
||||
drop
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 46
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
drop
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 47
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i64.trunc_u/f32
|
||||
drop
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 48
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i64.trunc_u/f64
|
||||
drop
|
||||
i64.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 49
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 51
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 52
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_u/f32
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 53
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_u/f64
|
||||
drop
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 54
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
drop
|
||||
i32.const 0
|
||||
i32.ne
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 56
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
i32.wrap/i64
|
||||
drop
|
||||
i64.const 0
|
||||
i64.ne
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 57
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
i32.trunc_u/f32
|
||||
drop
|
||||
f32.const 0
|
||||
f32.ne
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 58
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
i32.trunc_u/f64
|
||||
drop
|
||||
f64.const 0
|
||||
f64.ne
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 59
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
f32.convert_s/i32
|
||||
drop
|
||||
f32.const 0
|
||||
f32.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 61
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
f32.convert_s/i64
|
||||
drop
|
||||
f32.const 0
|
||||
f32.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 62
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
drop
|
||||
f32.const 0
|
||||
f32.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 63
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
f32.demote/f64
|
||||
drop
|
||||
f32.const 0
|
||||
f32.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 64
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/i
|
||||
f64.convert_s/i32
|
||||
drop
|
||||
f64.const 0
|
||||
f64.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 66
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/I
|
||||
f64.convert_s/i64
|
||||
drop
|
||||
f64.const 0
|
||||
f64.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 67
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/f
|
||||
f64.promote/f32
|
||||
drop
|
||||
f64.const 0
|
||||
f64.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 68
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
get_global $portable-conversions/F
|
||||
drop
|
||||
f64.const 0
|
||||
f64.eq
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 8
|
||||
i32.const 69
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
)
|
||||
(func $null (; 1 ;) (type $v)
|
||||
(func $null (; 2 ;) (type $v)
|
||||
)
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user