Created
July 28, 2024 19:19
-
-
Save tompng/5d64803c8e8af9087b7020e6135d153b 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
# compile.c:L3057 | |
# if (lab->unremovable) { | |
# rb_gv_set("$FOO", Qtrue); // Add this to run this script | |
# break; // maybe bug | |
# } | |
require 'prism' | |
class StringVisitor < Prism::Visitor | |
attr_reader :strings | |
def initialize; @strings = [] end | |
def visit_string_node(node) | |
strings << node.unescaped | |
end | |
end | |
$VERBOSE = nil | |
Dir.glob("**/*.rb").each do |file| | |
next if file =~ /^tmp\// | |
begin | |
$FOO = false | |
RubyVM::InstructionSequence.compile_file(file) | |
p file if $FOO | |
rescue SyntaxError, EncodingError | |
rescue ArgumentError => e | |
p file => e.message unless e.message =~ /encoding/ | |
end | |
v = StringVisitor.new | |
Prism.parse_file(file).value.accept(v) | |
v.strings.each do |code| | |
$FOO = false | |
RubyVM::InstructionSequence.compile(code) | |
p [file, code] if $FOO | |
rescue SyntaxError | |
rescue ArgumentError => e | |
p code => e.message unless e.message =~ /encoding|ASCII compatible/ | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment