class Puppet::Pops::Binder::BindingsModelDumper

Dumps a Pops::Binder::Bindings model in reverse polish notation; i.e. LISP style The intention is to use this for debugging output TODO: BAD NAME - A DUMP is a Ruby Serialization NOTE: use :break, :indent, :dedent in lists to do just that

Constants

Bindings

Attributes

expression_dumper[R]
type_calculator[R]

Public Instance Methods

dump_ASTArray(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 48
def dump_ASTArray o
  ["[]"] + o.children.collect {|x| do_dump(x)}
end
dump_ASTHash(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 52
def dump_ASTHash o
  ["{}"] + o.value.sort_by{|k,v| k.to_s}.collect {|x| [do_dump(x[0]), do_dump(x[1])]}
end
dump_Array(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 44
def dump_Array o
  o.collect {|e| do_dump(e) }
end
dump_ArrayMultibindProducerDescriptor(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 128
def dump_ArrayMultibindProducerDescriptor o
  ['multibind-array']
end
dump_Binding(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 140
def dump_Binding o
  result = ['bind']
  result << 'override' if o.override
  result << 'abstract' if o.abstract
  result.concat([do_dump(o.type), o.name])
  result << "(in #{o.multibind_id})" if o.multibind_id
  result << ['to', do_dump(o.producer)] + do_dump(o.producer_args)
  result
end
dump_Bindings(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 160
def dump_Bindings o
  do_dump(o.bindings)
end
dump_BindingsBuilder(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 23
def dump_BindingsBuilder o
  do_dump(o.model)
end
dump_BindingsContainerBuilder(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 27
def dump_BindingsContainerBuilder o
  do_dump(o.model)
end
dump_BindingsFactory(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 19
def dump_BindingsFactory o
  do_dump(o.model)
end
dump_ConstantProducerDescriptor(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 87
def dump_ConstantProducerDescriptor o
  ['constant', do_dump(o.value)]
end
dump_ContributedBindings(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 184
def dump_ContributedBindings o
  ['contributed', o.name, do_dump(o.bindings)]
end
dump_EvaluatingProducerDescriptor(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 91
def dump_EvaluatingProducerDescriptor o
  result = dump_ProducerDescriptor(o)
  result << expression_dumper.dump(o.expression)
end
dump_FirstFoundProducerDescriptor(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 123
def dump_FirstFoundProducerDescriptor o
  # TODO: transformer lambda
  ['first-found', do_dump(o.producers)]
end
dump_HashLookupProducerDescriptor(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 116
def dump_HashLookupProducerDescriptor o
  # TODO: transformer lambda
  result = ['hash-lookup', do_dump(o.type), o.name, "[#{do_dump(o.key)}]"]
  result << expression_dumper.dump(o.transformer) if o.transformer
  result
end
dump_HashMultibindProducerDescriptor(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 132
def dump_HashMultibindProducerDescriptor o
  ['multibind-hash']
end
dump_InstanceProducerDescriptor(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 96
def dump_InstanceProducerDescriptor o
  # TODO: o.arguments, o. transformer
  ['instance', o.class_name]
end
dump_Integer(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 56
def dump_Integer o
  o.to_s
end
dump_LayeredBindings(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 174
def dump_LayeredBindings o
  result = ['layers', :indent]
    o.layers.each do |layer|
      result << :break
      result << do_dump(layer)
    end
  result << :dedent
  result
end
dump_LookupProducerDescriptor(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 108
def dump_LookupProducerDescriptor o
  ['lookup', do_dump(o.type), o.name]
end
dump_Multibinding(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 150
def dump_Multibinding o
  result = ['multibind', o.id]
  result << 'override' if o.override
  result << 'abstract' if o.abstract
  result.concat([do_dump(o.type), o.name])
  result << "(in #{o.multibind_id})" if o.multibind_id
  result << ['to', do_dump(o.producer)] + do_dump(o.producer_args)
  result
end
dump_NamedArgument(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 136
def dump_NamedArgument o
  "#{o.name} => #{do_dump(o.value)}"
end
dump_NamedBindings(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 164
def dump_NamedBindings o
  result = ['named-bindings', o.name, :indent]
  o.bindings.each do |b|
    result << :break
    result << do_dump(b)
  end
  result << :dedent
  result
end
dump_NamedLayer(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 31
def dump_NamedLayer o
  result = ['named-layer', (o.name.nil? ? '<no-name>': o.name), :indent]
  if o.bindings
    o.bindings.each do |b|
      result << :break
      result << do_dump(b)
    end
  end
  result << :dedent
  result
end
dump_NilClass(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 65
def dump_NilClass o
  "()"
end
dump_NonCachingProducerDescriptor(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 83
def dump_NonCachingProducerDescriptor o
  dump_ProducerDescriptor(o) + do_dump(o.producer)
end
dump_Object(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 69
def dump_Object o
  ['dev-error-no-polymorph-dump-for:', o.class.to_s, o.to_s]
end
dump_PAnyType(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 112
def dump_PAnyType o
  type_calculator.string(o)
end
dump_ProducerDescriptor(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 77
def dump_ProducerDescriptor o
   result = [o.class.name]
   result << expression_dumper.dump(o.transformer) if o.transformer
   result
end
dump_ProducerProducerDescriptor(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 101
def dump_ProducerProducerDescriptor o
  # skip the transformer lambda...
  result = ['producer-producer', do_dump(o.producer)]
  result << expression_dumper.dump(o.transformer) if o.transformer
  result
end
dump_String(o) click to toggle source

Dump a Ruby String in single quotes unless it is a number.

# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 61
def dump_String o
  "'#{o}'"
end
is_nop?(o) click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 73
def is_nop? o
  o.nil? || o.is_a?(Model::Nop) || o.is_a?(AST::Nop)
end

Public Class Methods

new() click to toggle source
# File lib/puppet/pops/binder/bindings_model_dumper.rb, line 13
def initialize
  super
  @type_calculator = Puppet::Pops::Types::TypeCalculator.new()
  @expression_dumper = Puppet::Pops::Model::ModelTreeDumper.new()
end