enum StackMachine::Operation

Overview

Enum for every binary mathematical operaiton.

TODO Figure out a scheme for unary operations.

Defined in:

stackmachine/operations.cr

Enum Members

Add = 0
Sub = 1
Mul = 2
Div = 3

Instance Method Summary

Instance Method Detail

def add? #

[View source]
def call(l : Float64, r : Float64) : Float64 #

This method performs the mathematical operation represented by the enum. It will always return an Int32 and truncate on division.

StackMachine::Operation::Add.call(1, 2) # => 3
StackMachine::Operation::Div.call(1, 2) # => 0

[View source]
def div? #

[View source]
def mul? #

[View source]
def sub? #

[View source]