class Ascode::Interpreter::Math
Public Class Methods
bigger_than(env)
click to toggle source
# File lib/ascode/interpreter/math.rb, line 38 def self.bigger_than(env) a = env.pop b = env.pop env.push a > b ? 1 : 0 end
change_sign(env)
click to toggle source
# File lib/ascode/interpreter/math.rb, line 69 def self.change_sign(env) env.push(-1 * env.pop) end
decrement(env)
click to toggle source
# File lib/ascode/interpreter/math.rb, line 33 def self.decrement(env) a = env.pop env.push a - 1 end
divide(env)
click to toggle source
# File lib/ascode/interpreter/math.rb, line 16 def self.divide(env) a = env.pop b = env.pop env.push a / b end
equal(env)
click to toggle source
# File lib/ascode/interpreter/math.rb, line 50 def self.equal(env) a = env.pop b = env.pop env.push a == b ? 1 : 0 end
even(env)
click to toggle source
# File lib/ascode/interpreter/math.rb, line 56 def self.even(env) env.push env.pop.even? ? 1 : 0 end
increment(env)
click to toggle source
# File lib/ascode/interpreter/math.rb, line 28 def self.increment(env) a = env.pop env.push a + 1 end
invert(env)
click to toggle source
# File lib/ascode/interpreter/math.rb, line 60 def self.invert(env) a = env.pop if a.zero? env.push 1 else env.push 0 end end
less_than(env)
click to toggle source
# File lib/ascode/interpreter/math.rb, line 44 def self.less_than(env) a = env.pop b = env.pop env.push a < b ? 1 : 0 end
minus(env)
click to toggle source
# File lib/ascode/interpreter/math.rb, line 10 def self.minus(env) a = env.pop b = env.pop env.push a - b end
multiply(env)
click to toggle source
# File lib/ascode/interpreter/math.rb, line 22 def self.multiply(env) a = env.pop b = env.pop env.push a * b end
plus(env)
click to toggle source
# File lib/ascode/interpreter/math.rb, line 4 def self.plus(env) a = env.pop b = env.pop env.push a + b end