Module: Ryac

Defined in:
lib/ryac/errors.rb,
lib/ryac/packer.rb,
lib/ryac/version.rb,
lib/ryac/minifier.rb,
lib/ryac/ast_utils.rb,
lib/ryac/union_find.rb,
lib/ryac/driver_file.rb,
lib/ryac/gem_resolver.rb,
lib/ryac/name_generator.rb,
lib/ryac/pipeline/stage.rb,
lib/ryac/pipeline/errors.rb,
lib/ryac/analysis/nesting.rb,
lib/ryac/pipeline/analyzer.rb,
lib/ryac/pipeline/compactor.rb,
lib/ryac/pipeline/data_types.rb,
lib/ryac/analysis/type_oracle.rb,
lib/ryac/analysis/lazy_regions.rb,
lib/ryac/analysis/local_scopes.rb,
lib/ryac/pipeline/char_shorten.rb,
lib/ryac/pipeline/concatenator.rb,
lib/ryac/pipeline/stage_runner.rb,
lib/ryac/pipeline/constant_fold.rb,
lib/ryac/analysis/method_aliases.rb,
lib/ryac/pipeline/endless_method.rb,
lib/ryac/pipeline/file_collector.rb,
lib/ryac/pipeline/method_renamer.rb,
lib/ryac/pipeline/rename_patcher.rb,
lib/ryac/pipeline/source_patcher.rb,
lib/ryac/analysis/cvar/collection.rb,
lib/ryac/analysis/gvar/collection.rb,
lib/ryac/analysis/ivar/collection.rb,
lib/ryac/analysis/method_aliasing.rb,
lib/ryac/pipeline/boolean_shorten.rb,
lib/ryac/pipeline/paren_optimizer.rb,
lib/ryac/analysis/scope_management.rb,
lib/ryac/pipeline/constant_aliaser.rb,
lib/ryac/pipeline/spelling_shorten.rb,
lib/ryac/pipeline/variable_renamer.rb,
lib/ryac/analysis/method/collection.rb,
lib/ryac/pipeline/attr_decl_shorten.rb,
lib/ryac/analysis/keyword/collection.rb,
lib/ryac/analysis/constant/collection.rb,
lib/ryac/analysis/gvar/rename_mapping.rb,
lib/ryac/analysis/site_bucket_mapping.rb,
lib/ryac/analysis/method/rename_mapping.rb,
lib/ryac/pipeline/control_flow_simplify.rb,
lib/ryac/analysis/keyword/rename_mapping.rb,
lib/ryac/analysis/constant/rename_mapping.rb,
sig/ryac.rbs,
sig/ryac/errors.rbs,
sig/ryac/packer.rbs,
sig/ryac/minifier.rbs,
sig/ryac/ast_utils.rbs,
sig/ryac/union_find.rbs,
sig/ryac/driver_file.rbs,
sig/ryac/gem_resolver.rbs,
sig/ryac/name_generator.rbs,
sig/ryac/pipeline/stage.rbs,
sig/ryac/pipeline/errors.rbs,
sig/ryac/analysis/nesting.rbs,
sig/ryac/pipeline/analyzer.rbs,
sig/ryac/pipeline/compactor.rbs,
sig/ryac/pipeline/data_types.rbs,
sig/ryac/analysis/type_oracle.rbs,
sig/ryac/analysis/lazy_regions.rbs,
sig/ryac/analysis/local_scopes.rbs,
sig/ryac/pipeline/char_shorten.rbs,
sig/ryac/pipeline/concatenator.rbs,
sig/ryac/pipeline/stage_runner.rbs,
sig/ryac/pipeline/constant_fold.rbs,
sig/ryac/analysis/method_aliases.rbs,
sig/ryac/pipeline/endless_method.rbs,
sig/ryac/pipeline/file_collector.rbs,
sig/ryac/pipeline/method_renamer.rbs,
sig/ryac/pipeline/rename_patcher.rbs,
sig/ryac/pipeline/source_patcher.rbs,
sig/ryac/analysis/cvar/collection.rbs,
sig/ryac/analysis/gvar/collection.rbs,
sig/ryac/analysis/ivar/collection.rbs,
sig/ryac/analysis/method_aliasing.rbs,
sig/ryac/pipeline/boolean_shorten.rbs,
sig/ryac/pipeline/paren_optimizer.rbs,
sig/ryac/analysis/scope_management.rbs,
sig/ryac/pipeline/constant_aliaser.rbs,
sig/ryac/pipeline/spelling_shorten.rbs,
sig/ryac/pipeline/variable_renamer.rbs,
sig/ryac/analysis/method/collection.rbs,
sig/ryac/pipeline/attr_decl_shorten.rbs,
sig/ryac/analysis/keyword/collection.rbs,
sig/ryac/analysis/constant/collection.rbs,
sig/ryac/analysis/gvar/rename_mapping.rbs,
sig/ryac/analysis/site_bucket_mapping.rbs,
sig/ryac/analysis/method/rename_mapping.rbs,
sig/ryac/pipeline/control_flow_simplify.rbs,
sig/ryac/analysis/keyword/rename_mapping.rbs,
sig/ryac/analysis/constant/rename_mapping.rbs

