class Pione::Lang::CaseBranch

CaseBranch is a class for case branches.

Public Instance Methods

eval(env) click to toggle source

Return suitable context in the environment.

# File lib/pione/lang/conditional-branch.rb, line 59
def eval(env)
  # evaluate the condition
  val = expr.eval!(env)

  # return matched branch's context
  _, matched = when_contexts.find do |_expr, _context|
    val.call_pione_method(env, "==*", [_expr]).value
  end

  # return matched context, else-context, or empty context
  return matched || else_context || ConditionalBranchContext.new
end
validate(acceptances) click to toggle source

Validate inner contexts based on the list of acceptances.

# File lib/pione/lang/conditional-branch.rb, line 53
def validate(acceptances)
  when_contexts.each {|_expr, _context| _context.validate(acceptances)}
  else_context.validate(acceptances)
end