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.



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

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)



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

def arguments
  @arguments
end

#functor_exprObject (readonly)



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

def functor_expr
  @functor_expr
end

#lambdaObject (readonly)



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

def lambda
  @lambda
end

#rval_requiredObject (readonly)



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

def rval_required
  @rval_required
end

Class Method Details

._pcore_typeObject



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

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



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

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



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

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



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

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



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

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:



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

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

#_pcore_init_hashObject



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

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)


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

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