Created
January 7, 2025 16:18
-
-
Save tompng/b311a7373d57a9e833c8f6704f9e0d4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'prism' | |
Dir.glob('../**/*.rb').each do |file| | |
next if file =~ /(^|\/)tmp\// | |
codes = [] | |
prc = ->(node) { | |
codes << node.slice | |
codes << node.unescaped if node.is_a? Prism::StringNode | |
node.compact_child_nodes.each { prc.call it } | |
} | |
prc.call Prism.parse_file(file).value | |
p file | |
codes.uniq.sort_by(&:size).each_with_index do |code, i| | |
[ | |
"defined?((#{code}))", | |
"#shareable-constant-value: experimental_everything\nA=(#{code})", | |
"(#{code})=1" | |
].each do |target| | |
RubyVM::InstructionSequence.compile target | |
rescue SyntaxError | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment