class PrismCompilerMonkeyPatches::Sexp
Constants
- NODE_NAMES
Attributes
Whether or not this sexp is a mutated/modified sexp.
Whether or not this sexp is a mutated/modified sexp.
Public Instance Methods
Source
# File lib/flay.rb, line 615 def all_structural_subhashes hashes = [] self.deep_each do |node| hashes << node.structural_hash end hashes end
Returns a list of structural hashes for all nodes (and sub-nodes) of this sexp.
Source
# File lib/flay.rb, line 660 def code_index { :block => 0, # s(:block, *code) :class => 2, # s(:class, name, super, *code) :module => 1, # s(:module, name, *code) :defn => 2, # s(:defn, name, args, *code) :defs => 3, # s(:defs, recv, name, args, *code) :iter => 2, # s(:iter, recv, args, *code) }[self.sexp_type] end
Return the index of the last non-code element, or nil if this sexp is not a code-bearing node.
Also aliased as: has_code?
Source
# File lib/flay.rb, line 652 def split_at n return self[0..n], self[n+1..-1] end
Useful general array method that splits the array from 0..n and the rest. Returns both sections.
Source
# File lib/flay.rb, line 677 def split_code index = self.code_index self.split_at index if index end
Split the sexp into front-matter and code-matter, returning both. See code_index.
Source
# File lib/flay.rb, line 607 def structural_hash @structural_hash ||= pure_ruby_hash end
Calculate the structural hash for this sexp. Cached, so don’t modify the sexp afterwards and expect it to be correct.