Class: Dentaku::AST::Bitwise
- Defined in:
- lib/dentaku/ast/bitwise.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Node
Node::STATIC_CONTEXT, Node::STATIC_MODE_KEY
Instance Attribute Summary
Attributes inherited from Operation
Instance Method Summary collapse
Methods inherited from Operation
#accept, #dependencies, #display_operator, #initialize, max_param_count, min_param_count, #operator_spacing, right_associative?
Methods inherited from Node
arity, #dependencies, #name, precedence, #pure?, resolve_class, #type
Constructor Details
This class inherits a constructor from Dentaku::AST::Operation
Instance Method Details
#value(context = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dentaku/ast/bitwise.rb', line 6 def value(context = {}) left_value = left.value(context) right_value = right.value(context) left_value.public_send(operator, right_value) rescue NoMethodError raise Dentaku::ArgumentError.for(:incompatible_type, actual: left_value, expected: Integer), "#{self.class} requires integer operands, but got #{left_value.class}" rescue TypeError raise Dentaku::ArgumentError.for(:incompatible_type, actual: right_value, expected: Integer), "#{self.class} requires integer operands, but got #{right_value.class}" end |