Class: Dhallish::Ast::RecordTypeRecursiveMergeNode

Inherits:
Object
  • Object
show all
Defined in:
lib/ast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lhs, rhs) ⇒ RecordTypeRecursiveMergeNode

Returns a new instance of RecordTypeRecursiveMergeNode.



542
543
544
545
# File 'lib/ast.rb', line 542

def initialize(lhs, rhs)
  @lhs = lhs
  @rhs = rhs
end

Instance Attribute Details

#lhsObject

Returns the value of attribute lhs.



539
540
541
# File 'lib/ast.rb', line 539

def lhs
  @lhs
end

#rhsObject

Returns the value of attribute rhs.



540
541
542
# File 'lib/ast.rb', line 540

def rhs
  @rhs
end

Instance Method Details

#compute_type(ctx) ⇒ Object



547
548
549
550
551
552
553
554
# File 'lib/ast.rb', line 547

def compute_type(ctx)
  lhs = @lhs.compute_type ctx
  rhs = @rhs.compute_type ctx
  assert("`//\\\\` can only merge record types") {
    lhs.is_a? Types::Type and rhs.is_a? Types::Type and
    lhs..is_a? Types::Record and rhs..is_a? Types::Record }
  Types::Type.new(::Dhallish::mergeRecordTypes(lhs., rhs.))
end

#evaluate(ctx) ⇒ Object



556
557
558
559
560
# File 'lib/ast.rb', line 556

def evaluate(ctx)
  lhs = @lhs.evaluate(ctx)
  rhs = @rhs.evaluate(ctx)
  ::Dhallish::mergeRecordTypes(lhs, rhs)
end