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


3186
3187
3188
3189
3190
3191
3192
3193
# File 'lib/puppet/pops/model/ast.rb', line 3186

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)


3183
3184
3185
# File 'lib/puppet/pops/model/ast.rb', line 3183

def arguments
  @arguments
end

#functor_exprObject (readonly)


3182
3183
3184
# File 'lib/puppet/pops/model/ast.rb', line 3182

def functor_expr
  @functor_expr
end

#lambdaObject (readonly)


3184
3185
3186
# File 'lib/puppet/pops/model/ast.rb', line 3184

def lambda
  @lambda
end

#rval_requiredObject (readonly)


3181
3182
3183
# File 'lib/puppet/pops/model/ast.rb', line 3181

def rval_required
  @rval_required
end

Class Method Details

._pcore_typeObject


3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
# File 'lib/puppet/pops/model/ast.rb', line 3132

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


3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
# File 'lib/puppet/pops/model/ast.rb', line 3168

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


3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
# File 'lib/puppet/pops/model/ast.rb', line 3157

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


3153
3154
3155
# File 'lib/puppet/pops/model/ast.rb', line 3153

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


3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
# File 'lib/puppet/pops/model/ast.rb', line 3210

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:


3204
3205
3206
3207
3208
# File 'lib/puppet/pops/model/ast.rb', line 3204

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

#_pcore_init_hashObject


3195
3196
3197
3198
3199
3200
3201
3202
# File 'lib/puppet/pops/model/ast.rb', line 3195

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)

3227
3228
3229
3230
3231
3232
3233
# File 'lib/puppet/pops/model/ast.rb', line 3227

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