Class: CastOff::Compiler::SimpleIR::Stack

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/cast_off/compile/ir/simple_ir.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#bug, #dlog, #todo, #vlog

Constructor Details

#initialize(depth) ⇒ Stack

Returns a new instance of Stack.



15
16
17
# File 'lib/cast_off/compile/ir/simple_ir.rb', line 15

def initialize(depth)
  @depth = depth
end

Instance Attribute Details

#depthObject (readonly)

Returns the value of attribute depth.



13
14
15
# File 'lib/cast_off/compile/ir/simple_ir.rb', line 13

def depth
  @depth
end

Instance Method Details

#popObject



19
20
21
22
23
# File 'lib/cast_off/compile/ir/simple_ir.rb', line 19

def pop()
  @depth -= 1
  bug() if @depth < 0
  @depth
end

#pushObject



25
26
27
28
29
# File 'lib/cast_off/compile/ir/simple_ir.rb', line 25

def push()
  ret = @depth
  @depth += 1
  ret
end