# frozen_string_literal: true
#
# This file is generated by the templates/template.rb script and should not be
# modified manually. To change the template see
#   templates/lib/rbs/wasm/serialization_schema.rb.erb

module RBS
  module WASM
    # Describes how to decode the binary buffer produced by `rbs_serialize_node`
    # (src/serialize.c) back into RBS::AST objects. RBS::WASM::Deserializer walks
    # this table; the matching encoder is generated from the same config.yml, so
    # the two stay in sync.
    #
    # SCHEMA is indexed by node tag: tag 0 is NULL and SYMBOL_TAG is the
    # interned-symbol tag. Each remaining entry is one of:
    #
    #   [:node, class_name, expose_location, loc_children, fields, resolve_type_params]
    #   [:bool] / [:integer] / [:string_value] / [:record_field]
    #   [:signature] / [:namespace] / [:type_name]
    #
    # where loc_children is [[name, required?], ...] and fields is
    # [[name, reader], ...] with reader one of :node, :node_list, :hash, :string,
    # :bool, :location_range, :location_range_list, :attr_ivar_name, or
    # [:enum, [value_or_nil, ...]].
    module SerializationSchema
      SYMBOL_TAG = 79

      SCHEMA = [
        nil, # tag 0 is reserved for NULL
        [:node, "RBS::AST::Annotation", true, nil, [[:string, :string]], false],
        [:bool],
        [:node, "RBS::AST::Comment", true, nil, [[:string, :string]], false],
        [:node, "RBS::AST::Declarations::Class", true, [[:keyword, true], [:name, true], [:end, true], [:type_params, false], [:lt, false]], [[:name, :node], [:type_params, :node_list], [:super_class, :node], [:members, :node_list], [:annotations, :node_list], [:comment, :node]], true],
        [:node, "RBS::AST::Declarations::Class::Super", true, [[:name, true], [:args, false]], [[:name, :node], [:args, :node_list]], false],
        [:node, "RBS::AST::Declarations::ClassAlias", true, [[:keyword, true], [:new_name, true], [:eq, true], [:old_name, true]], [[:new_name, :node], [:old_name, :node], [:comment, :node], [:annotations, :node_list]], false],
        [:node, "RBS::AST::Declarations::Constant", true, [[:name, true], [:colon, true]], [[:name, :node], [:type, :node], [:comment, :node], [:annotations, :node_list]], false],
        [:node, "RBS::AST::Declarations::Global", true, [[:name, true], [:colon, true]], [[:name, :node], [:type, :node], [:comment, :node], [:annotations, :node_list]], false],
        [:node, "RBS::AST::Declarations::Interface", true, [[:keyword, true], [:name, true], [:end, true], [:type_params, false]], [[:name, :node], [:type_params, :node_list], [:members, :node_list], [:annotations, :node_list], [:comment, :node]], true],
        [:node, "RBS::AST::Declarations::Module", true, [[:keyword, true], [:name, true], [:end, true], [:type_params, false], [:colon, false], [:self_types, false]], [[:name, :node], [:type_params, :node_list], [:self_types, :node_list], [:members, :node_list], [:annotations, :node_list], [:comment, :node]], true],
        [:node, "RBS::AST::Declarations::Module::Self", true, [[:name, true], [:args, false]], [[:name, :node], [:args, :node_list]], false],
        [:node, "RBS::AST::Declarations::ModuleAlias", true, [[:keyword, true], [:new_name, true], [:eq, true], [:old_name, true]], [[:new_name, :node], [:old_name, :node], [:comment, :node], [:annotations, :node_list]], false],
        [:node, "RBS::AST::Declarations::TypeAlias", true, [[:keyword, true], [:name, true], [:eq, true], [:type_params, false]], [[:name, :node], [:type_params, :node_list], [:type, :node], [:annotations, :node_list], [:comment, :node]], true],
        [:node, "RBS::AST::Directives::Use", true, [[:keyword, true]], [[:clauses, :node_list]], false],
        [:node, "RBS::AST::Directives::Use::SingleClause", true, [[:type_name, true], [:keyword, false], [:new_name, false]], [[:type_name, :node], [:new_name, :node]], false],
        [:node, "RBS::AST::Directives::Use::WildcardClause", true, [[:namespace, true], [:star, true]], [[:namespace, :node]], false],
        [:integer],
        [:node, "RBS::AST::Members::Alias", true, [[:keyword, true], [:new_name, true], [:old_name, true], [:new_kind, false], [:old_kind, false]], [[:new_name, :node], [:old_name, :node], [:kind, [:enum, [:instance, :singleton]]], [:annotations, :node_list], [:comment, :node]], false],
        [:node, "RBS::AST::Members::AttrAccessor", true, [[:keyword, true], [:name, true], [:colon, true], [:kind, false], [:ivar, false], [:ivar_name, false], [:visibility, false]], [[:name, :node], [:type, :node], [:ivar_name, :attr_ivar_name], [:kind, [:enum, [:instance, :singleton]]], [:annotations, :node_list], [:comment, :node], [:visibility, [:enum, [nil, :public, :private]]]], false],
        [:node, "RBS::AST::Members::AttrReader", true, [[:keyword, true], [:name, true], [:colon, true], [:kind, false], [:ivar, false], [:ivar_name, false], [:visibility, false]], [[:name, :node], [:type, :node], [:ivar_name, :attr_ivar_name], [:kind, [:enum, [:instance, :singleton]]], [:annotations, :node_list], [:comment, :node], [:visibility, [:enum, [nil, :public, :private]]]], false],
        [:node, "RBS::AST::Members::AttrWriter", true, [[:keyword, true], [:name, true], [:colon, true], [:kind, false], [:ivar, false], [:ivar_name, false], [:visibility, false]], [[:name, :node], [:type, :node], [:ivar_name, :attr_ivar_name], [:kind, [:enum, [:instance, :singleton]]], [:annotations, :node_list], [:comment, :node], [:visibility, [:enum, [nil, :public, :private]]]], false],
        [:node, "RBS::AST::Members::ClassInstanceVariable", true, [[:name, true], [:colon, true], [:kind, false]], [[:name, :node], [:type, :node], [:comment, :node]], false],
        [:node, "RBS::AST::Members::ClassVariable", true, [[:name, true], [:colon, true], [:kind, false]], [[:name, :node], [:type, :node], [:comment, :node]], false],
        [:node, "RBS::AST::Members::Extend", true, [[:name, true], [:keyword, true], [:args, false]], [[:name, :node], [:args, :node_list], [:annotations, :node_list], [:comment, :node]], false],
        [:node, "RBS::AST::Members::Include", true, [[:name, true], [:keyword, true], [:args, false]], [[:name, :node], [:args, :node_list], [:annotations, :node_list], [:comment, :node]], false],
        [:node, "RBS::AST::Members::InstanceVariable", true, [[:name, true], [:colon, true], [:kind, false]], [[:name, :node], [:type, :node], [:comment, :node]], false],
        [:node, "RBS::AST::Members::MethodDefinition", true, [[:keyword, true], [:name, true], [:kind, false], [:overloading, false], [:visibility, false]], [[:name, :node], [:kind, [:enum, [:instance, :singleton, :singleton_instance]]], [:overloads, :node_list], [:annotations, :node_list], [:comment, :node], [:overloading, :bool], [:visibility, [:enum, [nil, :public, :private]]]], false],
        [:node, "RBS::AST::Members::MethodDefinition::Overload", false, nil, [[:annotations, :node_list], [:method_type, :node]], false],
        [:node, "RBS::AST::Members::Prepend", true, [[:name, true], [:keyword, true], [:args, false]], [[:name, :node], [:args, :node_list], [:annotations, :node_list], [:comment, :node]], false],
        [:node, "RBS::AST::Members::Private", true, nil, nil, false],
        [:node, "RBS::AST::Members::Public", true, nil, nil, false],
        [:node, "RBS::AST::Ruby::Annotations::BlockParamTypeAnnotation", true, nil, [[:prefix_location, :location_range], [:ampersand_location, :location_range], [:name_location, :location_range], [:colon_location, :location_range], [:question_location, :location_range], [:type_location, :location_range], [:type, :node], [:comment_location, :location_range]], false],
        [:node, "RBS::AST::Ruby::Annotations::ClassAliasAnnotation", true, nil, [[:prefix_location, :location_range], [:keyword_location, :location_range], [:type_name, :node], [:type_name_location, :location_range]], false],
        [:node, "RBS::AST::Ruby::Annotations::ColonMethodTypeAnnotation", true, nil, [[:prefix_location, :location_range], [:annotations, :node_list], [:method_type, :node]], false],
        [:node, "RBS::AST::Ruby::Annotations::DoubleSplatParamTypeAnnotation", true, nil, [[:prefix_location, :location_range], [:star2_location, :location_range], [:name_location, :location_range], [:colon_location, :location_range], [:param_type, :node], [:comment_location, :location_range]], false],
        [:node, "RBS::AST::Ruby::Annotations::InstanceVariableAnnotation", true, nil, [[:prefix_location, :location_range], [:ivar_name, :node], [:ivar_name_location, :location_range], [:colon_location, :location_range], [:type, :node], [:comment_location, :location_range]], false],
        [:node, "RBS::AST::Ruby::Annotations::MethodTypesAnnotation", true, nil, [[:prefix_location, :location_range], [:overloads, :node_list], [:vertical_bar_locations, :location_range_list], [:dot3_location, :location_range]], false],
        [:node, "RBS::AST::Ruby::Annotations::ModuleAliasAnnotation", true, nil, [[:prefix_location, :location_range], [:keyword_location, :location_range], [:type_name, :node], [:type_name_location, :location_range]], false],
        [:node, "RBS::AST::Ruby::Annotations::ModuleSelfAnnotation", true, nil, [[:prefix_location, :location_range], [:keyword_location, :location_range], [:colon_location, :location_range], [:name, :node], [:args, :node_list], [:open_bracket_location, :location_range], [:close_bracket_location, :location_range], [:args_comma_locations, :location_range_list], [:comment_location, :location_range]], false],
        [:node, "RBS::AST::Ruby::Annotations::NodeTypeAssertion", true, nil, [[:prefix_location, :location_range], [:type, :node]], false],
        [:node, "RBS::AST::Ruby::Annotations::ParamTypeAnnotation", true, nil, [[:prefix_location, :location_range], [:name_location, :location_range], [:colon_location, :location_range], [:param_type, :node], [:comment_location, :location_range]], false],
        [:node, "RBS::AST::Ruby::Annotations::ReturnTypeAnnotation", true, nil, [[:prefix_location, :location_range], [:return_location, :location_range], [:colon_location, :location_range], [:return_type, :node], [:comment_location, :location_range]], false],
        [:node, "RBS::AST::Ruby::Annotations::SkipAnnotation", true, nil, [[:prefix_location, :location_range], [:skip_location, :location_range], [:comment_location, :location_range]], false],
        [:node, "RBS::AST::Ruby::Annotations::SplatParamTypeAnnotation", true, nil, [[:prefix_location, :location_range], [:star_location, :location_range], [:name_location, :location_range], [:colon_location, :location_range], [:param_type, :node], [:comment_location, :location_range]], false],
        [:node, "RBS::AST::Ruby::Annotations::TypeApplicationAnnotation", true, nil, [[:prefix_location, :location_range], [:type_args, :node_list], [:close_bracket_location, :location_range], [:comma_locations, :location_range_list]], false],
        [:string_value],
        [:node, "RBS::AST::TypeParam", true, [[:name, true], [:variance, false], [:unchecked, false], [:upper_bound, false], [:lower_bound, false], [:default, false]], [[:name, :node], [:variance, [:enum, [:invariant, :covariant, :contravariant]]], [:upper_bound, :node], [:lower_bound, :node], [:default_type, :node], [:unchecked, :bool]], false],
        [:node, "RBS::MethodType", true, [[:type, true], [:type_params, false]], [[:type_params, :node_list], [:type, :node], [:block, :node]], true],
        [:namespace],
        [:signature],
        [:type_name],
        [:node, "RBS::Types::Alias", true, [[:name, true], [:args, false]], [[:name, :node], [:args, :node_list]], false],
        [:node, "RBS::Types::Bases::Any", true, nil, [[:todo, :bool]], false],
        [:node, "RBS::Types::Bases::Bool", true, nil, nil, false],
        [:node, "RBS::Types::Bases::Bottom", true, nil, nil, false],
        [:node, "RBS::Types::Bases::Class", true, nil, nil, false],
        [:node, "RBS::Types::Bases::Instance", true, nil, nil, false],
        [:node, "RBS::Types::Bases::Nil", true, nil, nil, false],
        [:node, "RBS::Types::Bases::Self", true, nil, nil, false],
        [:node, "RBS::Types::Bases::Top", true, nil, nil, false],
        [:node, "RBS::Types::Bases::Void", true, nil, nil, false],
        [:node, "RBS::Types::Block", true, nil, [[:type, :node], [:required, :bool], [:self_type, :node]], false],
        [:node, "RBS::Types::ClassInstance", true, [[:name, true], [:args, false]], [[:name, :node], [:args, :node_list]], false],
        [:node, "RBS::Types::ClassSingleton", true, [[:name, true], [:args, false]], [[:name, :node], [:args, :node_list]], false],
        [:node, "RBS::Types::Function", false, nil, [[:required_positionals, :node_list], [:optional_positionals, :node_list], [:rest_positionals, :node], [:trailing_positionals, :node_list], [:required_keywords, :hash], [:optional_keywords, :hash], [:rest_keywords, :node], [:forwarding, :node], [:return_type, :node]], false],
        [:node, "RBS::Types::Function::ForwardingParam", true, nil, nil, false],
        [:node, "RBS::Types::Function::Param", true, [[:name, false]], [[:type, :node], [:name, :node]], false],
        [:node, "RBS::Types::Interface", true, [[:name, true], [:args, false]], [[:name, :node], [:args, :node_list]], false],
        [:node, "RBS::Types::Intersection", true, nil, [[:types, :node_list]], false],
        [:node, "RBS::Types::Literal", true, nil, [[:literal, :node]], false],
        [:node, "RBS::Types::Optional", true, nil, [[:type, :node]], false],
        [:node, "RBS::Types::Proc", true, nil, [[:type, :node], [:block, :node], [:self_type, :node]], false],
        [:node, "RBS::Types::Record", true, nil, [[:all_fields, :hash]], false],
        [:record_field],
        [:node, "RBS::Types::Tuple", true, nil, [[:types, :node_list]], false],
        [:node, "RBS::Types::Union", true, nil, [[:types, :node_list]], false],
        [:node, "RBS::Types::UntypedFunction", false, nil, [[:return_type, :node]], false],
        [:node, "RBS::Types::Variable", true, nil, [[:name, :node]], false],
      ].freeze
    end
  end
end
