Skip to content

path.gerPrevSibling() in traverse #1208

@coderaiser

Description

@coderaiser

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions