Class: ModNode
- Inherits:
-
BinaryNode
- Object
- BinaryNode
- ModNode
- Defined in:
- lib/ast.rb
Instance Attribute Summary
Attributes inherited from BinaryNode
Instance Method Summary collapse
- #evaluate ⇒ Object
- #ewe ⇒ Object
-
#initialize(lef, right) ⇒ ModNode
constructor
A new instance of ModNode.
Constructor Details
#initialize(lef, right) ⇒ ModNode
Returns a new instance of ModNode.
108 109 110 |
# File 'lib/ast.rb', line 108 def initialize(lef, right) super(left, right) end |
Instance Method Details
#evaluate ⇒ Object
111 112 113 |
# File 'lib/ast.rb', line 111 def evaluate() return @left.evaluate() % @right.evaluate() end |
#ewe ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/ast.rb', line 115 def ewe() iniciaModN = " sp := sp + tres \n" medioModN = "\n sp := sp - tres \n tmp := M[sp + 3] \n" medioModN+=" M[sp + 1] := tmp \n sp := sp + tres \n"; finModN = "\n sp := sp - tres \n tmp := M[sp + 3] \n" finModN+=" M[sp + 2] := tmp \n tmp := M[sp + 1] \n" finModN+=" tmp2 := M[sp + 2] \n tmp := tmp % tmp2 \n" finModN+=" M[sp + 0] := tmp \n" mod = iniciaModN + @left.ewe() +medioModN + @right.ewe() + finModN return mod end |