mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-20 02:11:31 +00:00
Naive parseFloat
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
(type $iii (func (param i32 i32) (result i32)))
|
||||
(type $iiii (func (param i32 i32 i32) (result i32)))
|
||||
(type $iiI (func (param i32 i32) (result i64)))
|
||||
(type $iF (func (param i32) (result f64)))
|
||||
(type $v (func))
|
||||
(global $std/string/str (mut i32) (i32.const 8))
|
||||
(memory $0 1)
|
||||
@ -21,6 +22,9 @@
|
||||
(data (i32.const 184) "\05\00\00\000\00x\00F\000\00F")
|
||||
(data (i32.const 200) "\03\00\00\000\001\001")
|
||||
(data (i32.const 216) "\04\00\00\000\00x\001\00g")
|
||||
(data (i32.const 232) "\03\00\00\000\00.\001")
|
||||
(data (i32.const 248) "\03\00\00\00.\002\005")
|
||||
(data (i32.const 264) "\08\00\00\00.\001\00f\00o\00o\00b\00a\00r")
|
||||
(export "getString" (func $std/string/getString))
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
@ -607,62 +611,39 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(loop $continue|1
|
||||
(if
|
||||
(block (result i32)
|
||||
(set_local $3
|
||||
(i32.sub
|
||||
(tee_local $2
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.and
|
||||
(select
|
||||
(i32.le_s
|
||||
(tee_local $2
|
||||
(i32.load16_u offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 57)
|
||||
)
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(i32.const 48)
|
||||
)
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(i32.const 48)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_local $2
|
||||
(block $break|1
|
||||
(loop $continue|1
|
||||
(if
|
||||
(block (result i32)
|
||||
(set_local $3
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 48)
|
||||
(tee_local $2
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.and
|
||||
(select
|
||||
(i32.le_s
|
||||
(get_local $2)
|
||||
(i32.const 90)
|
||||
(tee_local $2
|
||||
(i32.load16_u offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.const 57)
|
||||
)
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(i32.const 65)
|
||||
(i32.const 48)
|
||||
)
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(i32.const 65)
|
||||
(i32.const 48)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
@ -670,7 +651,7 @@
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 55)
|
||||
(i32.const 48)
|
||||
)
|
||||
)
|
||||
(if
|
||||
@ -678,15 +659,15 @@
|
||||
(select
|
||||
(i32.le_s
|
||||
(get_local $2)
|
||||
(i32.const 122)
|
||||
(i32.const 90)
|
||||
)
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(i32.const 97)
|
||||
(i32.const 65)
|
||||
)
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(i32.const 97)
|
||||
(i32.const 65)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
@ -694,50 +675,64 @@
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 87)
|
||||
(i32.const 55)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(i64.mul
|
||||
(get_local $5)
|
||||
(get_local $4)
|
||||
(if
|
||||
(i32.and
|
||||
(select
|
||||
(i32.le_s
|
||||
(get_local $2)
|
||||
(i32.const 122)
|
||||
)
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(i32.const 97)
|
||||
)
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(i32.const 97)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 87)
|
||||
)
|
||||
)
|
||||
(br $break|1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(get_local $1)
|
||||
)
|
||||
(return
|
||||
(i64.mul
|
||||
(get_local $5)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(i64.add
|
||||
(i64.mul
|
||||
(get_local $4)
|
||||
(i64.extend_s/i32
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(i64.extend_s/i32
|
||||
(br_if $break|1
|
||||
(i32.ge_s
|
||||
(get_local $2)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 2)
|
||||
(set_local $4
|
||||
(i64.add
|
||||
(i64.mul
|
||||
(get_local $4)
|
||||
(i64.extend_s/i32
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(i64.extend_s/i32
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $0
|
||||
(i32.add
|
||||
(get_local $0)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(br $continue|1)
|
||||
)
|
||||
(br $continue|1)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -746,7 +741,251 @@
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
(func $start (; 7 ;) (type $v)
|
||||
(func $std:string/parseFloat (; 7 ;) (type $iF) (param $0 i32) (result f64)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 f64)
|
||||
(local $4 f64)
|
||||
(local $5 f64)
|
||||
(if
|
||||
(i32.eqz
|
||||
(tee_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
)
|
||||
(set_local $5
|
||||
(if (result f64)
|
||||
(i32.eq
|
||||
(tee_local $0
|
||||
(i32.load16_u offset=4
|
||||
(tee_local $1
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 45)
|
||||
)
|
||||
(block (result f64)
|
||||
(if
|
||||
(i32.eqz
|
||||
(tee_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load16_u offset=4
|
||||
(tee_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(f64.const -1)
|
||||
)
|
||||
(if (result f64)
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(i32.const 43)
|
||||
)
|
||||
(block (result f64)
|
||||
(if
|
||||
(i32.eqz
|
||||
(tee_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load16_u offset=4
|
||||
(tee_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(f64.const 1)
|
||||
)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(block $break|0
|
||||
(loop $continue|0
|
||||
(if
|
||||
(block (result i32)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(tee_local $0
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.eq
|
||||
(tee_local $0
|
||||
(i32.load16_u offset=4
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(i32.const 46)
|
||||
)
|
||||
(block
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(f64.const 0.1)
|
||||
)
|
||||
(block $break|1
|
||||
(loop $continue|1
|
||||
(if
|
||||
(block (result i32)
|
||||
(set_local $2
|
||||
(i32.sub
|
||||
(tee_local $0
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
(block
|
||||
(if
|
||||
(i32.and
|
||||
(select
|
||||
(i32.eq
|
||||
(tee_local $0
|
||||
(i32.load16_u offset=4
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
(i32.const 69)
|
||||
)
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(i32.const 101)
|
||||
)
|
||||
(i32.eq
|
||||
(get_local $0)
|
||||
(i32.const 69)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(br_if $break|1
|
||||
(i32.gt_u
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 48)
|
||||
)
|
||||
)
|
||||
(i32.const 9)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(f64.add
|
||||
(get_local $3)
|
||||
(f64.mul
|
||||
(f64.convert_s/i32
|
||||
(get_local $0)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $4
|
||||
(f64.mul
|
||||
(get_local $4)
|
||||
(f64.const 0.1)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(br $continue|1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(br $break|0)
|
||||
)
|
||||
)
|
||||
(br_if $break|0
|
||||
(i32.ge_u
|
||||
(tee_local $0
|
||||
(i32.sub
|
||||
(get_local $0)
|
||||
(i32.const 48)
|
||||
)
|
||||
)
|
||||
(i32.const 10)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(f64.add
|
||||
(f64.mul
|
||||
(get_local $3)
|
||||
(f64.const 10)
|
||||
)
|
||||
(f64.convert_s/i32
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $1
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
)
|
||||
(br $continue|0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(f64.mul
|
||||
(get_local $5)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(func $start (; 8 ;) (type $v)
|
||||
(if
|
||||
(i32.ne
|
||||
(get_global $std/string/str)
|
||||
@ -908,5 +1147,50 @@
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f64.ne
|
||||
(call $std:string/parseFloat
|
||||
(i32.const 120)
|
||||
)
|
||||
(f64.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f64.ne
|
||||
(call $std:string/parseFloat
|
||||
(i32.const 128)
|
||||
)
|
||||
(f64.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f64.ne
|
||||
(call $std:string/parseFloat
|
||||
(i32.const 232)
|
||||
)
|
||||
(f64.const 0.1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f64.ne
|
||||
(call $std:string/parseFloat
|
||||
(i32.const 248)
|
||||
)
|
||||
(f64.const 0.25)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(f64.ne
|
||||
(call $std:string/parseFloat
|
||||
(i32.const 264)
|
||||
)
|
||||
(f64.const 0.1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user