mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-24 20:21:48 +00:00
parseInt compatibility layer around parseI64, see #19
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 $iiF (func (param i32 i32) (result f64)))
|
||||
(type $iF (func (param i32) (result f64)))
|
||||
(type $v (func))
|
||||
(global $std/string/str (mut i32) (i32.const 8))
|
||||
@ -499,7 +500,7 @@
|
||||
(get_global $std/string/str)
|
||||
)
|
||||
)
|
||||
(func $std:string/parseInt (; 7 ;) (type $iiI) (param $0 i32) (param $1 i32) (result i64)
|
||||
(func $std:string/parseI64 (; 7 ;) (type $iiI) (param $0 i32) (param $1 i32) (result i64)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
@ -924,7 +925,111 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std:string/parseFloat (; 8 ;) (type $iF) (param $0 i32) (result f64)
|
||||
(func $std:string/parseInt (; 8 ;) (type $iiF) (param $0 i32) (param $1 i32) (result f64)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
(local $4 i32)
|
||||
(set_local $2
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $2)
|
||||
)
|
||||
(return
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(get_local $0)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.load16_u offset=4
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $4)
|
||||
(i32.const 45)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(tee_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.eq
|
||||
(get_local $4)
|
||||
(i32.const 43)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(tee_local $2
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(if (result i32)
|
||||
(i32.ne
|
||||
(get_local $1)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.and
|
||||
(if (result i32)
|
||||
(i32.ne
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i32.lt_s
|
||||
(get_local $1)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $1)
|
||||
(i32.const 36)
|
||||
)
|
||||
)
|
||||
(i32.const 1)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(return
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
)
|
||||
(return
|
||||
(f64.convert_s/i64
|
||||
(call $std:string/parseI64
|
||||
(get_local $0)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $std:string/parseFloat (; 9 ;) (type $iF) (param $0 i32) (result f64)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
@ -1205,7 +1310,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $start (; 9 ;) (type $v)
|
||||
(func $start (; 10 ;) (type $v)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.eq
|
||||
@ -1299,96 +1404,96 @@
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i64.eq
|
||||
(f64.eq
|
||||
(call $std:string/parseInt
|
||||
(i32.const 120)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i64.const 0)
|
||||
(f64.const 0)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i64.eq
|
||||
(f64.eq
|
||||
(call $std:string/parseInt
|
||||
(i32.const 128)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i64.const 1)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i64.eq
|
||||
(f64.eq
|
||||
(call $std:string/parseInt
|
||||
(i32.const 136)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i64.const 5)
|
||||
(f64.const 5)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i64.eq
|
||||
(f64.eq
|
||||
(call $std:string/parseInt
|
||||
(i32.const 152)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i64.const 455)
|
||||
(f64.const 455)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i64.eq
|
||||
(f64.eq
|
||||
(call $std:string/parseInt
|
||||
(i32.const 168)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i64.const 3855)
|
||||
(f64.const 3855)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i64.eq
|
||||
(f64.eq
|
||||
(call $std:string/parseInt
|
||||
(i32.const 184)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i64.const 3855)
|
||||
(f64.const 3855)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i64.eq
|
||||
(f64.eq
|
||||
(call $std:string/parseInt
|
||||
(i32.const 200)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i64.const 11)
|
||||
(f64.const 11)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i64.eq
|
||||
(f64.eq
|
||||
(call $std:string/parseInt
|
||||
(i32.const 216)
|
||||
(i32.const 0)
|
||||
)
|
||||
(i64.const 1)
|
||||
(f64.const 1)
|
||||
)
|
||||
)
|
||||
(unreachable)
|
||||
@ -1529,6 +1634,8 @@
|
||||
ENUM: std:string/CharCode
|
||||
FUNCTION_PROTOTYPE: std:string/parseInt
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: std:string/parseI64
|
||||
FUNCTION_PROTOTYPE: parseI64
|
||||
FUNCTION_PROTOTYPE: std:string/parseFloat
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
GLOBAL: std/string/str
|
||||
@ -1558,6 +1665,8 @@
|
||||
CLASS_PROTOTYPE: String
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: std:string/parseInt
|
||||
FUNCTION_PROTOTYPE: parseI64
|
||||
FUNCTION_PROTOTYPE: std:string/parseI64
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: std:string/parseFloat
|
||||
FUNCTION_PROTOTYPE: std/string/getString
|
||||
|
Reference in New Issue
Block a user