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.


2995
2996
2997
2998
2999
3000
3001
3002
# File 'lib/puppet/pops/model/ast.rb', line 2995

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)


2992
2993
2994
# File 'lib/puppet/pops/model/ast.rb', line 2992

def arguments
  @arguments
end

#functor_exprObject (readonly)


2991
2992
2993
# File 'lib/puppet/pops/model/ast.rb', line 2991

def functor_expr
  @functor_expr
end

#lambdaObject (readonly)


2993
2994
2995
# File 'lib/puppet/pops/model/ast.rb', line 2993

def lambda
  @lambda
end

#rval_requiredObject (readonly)


2990
2991
2992
# File 'lib/puppet/pops/model/ast.rb', line 2990

def rval_required
  @rval_required
end

Class Method Details

._pcore_typeObject


2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
# File 'lib/puppet/pops/model/ast.rb', line 2941

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


2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
# File 'lib/puppet/pops/model/ast.rb', line 2977

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


2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
# File 'lib/puppet/pops/model/ast.rb', line 2966

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


2962
2963
2964
# File 'lib/puppet/pops/model/ast.rb', line 2962

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


3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
# File 'lib/puppet/pops/model/ast.rb', line 3019

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:


3013
3014
3015
3016
3017
# File 'lib/puppet/pops/model/ast.rb', line 3013

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

#_pcore_init_hashObject


3004
3005
3006
3007
3008
3009
3010
3011
# File 'lib/puppet/pops/model/ast.rb', line 3004

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)

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

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