webassemblyjs icon indicating copy to clipboard operation
webassemblyjs copied to clipboard

`path.gerPrevSibling()` in traverse

Open coderaiser opened this issue 9 months ago • 0 comments

Would be great to o have ability to get siblings (prev, next) while traversing AST, just like in Babel. I want to write transformation:

  (func (param $a i32) (param $b i32)
    (get_local $a)
    (get_local $b)
    i32.add
  )
  (export "add" (func $add))

To:

  func (param $a i32) (param $b i32)
    (i32.add (get_local $a) (get_local $b))
  )
  (export "add" (func $add))

I'm working on 🐊Putout linter, and wast also supported.

The most obvious way to do it would be to traverse i32.add and two previos siblings, and put them inside of i32.add.

coderaiser avatar Apr 20 '25 08:04 coderaiser