Class: Nodewrap::ByteDecoder::Expression::Infix
- Inherits:
-
Nodewrap::ByteDecoder::Expression
- Object
- Nodewrap::ByteDecoder::Expression
- Nodewrap::ByteDecoder::Expression::Infix
- Defined in:
- lib/bytedecoder.rb
Instance Attribute Summary collapse
-
#lhs ⇒ Object
readonly
Returns the value of attribute lhs.
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#rhs ⇒ Object
readonly
Returns the value of attribute rhs.
Attributes inherited from Nodewrap::ByteDecoder::Expression
Instance Method Summary collapse
-
#initialize(pc, op, lhs, rhs) ⇒ Infix
constructor
A new instance of Infix.
- #precedence ⇒ Object
- #to_s ⇒ Object
Methods inherited from Nodewrap::ByteDecoder::Expression
Constructor Details
#initialize(pc, op, lhs, rhs) ⇒ Infix
Returns a new instance of Infix.
100 101 102 103 104 105 |
# File 'lib/bytedecoder.rb', line 100 def initialize(pc, op, lhs, rhs) super(pc) @op = op @lhs = lhs @rhs = rhs end |
Instance Attribute Details
#lhs ⇒ Object (readonly)
Returns the value of attribute lhs.
97 98 99 |
# File 'lib/bytedecoder.rb', line 97 def lhs @lhs end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
96 97 98 |
# File 'lib/bytedecoder.rb', line 96 def op @op end |
#rhs ⇒ Object (readonly)
Returns the value of attribute rhs.
98 99 100 |
# File 'lib/bytedecoder.rb', line 98 def rhs @rhs end |
Instance Method Details
#precedence ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/bytedecoder.rb', line 111 def precedence case @op when :*, :/, :% return 2 when '+'.intern, '-'.intern return 3 when :<<, :>> return 4 when :>, :>=, :<, :<=, :==, :=== return 5 else raise ArgumentError, "Unknown op: #{@op}" end end |
#to_s ⇒ Object
107 108 109 |
# File 'lib/bytedecoder.rb', line 107 def to_s return "#{fmt(@lhs)} #{@op} #{fmt(@rhs)}" end |