class Bpl::AST::FunctionApplication

Public Instance Methods

eql?(fa) click to toggle source
# File lib/bpl/ast/expression.rb, line 67
def eql?(fa)
  fa.is_a?(FunctionApplication) &&
  fa.function.eql?(@function) &&
  fa.arguments.eql?(@arguments)
end
hilite() click to toggle source
# File lib/bpl/ast/expression.rb, line 73
def hilite
  "#{@function.hilite}(#{@arguments.map(&:hilite) * ", "})" +
  (type ? ":#{type.hilite}" : "")
end
show() click to toggle source
# File lib/bpl/ast/expression.rb, line 72
def show; "#{yield @function}(#{@arguments.map{|a| yield a} * ","})" end
type() click to toggle source
# File lib/bpl/ast/expression.rb, line 77
def type
  @function.declaration && @function.declaration.return.type
end
type_check() click to toggle source
# File lib/bpl/passes/analysis/type_checking.rb, line 13
def type_check
  return unless d = @function.declaration

  params = d.arguments # .map(&:flatten).flatten
  unless params.count == arguments.count
    warn "wrong number of arguments to function #{d.signature}" \
      "\n  #{hilite.underline}"
  end

  arguments.each.with_index do |a,i|
    break unless i < params.count
    unless params[i].type.expand.to_s == a.type.expand.to_s
      warn "invalid type for argument #{i} in application of #{d.signature}" \
        "\n  #{hilite.underline}"
    end
  end

end