Class: Puppet::Pops::Model::CallExpression

Inherits:
Expression show all
Defined in:
lib/puppet/pops/model/ast.rb

Instance Attribute Summary collapse

Attributes inherited from Positioned

#length, #locator, #offset

Attributes inherited from PopsObject

#hash

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Positioned

#file, #line, #pos

Methods inherited from PopsObject

#to_s

Methods included from Types::PuppetObject

#_pcore_type, #to_s

Constructor Details

#initialize(locator, offset, length, functor_expr, rval_required = false, arguments = _pcore_type['arguments'].value, lambda = nil) ⇒ CallExpression

Returns a new instance of CallExpression.



3060
3061
3062
3063
3064
3065
3066
3067
# File 'lib/puppet/pops/model/ast.rb', line 3060

def initialize(locator, offset, length, functor_expr, rval_required = false, arguments = _pcore_type['arguments'].value, lambda = nil)
  super(locator, offset, length)
  @hash = @hash ^ rval_required.hash ^ functor_expr.hash ^ arguments.hash ^ lambda.hash
  @rval_required = rval_required
  @functor_expr = functor_expr
  @arguments = arguments
  @lambda = lambda
end

Instance Attribute Details

#argumentsObject (readonly)



3057
3058
3059
# File 'lib/puppet/pops/model/ast.rb', line 3057

def arguments
  @arguments
end

#functor_exprObject (readonly)



3056
3057
3058
# File 'lib/puppet/pops/model/ast.rb', line 3056

def functor_expr
  @functor_expr
end

#lambdaObject (readonly)



3058
3059
3060
# File 'lib/puppet/pops/model/ast.rb', line 3058

def lambda
  @lambda
end

#rval_requiredObject (readonly)



3055
3056
3057
# File 'lib/puppet/pops/model/ast.rb', line 3055

def rval_required
  @rval_required
end

Class Method Details

._pcore_typeObject



3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
# File 'lib/puppet/pops/model/ast.rb', line 3004

def self._pcore_type
  @_pcore_type ||=
    Types::PObjectType
      .new('Puppet::AST::CallExpression', {
             'parent' => Expression._pcore_type,
             'attributes' => {
               'rval_required' => {
                 'type' => Types::PBooleanType::DEFAULT,
                 'value' => false
               },
               'functor_expr' => Expression._pcore_type,
               'arguments' => {
                 'type' => Types::PArrayType.new(Expression._pcore_type),
                 'value' => []
               },
               'lambda' => {
                 'type' => Types::POptionalType.new(Expression._pcore_type),
                 'value' => nil
               }
             }
           })
end

.create(locator, offset, length, functor_expr, rval_required = false, arguments = _pcore_type['arguments'].value, lambda = nil) ⇒ Object



3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
# File 'lib/puppet/pops/model/ast.rb', line 3042

def self.create(locator, offset, length, functor_expr, rval_required = false, arguments = _pcore_type['arguments'].value, lambda = nil)
  ta = Types::TypeAsserter
  attrs = _pcore_type.attributes(true)
  ta.assert_instance_of('Puppet::AST::Positioned[locator]', attrs['locator'].type, locator)
  ta.assert_instance_of('Puppet::AST::Positioned[offset]', attrs['offset'].type, offset)
  ta.assert_instance_of('Puppet::AST::Positioned[length]', attrs['length'].type, length)
  ta.assert_instance_of('Puppet::AST::CallExpression[rval_required]', attrs['rval_required'].type, rval_required)
  ta.assert_instance_of('Puppet::AST::CallExpression[functor_expr]', attrs['functor_expr'].type, functor_expr)
  ta.assert_instance_of('Puppet::AST::CallExpression[arguments]', attrs['arguments'].type, arguments)
  ta.assert_instance_of('Puppet::AST::CallExpression[lambda]', attrs['lambda'].type, lambda)
  new(locator, offset, length, functor_expr, rval_required, arguments, lambda)
end

.from_asserted_hash(init_hash) ⇒ Object



3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
# File 'lib/puppet/pops/model/ast.rb', line 3031

def self.from_asserted_hash(init_hash)
  new(
    init_hash['locator'],
    init_hash['offset'],
    init_hash['length'],
    init_hash['functor_expr'],
    init_hash.fetch('rval_required') { false },
    init_hash.fetch('arguments') { _pcore_type['arguments'].value },
    init_hash['lambda'])
end

.from_hash(init_hash) ⇒ Object



3027
3028
3029
# File 'lib/puppet/pops/model/ast.rb', line 3027

def self.from_hash(init_hash)
  from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::CallExpression initializer', _pcore_type.init_hash_type, init_hash))
end

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object



3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
# File 'lib/puppet/pops/model/ast.rb', line 3084

def _pcore_all_contents(path, &block)
  path << self
  unless @functor_expr.nil?
    block.call(@functor_expr, path)
    @functor_expr._pcore_all_contents(path, &block)
  end
  @arguments.each do |value|
    block.call(value, path)
    value._pcore_all_contents(path, &block)
  end
  unless @lambda.nil?
    block.call(@lambda, path)
    @lambda._pcore_all_contents(path, &block)
  end
  path.pop
end

#_pcore_contents {|@functor_expr| ... } ⇒ Object

Yields:



3078
3079
3080
3081
3082
# File 'lib/puppet/pops/model/ast.rb', line 3078

def _pcore_contents
  yield(@functor_expr) unless @functor_expr.nil?
  @arguments.each { |value| yield(value) }
  yield(@lambda) unless @lambda.nil?
end

#_pcore_init_hashObject



3069
3070
3071
3072
3073
3074
3075
3076
# File 'lib/puppet/pops/model/ast.rb', line 3069

def _pcore_init_hash
  result = super
  result['rval_required'] = @rval_required unless @rval_required == false
  result['functor_expr'] = @functor_expr
  result['arguments'] = @arguments unless _pcore_type['arguments'].default_value?(@arguments)
  result['lambda'] = @lambda unless @lambda == nil
  result
end

#eql?(o) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


3101
3102
3103
3104
3105
3106
3107
# File 'lib/puppet/pops/model/ast.rb', line 3101

def eql?(o)
  super &&
  @rval_required.eql?(o.rval_required) &&
  @functor_expr.eql?(o.functor_expr) &&
  @arguments.eql?(o.arguments) &&
  @lambda.eql?(o.lambda)
end