class IDL::Expression::Operation

Constants

NUMBER_OF_OPERANDS

Attributes

operands[R]

Public Class Methods

new(*_operands) click to toggle source
# File lib/ridl/expression.rb, line 93
def initialize(*_operands)
  n = self.class::NUMBER_OF_OPERANDS

  if _operands.size != n
    raise format("%s must receive %d operand%s.",
      self.typename, n, if (n > 1) then "s" else "" end)
  end

  unless _operands.any? { |o| o.is_template? }
    @idltype = self.class.suite_type(*(_operands.collect { |o| o.idltype.resolved_type }))
    @value = calculate(*(_operands.collect { |o| o.value }))
  else
    @idltype = nil
    @value = nil
  end
  @operands = _operands
  self.set_type
end
suite_type(*types) click to toggle source
# File lib/ridl/expression.rb, line 120
def Operation.suite_type(*types)
  types.each do |t|
    unless self::Applicable.include? t.class
      raise "#{self.name} cannot be applicable for #{t.typename}"
    end
  end

  ret = nil
  types = types.collect { |t| t.class }
  self::Applicable.each do |t|
    if types.include? t
      ret = t
      break
    end
  end
  ret
end

Public Instance Methods

instantiate(instantiation_context) click to toggle source
# File lib/ridl/expression.rb, line 116
def instantiate(instantiation_context)
  self.is_template? ? self.class.new(*@operands.collect { |o| o.instantiate(instantiation_context) }) : self
end
is_template?() click to toggle source
# File lib/ridl/expression.rb, line 112
def is_template?
  @operands.any? { |o| o.is_template? }
end
set_type() click to toggle source
# File lib/ridl/expression.rb, line 138
def set_type; end