diff options
| author | Benoit Daloze <eregontp@gmail.com> | 2023-09-12 17:20:50 +0200 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-09-19 17:20:01 +0000 |
| commit | 7fc73ab5f6fbe46655855079954b26dcc14576b3 (patch) | |
| tree | 92953fc85e50ad39be631f0bf90ec14d7daa6f63 /lib | |
| parent | 4da53fd3a7a08d80b0b63640a6351dd4d1250b72 (diff) | |
[ruby/yarp] Only keep semantic fields in Java, i.e. skip location fields
* Add $YARP_SERIALIZE_ONLY_SEMANTICS_FIELDS to control where to serialize location fields at templating time,
this way there is no overhead for either case and nothing to check at runtime.
* Add a byte in the header to indicate whether location fields are included as expected.
* Fixes https://github.com/ruby/yarp/issues/807
* Simplify the build-java CI job now that the FFI backend is available so JRuby can serialize.
* Support keeping some location fields which are still needed until there is a replacement
https://github.com/ruby/yarp/commit/fc5cf2df12
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/yarp/ffi.rb | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/yarp/ffi.rb b/lib/yarp/ffi.rb index 26b6019b27..82643be808 100644 --- a/lib/yarp/ffi.rb +++ b/lib/yarp/ffi.rb @@ -166,6 +166,14 @@ module YARP end end end + + def self.dump_internal(source, source_size, filepath) + YPBuffer.with do |buffer| + metadata = [filepath.bytesize, filepath.b, 0].pack("LA*L") if filepath + yp_parse_serialize(source, source_size, buffer.pointer, metadata) + buffer.read + end + end end # Mark the LibRubyParser module as private as it should only be called through @@ -175,24 +183,15 @@ module YARP # The version constant is set by reading the result of calling yp_version. VERSION = LibRubyParser.yp_version.read_string - def self.dump_internal(source, source_size, filepath) - LibRubyParser::YPBuffer.with do |buffer| - metadata = [filepath.bytesize, filepath.b, 0].pack("LA*L") if filepath - LibRubyParser.yp_parse_serialize(source, source_size, buffer.pointer, metadata) - buffer.read - end - end - private_class_method :dump_internal - # Mirror the YARP.dump API by using the serialization API. def self.dump(code, filepath = nil) - dump_internal(code, code.bytesize, filepath) + LibRubyParser.dump_internal(code, code.bytesize, filepath) end # Mirror the YARP.dump_file API by using the serialization API. def self.dump_file(filepath) LibRubyParser::YPString.with(filepath) do |string| - dump_internal(string.source, string.length, filepath) + LibRubyParser.dump_internal(string.source, string.length, filepath) end end |
