Class: Gisele::VM::Prog

Inherits:
Object
  • Object
show all
Defined in:
lib/gisele/vm/prog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Prog

Returns a new instance of Prog.



12
13
14
15
16
17
18
19
20
# File 'lib/gisele/vm/prog.rb', line 12

def initialize(attrs = {})
  @puid     = attrs[:puid]     || nil
  @parent   = attrs[:parent]   || @puid
  @root     = attrs[:root]     || @puid
  @pc       = attrs[:pc]       || :main
  @waitfor  = attrs[:waitfor]  || :none
  @waitlist = attrs[:waitlist] || {}
  @input    = attrs[:input]    || []
end

Instance Attribute Details

#inputObject

Returns the value of attribute input.



10
11
12
# File 'lib/gisele/vm/prog.rb', line 10

def input
  @input
end

#parentObject

Returns the value of attribute parent.



5
6
7
# File 'lib/gisele/vm/prog.rb', line 5

def parent
  @parent
end

#pcObject

Returns the value of attribute pc.



7
8
9
# File 'lib/gisele/vm/prog.rb', line 7

def pc
  @pc
end

#puidObject

Returns the value of attribute puid.



4
5
6
# File 'lib/gisele/vm/prog.rb', line 4

def puid
  @puid
end

#rootObject

Returns the value of attribute root.



6
7
8
# File 'lib/gisele/vm/prog.rb', line 6

def root
  @root
end

#waitforObject

Returns the value of attribute waitfor.



8
9
10
# File 'lib/gisele/vm/prog.rb', line 8

def waitfor
  @waitfor
end

#waitlistObject

Returns the value of attribute waitlist.



9
10
11
# File 'lib/gisele/vm/prog.rb', line 9

def waitlist
  @waitlist
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



52
53
54
# File 'lib/gisele/vm/prog.rb', line 52

def ==(other)
  other.is_a?(Prog) and (other.to_hash == to_hash)
end

#dupObject



45
46
47
48
49
50
# File 'lib/gisele/vm/prog.rb', line 45

def dup
  super.tap do |c|
    c.waitlist = waitlist.dup
    c.input    = input.dup
  end
end

#to_hash(keys = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gisele/vm/prog.rb', line 27

def to_hash(keys = nil)
  if keys
    h = {}
    keys.each do |k|
      h[k] = instance_variable_get(:"@#{k}")
    end
    h
  else
    { :puid     => puid,
      :parent   => parent,
      :root     => root,
      :pc       => pc,
      :waitfor  => waitfor,
      :waitlist => waitlist,
      :input    => input }
  end
end

#to_sObject



57
58
59
# File 'lib/gisele/vm/prog.rb', line 57

def to_s
  "Prog(#{puid.inspect})"
end