Class: Emfrp::Alloc

Inherits:
Object
  • Object
show all
Defined in:
lib/emfrp/compile/c/alloc.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Alloc

Returns a new instance of Alloc.



176
177
178
# File 'lib/emfrp/compile/c/alloc.rb', line 176

def initialize(hash)
  @h = hash
end

Instance Attribute Details

#hObject (readonly)

Returns the value of attribute h.



175
176
177
# File 'lib/emfrp/compile/c/alloc.rb', line 175

def h
  @h
end

Class Method Details

.emptyObject



180
181
182
# File 'lib/emfrp/compile/c/alloc.rb', line 180

def self.empty
  self.new({})
end

.one(k) ⇒ Object



184
185
186
# File 'lib/emfrp/compile/c/alloc.rb', line 184

def self.one(k)
  self.new(k => 1)
end

Instance Method Details

#&(other) ⇒ Object



192
193
194
# File 'lib/emfrp/compile/c/alloc.rb', line 192

def &(other)
  Alloc.new self.h.merge(other.h){|k, v1, v2| v1 + v2}
end

#each(&block) ⇒ Object



196
197
198
# File 'lib/emfrp/compile/c/alloc.rb', line 196

def each(&block)
  @h.each(&block)
end

#|(other) ⇒ Object



188
189
190
# File 'lib/emfrp/compile/c/alloc.rb', line 188

def |(other)
  Alloc.new self.h.merge(other.h){|k, v1, v2| [v1, v2].max}
end