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

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.



3063
3064
3065
3066
3067
3068
3069
3070
# File 'lib/puppet/pops/model/ast.rb', line 3063

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)



3060
3061
3062
# File 'lib/puppet/pops/model/ast.rb', line 3060

def arguments
  @arguments
end

#functor_exprObject (readonly)



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

def functor_expr
  @functor_expr
end

#lambdaObject (readonly)



3061
3062
3063
# File 'lib/puppet/pops/model/ast.rb', line 3061

def lambda
  @lambda
end

#rval_requiredObject (readonly)



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

def rval_required
  @rval_required
end

Class Method Details

._pcore_typeObject



3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
# File 'lib/puppet/pops/model/ast.rb', line 3009

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



3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
# File 'lib/puppet/pops/model/ast.rb', line 3045

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



3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
# File 'lib/puppet/pops/model/ast.rb', line 3034

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



3030
3031
3032
# File 'lib/puppet/pops/model/ast.rb', line 3030

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



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

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:



3081
3082
3083
3084
3085
# File 'lib/puppet/pops/model/ast.rb', line 3081

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

#_pcore_init_hashObject



3072
3073
3074
3075
3076
3077
3078
3079
# File 'lib/puppet/pops/model/ast.rb', line 3072

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)


3104
3105
3106
3107
3108
3109
3110
# File 'lib/puppet/pops/model/ast.rb', line 3104

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