Class: SubNode
- Inherits:
-
BinaryNode
- Object
- BinaryNode
- SubNode
- Defined in:
- lib/ast.rb
Instance Attribute Summary
Attributes inherited from BinaryNode
Instance Method Summary collapse
- #evaluate ⇒ Object
- #ewe ⇒ Object
-
#initialize(left, right) ⇒ SubNode
constructor
A new instance of SubNode.
Constructor Details
#initialize(left, right) ⇒ SubNode
Returns a new instance of SubNode.
43 44 45 |
# File 'lib/ast.rb', line 43 def initialize(left, right) super(left,right) end |
Instance Method Details
#evaluate ⇒ Object
47 48 49 |
# File 'lib/ast.rb', line 47 def evaluate() return @left.evaluate() - @right.evaluate() end |
#ewe ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ast.rb', line 51 def ewe() iniciaSubN = " sp := sp + tres \n" medioSubN = "\n sp := sp - tres \n tmp := M[sp + 3] \n" medioSubN+=" M[sp + 1] := tmp \n sp := sp + tres \n" finSubN ="\n sp := sp - tres \n tmp := M[sp + 3] \n" finSubN+=" M[sp + 2] := tmp \n tmp := M[sp + 1] \n" finSubN+=" tmp2 := M[sp + 2] \n tmp := tmp - tmp2 \n" finSubN+=" M[sp + 0] := tmp \n" sub = iniciaSubN + @left.ewe() + medioSubN + @right.ewe() + finSubN return sub end |