Skip to content

Instantly share code, notes, and snippets.

@christian-rogobete
Last active February 9, 2023 17:51
Show Gist options
  • Save christian-rogobete/4e1445186086d00c05c4b5a4dceb3ec6 to your computer and use it in GitHub Desktop.
Save christian-rogobete/4e1445186086d00c05c4b5a4dceb3ec6 to your computer and use it in GitHub Desktop.
AssemblyScript, Simple, String concat, runtime=stub
(module
(type $none_=>_none (func))
(type $i32_=>_i32 (func (param i32) (result i32)))
(type $none_=>_i64 (func (result i64)))
(global $~lib/rt/stub/offset (mut i32) (i32.const 0))
(global $~started (mut i32) (i32.const 0))
(memory $0 1)
(data (i32.const 12) "\1c")
(data (i32.const 24) "\01\00\00\00\02\00\00\00a")
(data (i32.const 44) "\1c")
(data (i32.const 56) "\01\00\00\00\02\00\00\00b")
(data (i32.const 76) "\1c")
(data (i32.const 88) "\01")
(data (i32.const 108) "<")
(data (i32.const 120) "\01\00\00\00(\00\00\00A\00l\00l\00o\00c\00a\00t\00i\00o\00n\00 \00t\00o\00o\00 \00l\00a\00r\00g\00e")
(data (i32.const 172) "<")
(data (i32.const 184) "\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00s\00t\00u\00b\00.\00t\00s")
(export "testStr" (func $test/value-conversion/tests/testStr))
(export "memory" (memory $0))
(export "sdkstart" (func $~start))
(func $~lib/string/String#get:length (param $0 i32) (result i32)
local.get $0
i32.const 20
i32.sub
i32.load $0 offset=16
i32.const 1
i32.shr_u
)
(func $~lib/string/String.__concat
(local $0 i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
(local $4 i32)
(local $5 i32)
(local $6 i32)
(local $7 i32)
(local $8 i32)
i32.const 32
call $~lib/string/String#get:length
i32.const 1
i32.shl
local.tee $0
i32.const 64
call $~lib/string/String#get:length
i32.const 1
i32.shl
local.tee $1
i32.add
local.tee $4
if
local.get $4
i32.const 1073741804
i32.gt_u
if
unreachable
end
local.get $4
i32.const 16
i32.add
local.tee $3
i32.const 1073741820
i32.gt_u
if
unreachable
end
global.get $~lib/rt/stub/offset
local.set $2
global.get $~lib/rt/stub/offset
i32.const 4
i32.add
local.tee $6
local.get $3
i32.const 19
i32.add
i32.const -16
i32.and
i32.const 4
i32.sub
local.tee $3
i32.add
local.tee $5
memory.size $0
local.tee $7
i32.const 16
i32.shl
i32.const 15
i32.add
i32.const -16
i32.and
local.tee $8
i32.gt_u
if
local.get $7
local.get $5
local.get $8
i32.sub
i32.const 65535
i32.add
i32.const -65536
i32.and
i32.const 16
i32.shr_u
local.tee $8
local.get $7
local.get $8
i32.gt_s
select
memory.grow $0
i32.const 0
i32.lt_s
if
local.get $8
memory.grow $0
i32.const 0
i32.lt_s
if
unreachable
end
end
end
local.get $5
global.set $~lib/rt/stub/offset
local.get $2
local.get $3
i32.store $0
local.get $6
i32.const 4
i32.sub
local.tee $2
i32.const 0
i32.store $0 offset=4
local.get $2
i32.const 0
i32.store $0 offset=8
local.get $2
i32.const 1
i32.store $0 offset=12
local.get $2
local.get $4
i32.store $0 offset=16
local.get $6
i32.const 16
i32.add
local.tee $2
i32.const 32
local.get $0
memory.copy $0 $0
local.get $0
local.get $2
i32.add
i32.const 64
local.get $1
memory.copy $0 $0
end
)
(func $test/value-conversion/tests/testStr (result i64)
call $~lib/string/String.__concat
i64.const 21
)
(func $~start
global.get $~started
if
return
end
i32.const 1
global.set $~started
i32.const 236
global.set $~lib/rt/stub/offset
)
;; custom section "contractenvmetav0", size 12
;; custom section "contractspecv0", size 28
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment