class method
Prism::Serialize.load_parse_lex
load_parse_lex(input, serialized, freeze)
lib/prism/serialize.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/serialize.rb, line 153
def self.load_parse_lex(input, serialized, freeze)
source = Source.for(input)
loader = Loader.new(source, serialized)
tokens = loader.load_tokens
loader.load_header
encoding = loader.load_encoding
start_line = loader.load_varsint
offsets = loader.load_line_offsets(freeze)
source.replace_start_line(start_line)
source.replace_offsets(offsets)
comments = loader.load_comments(freeze)
magic_comments = loader.load_magic_comments(freeze)
data_loc = loader.load_optional_location_object(freeze)
errors = loader.load_errors(encoding, freeze)
warnings = loader.load_warnings(encoding, freeze)
cpool_base = loader.load_uint32
cpool_size = loader.load_varuint
constant_pool = ConstantPool.new(input, serialized, cpool_base, cpool_size)
node = loader.load_node(constant_pool, encoding, freeze)
loader.load_constant_pool(constant_pool)
raise unless loader.eof?
value = [node, tokens]
result = ParseLexResult.new(value, comments, magic_comments, data_loc, errors, warnings, source)
tokens.each do |token|
token[0].value.force_encoding(encoding)
if freeze
token[0].deep_freeze
token.freeze
end
end
if freeze
source.deep_freeze
tokens.freeze
value.freeze
result.freeze
end
result
end
Deserialize the dumped output from a request to parse_lex or parse_lex_file.
The formatting of the source of this method is purposeful to illustrate the structure of the serialized data.