タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

rubyとASTに関するiga_kのブックマーク (2)

  • RubyVM::AbstractSyntaxTree で Node を辿る処理をシンプルに実装する - アジャイルSEの憂鬱

    Ruby の Enumerator を使うと簡単にRubyのコードを処理できて便利だったので、ブログに書いておく。 ast = RubyVM::AbstractSyntaxTree.parse(<<~RUBY) class User < ApplicationRecord def say(text) puts text end def sum(x, y) x + y end end RUBY enum = Enumerator.new { |y| nodes = ast.children until nodes.empty? nodes.select! { _1.is_a?(RubyVM::AbstractSyntaxTree::Node) } nodes.each { y << _1 } nodes = nodes.flat_map(&:children) end } method_na

    RubyVM::AbstractSyntaxTree で Node を辿る処理をシンプルに実装する - アジャイルSEの憂鬱
    iga_k
    iga_k 2023/11/30
  • YARV Maniacs 【第 13 回】 事前コンパイルへの道


      2 RubyKaigi 2015  Compiling Ruby scripts   Ruby   YARV    (1)  (2) 
    iga_k
    iga_k 2019/06/01
    RubyVM::InstructionSequnece.load_iseqが入ったあとのささださん記事
  • 1