class Pione::Lang::IfBranch
IfBranch
is a class for if
branches.
Public Instance Methods
eval(env)
click to toggle source
Return suitable context in the environment.
# File lib/pione/lang/conditional-branch.rb, line 22 def eval(env) # evaluate the condition res = expr.eval!(env) # check type of the result unless res.is_a?(BooleanSequence) raise StructuralError.new(BooleanSequence, expr.pos) end # return true_context when it is true return true_context if res.value # or return else_context when the context exists return else_context if else_context # otherwise return empty context return ConditionalBranchContext.new end
eval!(env)
click to toggle source
# File lib/pione/lang/conditional-branch.rb, line 41 def eval!(env) eval(env).eval!(env) end
validate(acceptances)
click to toggle source
Validate inner contexts based on the list of acceptances.
# File lib/pione/lang/conditional-branch.rb, line 16 def validate(acceptances) true_context.validate(acceptances) else_context.validate(acceptances) end