Overview

The error hierarchy lives in its own required file, not in ryac.rb: superclass references execute at load, and the concatenated self-host artifact places dependencies first and the root file's own body last — a class defined in the root body can never be a parent for a class defined in a required file.

Defined Under Namespace

Modules: AnalysisPhases, AstUtils, BootConstants, DriverFile, LazyRegions, Nesting, Packer, Pipeline, RenameInvariants, UnionFind Classes: ConstantInfo, ConstantRenameMapping, Error, ExternalPrefixInfo, GemResolver, GvarRenameMapping, InputError, InternalError, KeywordRenameMapping, LocalScopes, MethodRenameMapping, Minifier, MinifyError, NameGenerator, SiteBucketMapping, SyntaxError, TypeOracle

Constant Summary collapse

VERSION =

Returns:

  • (String)
"0.3.0"
KERNEL_ALIASES =

Method alias mappings: longer method name => shorter equivalent TypeProf verifies at analysis time that the shorter method is available on the receiver type via inheritance chain.

SELF-HOSTING NOTE: these rewrites fire only where inference proves the receiver, and inference over lib/'s own source can shift between self-hosting passes; the integration suite's fixed-point check is what catches a rewrite firing on one pass only. Object/Kernel aliases where both spellings name the same method on EVERY receiver — the only rows safe on a receiverless call, which dispatches on whatever self happens to be.

Returns:

  • (Hash[Symbol, Symbol])
{
  kind_of?:   :is_a?,
  yield_self: :then,
  object_id:  :__id__,
  raise:      :fail,
}.freeze
RECEIVER_ALIASES =

Receiver-specific synonyms (Enumerable/Hash/String/...): a receiverless spelling can name something else entirely (include? in a class body is Module#include?), so these fire only when inference proves the receiver responds to the short spelling.

Returns:

  • (Hash[Symbol, Symbol])
{
  collect:        :map,
  collect!:       :map!,
  detect:         :find,
  find_all:       :select,
  collect_concat: :flat_map,
  each_pair:      :each,
  has_key?:       :key?,
  has_value?:     :value?,
  find_index:     :index,
  magnitude:      :abs,
  id2name:        :to_s,
  length:         :size,
  entries:        :to_a,
  append:         :push,
  include?:       :key?,
  member?:        :key?,
}.freeze
METHOD_ALIASES =

Returns:

  • (Hash[Symbol, Symbol])
KERNEL_ALIASES.merge(RECEIVER_ALIASES).freeze
EMPTY_LITERALS =

The literal an emptiness rewrite compares against, per receiver type — the single fact both transform tables below build on.

Returns:

  • (Hash[Symbol, String])
{ Array: '[]', String: '""', Hash: '{}' }.freeze
METHOD_TRANSFORMS =

Structural method transforms: method call → different syntax Applied only when TypeProf verifies receiver type compatibility. Key: [method_name, :ClassName], Value: replacement string

Returns:

  • (Hash[[Symbol, Symbol], String])
{
  [:first, :Array] => '[0]',
  [:zero?, :Numeric] => '==0',
  **EMPTY_LITERALS.to_h { |type, lit| [[:empty?, type], "==#{lit}"] },
}.freeze
SIZE_COMPARISON_OPS =

The comparison operators the size-comparison transforms recognize, and the spelling each takes in the rewrite: > 0 means non-empty for a size, so it shares the != spelling.

Returns:

  • (Hash[Symbol, String])
{ :== => '==', :!= => '!=', :> => '!=' }.freeze
SIZE_COMPARISON_TRANSFORMS =

Whole-comparison transforms: .size==0 and friends collapse to a literal comparison under the same receiver-type gate as the empty? rows, one call deeper. Key: [comparison_op, :ClassName], value: the replacement for .mid op 0.

Returns:

  • (Hash[[Symbol, Symbol], String])
SIZE_COMPARISON_OPS.each_with_object(
  {} #: Hash[[Symbol, Symbol], String]
) { |(op, spelled), table|
  EMPTY_LITERALS.each { |type, lit| table[[op, type]] = "#{spelled}#{lit}" }
}.freeze
SIZE_QUERY_MIDS =

The inner calls those comparisons recognize, with the types where the no-argument form means size. String#count requires an argument, so a bare .count is never a String size query.

Returns:

  • (Hash[Symbol, Array[Symbol]])
{
  size: %i[Array String Hash],
  length: %i[Array String Hash],
  count: %i[Array Hash],
}.freeze
EXCLUDED_METHODS =

Returns:

  • (Set[Symbol])
%i[
  initialize initialize_copy initialize_clone initialize_dup
  method_missing respond_to_missing? const_missing
  inherited included extended prepended
  marshal_dump marshal_load encode_with init_with
  call to_s to_str to_i to_int to_f to_r to_c
  to_a to_ary to_h to_hash to_io to_proc
  inspect hash eql? equal? frozen? nil?
  class is_a? kind_of? instance_of?
  coerce respond_to? dup clone freeze
  each __send__ __id__
  <=> == === != < > <= >= + - * / % ** & | ^ << >> =~ !~
  [] []= ! ~ +@ -@
].to_set.freeze