v0.0.51


View WebAssembly source (2005 bytes compiled)
(module $MenuButton
  (type $SilverOrb.StringBuilder (func (result i32 i32)))
  (memory (export "memory") 3)
  (global $bump_offset (mut i32) (i32.const 65536))
  (global $bump_mark (mut i32) (i32.const 0))
  (global $bump_write_level (mut i32) (i32.const 0))
  (global $active_item_index (mut i32) (i32.const 0))
  (global $focus_enum (mut i32) (i32.const 0))
  (global $focus_clock (mut i32) (i32.const 0))
  (global $text_html_clock (mut i32) (i32.const 0))
  (global $id_suffix (export "id_suffix") (mut i32) (i32.const 1))
  (global $item_count (export "item_count") (mut i32) (i32.const 3))
  (; constants 694 bytes ;)
  (data (i32.const 255) "menubutton:")
  (data (i32.const 267) "menu:")
  (data (i32.const 273) "menuitem:")
  (data (i32.const 283) ".")
  (data (i32.const 285) "<button type=\"button\" id=\"")
  (data (i32.const 312) "\" aria-haspopup=\"true\" aria-expanded=\"")
  (data (i32.const 351) "true")
  (data (i32.const 356) "false")
  (data (i32.const 362) "\" aria-controls=\"")
  (data (i32.const 380) "\" data-action=\"toggle\" data-keydown-arrow-down data-keydown-arrow-up=\"focus_previous_item\">")
  (data (i32.const 472) "Click me")
  (data (i32.const 481) "</button>")
  (data (i32.const 491) "<ul role=\"menu\" id=\"")
  (data (i32.const 512) "\" tabindex=\"-1\" aria-labelledby=\"")
  (data (i32.const 546) "\" aria-activedescendant=\"")
  (data (i32.const 572) "\" data-keydown-escape=\"close\" data-keydown-arrow-up=\"focus_previous_item\" data-keydown-arrow-down=\"focus_next_item\"")
  (data (i32.const 688) " hidden")
  (data (i32.const 696) ">")
  (data (i32.const 698) "\n")
  (data (i32.const 700) "</ul>")
  (data (i32.const 706) "<li role=\"menuitem\" id=\"")
  (data (i32.const 731) "\" tabindex=\"-1\" data-action=\"select_item:[")
  (data (i32.const 774) "]\" data-pointerover=\"focus_item:[")
  (data (i32.const 808) "]\">")
  (data (i32.const 812) "Action ")
  (data (i32.const 820) "</li>")
  (data (i32.const 826) "<lipid-menu-button>\n")
  (data (i32.const 847) "<golden-orb>\n")
  (data (i32.const 861) "<source type=\"application/wasm\" src=\"/menu.wasm\">\n")
  (data (i32.const 912) "</golden-orb>\n")
  (data (i32.const 927) "</lipid-menu-button>\n")
  (func $decimal_u32_char_count (param $value i32) (result i32)
    (local $digit_count i32)
    (loop $Digits
      (i32.add (local.get $digit_count) (i32.const 1))
      (local.set $digit_count)
      (i32.div_u (local.get $value) (i32.const 10))
      (local.set $value)
      (i32.gt_u (local.get $value) (i32.const 0))
      (br_if $Digits)
    )
    (local.get $digit_count)
  )
  (func $decimal_u32 (param $value i32) (param $str_ptr i32) (result i32 i32)
    (local $working_offset i32)
    (local $len i32)
    (local $digit i32)
    (call $decimal_u32_char_count (local.get $value))
    (local.set $len)
    (i32.add (local.get $str_ptr) (local.get $len))
    (local.set $working_offset)
    (loop $Digits
      (i32.sub (local.get $working_offset) (i32.const 1))
      (local.set $working_offset)
      (i32.rem_u (local.get $value) (i32.const 10))
      (local.set $digit)
      (i32.div_u (local.get $value) (i32.const 10))
      (local.set $value)
      (i32.store8 (local.get $working_offset) (i32.add (i32.const 48) (local.get $digit)))
      (i32.gt_u (local.get $value) (i32.const 0))
      (br_if $Digits)
    )
    (local.get $str_ptr)
    (local.get $len)
  )
  (func $bump_write_start
    (i32.eqz (global.get $bump_write_level))
    (if
      (then
        (i32.const 65536)
        (global.set $bump_offset)
        (global.get $bump_offset)
        (global.set $bump_mark)
      )
    )
    (i32.add (global.get $bump_write_level) (i32.const 1))
    (global.set $bump_write_level)
  )
  (func $bump_write_done (result i32 i32)
    (i32.gt_s (global.get $bump_write_level) (i32.const 0))
    (if
      (then
        nop      )
      (else
        unreachable      )
    )
    (i32.sub (global.get $bump_write_level) (i32.const 1))
    (global.set $bump_write_level)
    (global.get $bump_mark)
    (i32.sub (global.get $bump_offset) (global.get $bump_mark))
  )
  (func $bump_write_str (param $str_ptr i32) (param $len i32)
    (local $i i32)
    (local $char i32)
    (i32.or (i32.eq (local.get $str_ptr) (global.get $bump_mark)) (i32.eqz (local.get $len)))
    (if
      (then
        return      )
    )
    (loop $EachChar
      (i32.load8_u (i32.add (local.get $str_ptr) (local.get $i)))
      (local.set $char)
      (i32.store8 (i32.add (global.get $bump_offset) (local.get $i)) (local.get $char))
      (i32.lt_s (local.get $i) (local.get $len))
      (if
        (then
          (i32.add (local.get $i) (i32.const 1))
          (local.set $i)
          (br $EachChar)
        )
      )
    )
    (i32.add (global.get $bump_offset) (local.get $len))
    (global.set $bump_offset)
  )
  (func $bump_written? (result i32)
    (i32.gt_s (global.get $bump_offset) (global.get $bump_mark))
  )
  (func $open? (export "open?") (result i32)
    (i32.gt_s (global.get $active_item_index) (i32.const 0))
  )
  (func $open (export "open")
    (i32.gt_s (global.get $item_count) (i32.const 0))
    (if
      (then
        (i32.const 1)
        (global.set $active_item_index)
        (i32.const 1)
        (global.set $focus_enum)
      )
    )
  )
  (func $close (export "close")
    (i32.const 0)
    (global.set $active_item_index)
    (i32.const 2)
    (global.set $focus_enum)
  )
  (func $toggle (export "toggle")
    (global.get $active_item_index)
    (if
      (then
        (call $close)
      )
      (else
        (call $open)
      )
    )
  )
  (func $focus_item (export "focus_item") (param $index i32)
    (i32.gt_s (local.get $index) (global.get $item_count))
    (if (result i32)
      (then
        (i32.const 1)
      )
      (else
        (i32.le_s (local.get $index) (i32.const 0))
        (if (result i32)
          (then
            (global.get $item_count)
          )
          (else
            (local.get $index)
          )
        )
      )
    )
    (global.set $active_item_index)
    (i32.const 1)
    (global.set $focus_enum)
  )
  (func $focus_previous_item (export "focus_previous_item")
    (call $focus_item (i32.sub (global.get $active_item_index) (i32.const 1)))
  )
  (func $focus_next_item (export "focus_next_item")
    (call $focus_item (i32.add (global.get $active_item_index) (i32.const 1)))
  )
  (func $button_id (export "button_id") (result i32 i32)
    (call $bump_write_start)
    (i32.const 255) (i32.const 11)
    (call $bump_write_str (;i32;) (;i32;))
    (call $decimal_u32 (global.get $id_suffix) (global.get $bump_offset))
    (i32.add (global.get $bump_offset))
    (global.set $bump_offset)
    nop
    drop
    (call $bump_write_done)
  )
  (func $menu_id (export "menu_id") (result i32 i32)
    (call $bump_write_start)
    (i32.const 267) (i32.const 5)
    (call $bump_write_str (;i32;) (;i32;))
    (call $decimal_u32 (global.get $id_suffix) (global.get $bump_offset))
    (i32.add (global.get $bump_offset))
    (global.set $bump_offset)
    nop
    drop
    (call $bump_write_done)
  )
  (func $menu_item_id (export "menu_item_id") (param $index i32) (result i32 i32)
    (call $bump_write_start)
    (i32.const 273) (i32.const 9)
    (call $bump_write_str (;i32;) (;i32;))
    (call $decimal_u32 (global.get $id_suffix) (global.get $bump_offset))
    (i32.add (global.get $bump_offset))
    (global.set $bump_offset)
    nop
    drop
    (i32.const 283) (i32.const 1)
    (call $bump_write_str (;i32;) (;i32;))
    (call $decimal_u32 (local.get $index) (global.get $bump_offset))
    (i32.add (global.get $bump_offset))
    (global.set $bump_offset)
    nop
    drop
    (call $bump_write_done)
  )
  (func $button (result i32 i32)
    (call $bump_write_start)
    (i32.const 285) (i32.const 26)
    (call $bump_write_str (;i32;) (;i32;))
    (call $button_id)
    drop
    drop
    (i32.const 312) (i32.const 38)
    (call $bump_write_str (;i32;) (;i32;))
    (call $open?)
    (if
      (then
        (i32.const 351) (i32.const 4)
        (call $bump_write_str (;i32;) (;i32;))
      )
      (else
        (i32.const 356) (i32.const 5)
        (call $bump_write_str (;i32;) (;i32;))
      )
    )
    (i32.const 362) (i32.const 17)
    (call $bump_write_str (;i32;) (;i32;))
    (call $menu_id)
    drop
    drop
    (i32.const 380) (i32.const 91)
    (call $bump_write_str (;i32;) (;i32;))
    (i32.const 472) (i32.const 8)
    (call $bump_write_str (;i32;) (;i32;))
    (i32.const 481) (i32.const 9)
    (call $bump_write_str (;i32;) (;i32;))
    (call $bump_write_done)
  )
  (func $menu_list (result i32 i32)
    (local $i i32)
    (i32.const 1)
    (local.set $i)
    (call $bump_write_start)
    (i32.const 491) (i32.const 20)
    (call $bump_write_str (;i32;) (;i32;))
    (call $menu_id)
    drop
    drop
    (i32.const 512) (i32.const 33)
    (call $bump_write_str (;i32;) (;i32;))
    (call $button_id)
    drop
    drop
    (i32.const 546) (i32.const 25)
    (call $bump_write_str (;i32;) (;i32;))
    (i32.gt_s (global.get $active_item_index) (i32.const 0))
    (if
      (then
        (call $menu_item_id (global.get $active_item_index))
        drop
        drop
      )
    )
    (i32.const 572) (i32.const 115)
    (call $bump_write_str (;i32;) (;i32;))
    (i32.eq (global.get $active_item_index) (i32.const 0))
    (if
      (then
        (i32.const 688) (i32.const 7)
        (call $bump_write_str (;i32;) (;i32;))
      )
    )
    (i32.const 696) (i32.const 1)
    (call $bump_write_str (;i32;) (;i32;))
    (i32.const 698) (i32.const 1)
    (call $bump_write_str (;i32;) (;i32;))
    (loop $EachItem (result i32 i32)
      (call $menu_item (local.get $i))
      (i32.add (local.get $i) (i32.const 1))
      (local.set $i)
      (i32.le_s (local.get $i) (global.get $item_count))
      (if
        (then
          (br $EachItem)
        )
      )
    )
    drop
    drop
    (i32.const 700) (i32.const 5)
    (call $bump_write_str (;i32;) (;i32;))
    (i32.const 698) (i32.const 1)
    (call $bump_write_str (;i32;) (;i32;))
    (call $bump_write_done)
  )
  (func $menu_item (param $i i32) (result i32 i32)
    (call $bump_write_start)
    (i32.const 706) (i32.const 24)
    (call $bump_write_str (;i32;) (;i32;))
    (call $menu_item_id (local.get $i))
    drop
    drop
    (i32.const 731) (i32.const 42)
    (call $bump_write_str (;i32;) (;i32;))
    (call $decimal_u32 (local.get $i) (global.get $bump_offset))
    (i32.add (global.get $bump_offset))
    (global.set $bump_offset)
    nop
    drop
    (i32.const 774) (i32.const 33)
    (call $bump_write_str (;i32;) (;i32;))
    (call $decimal_u32 (local.get $i) (global.get $bump_offset))
    (i32.add (global.get $bump_offset))
    (global.set $bump_offset)
    nop
    drop
    (i32.const 808) (i32.const 3)
    (call $bump_write_str (;i32;) (;i32;))
    (i32.const 812) (i32.const 7)
    (call $bump_write_str (;i32;) (;i32;))
    (call $decimal_u32 (local.get $i) (global.get $bump_offset))
    (i32.add (global.get $bump_offset))
    (global.set $bump_offset)
    nop
    drop
    (i32.const 820) (i32.const 5)
    (call $bump_write_str (;i32;) (;i32;))
    (i32.const 698) (i32.const 1)
    (call $bump_write_str (;i32;) (;i32;))
    (call $bump_write_done)
  )
  (func $text_html (export "text_html") (result i32 i32)
    (call $bump_write_start)
    (i32.const 826) (i32.const 20)
    (call $bump_write_str (;i32;) (;i32;))
    (i32.const 847) (i32.const 13)
    (call $bump_write_str (;i32;) (;i32;))
    (i32.const 861) (i32.const 50)
    (call $bump_write_str (;i32;) (;i32;))
    (call $button)
    drop
    drop
    (call $menu_list)
    drop
    drop
    (i32.const 912) (i32.const 14)
    (call $bump_write_str (;i32;) (;i32;))
    (i32.const 927) (i32.const 21)
    (call $bump_write_str (;i32;) (;i32;))
    (call $bump_write_done)
  )
  (func $focus_id (export "focus_id") (result i32 i32)
    (call $bump_write_start)
    (i32.gt_s (global.get $active_item_index) (i32.const 0))
    (if
      (then
        (call $menu_item_id (global.get $active_item_index))
        drop
        drop
      )
      (else
        (i32.eq (global.get $focus_enum) (i32.const 1))
        (if
          (then
            (call $menu_id)
            drop
            drop
          )
          (else
            (i32.eq (global.get $focus_enum) (i32.const 2))
            (if
              (then
                (call $button_id)
                drop
                drop
              )
            )
          )
        )
      )
    )
    (call $bump_write_done)
  )
)