Class: WAG::Memory

Inherits:
Object
  • Object
show all
Includes:
Encodable
Defined in:
lib/wag/memory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Encodable

#to_wasm, #to_wat

Constructor Details

#initialize(*args) ⇒ Memory

Returns a new instance of Memory.



9
10
11
12
13
# File 'lib/wag/memory.rb', line 9

def initialize(*args)
  @label = WAG::Label.from(args.shift) if args.first.is_a?(Symbol)

  (@number, @min, @max) = args
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



7
8
9
# File 'lib/wag/memory.rb', line 7

def label
  @label
end

#maxObject (readonly)

Returns the value of attribute max.



7
8
9
# File 'lib/wag/memory.rb', line 7

def max
  @max
end

#minObject (readonly)

Returns the value of attribute min.



7
8
9
# File 'lib/wag/memory.rb', line 7

def min
  @min
end

#numberObject (readonly)

Returns the value of attribute number.



7
8
9
# File 'lib/wag/memory.rb', line 7

def number
  @number
end

Instance Method Details

#to_sexprObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/wag/memory.rb', line 15

def to_sexpr
  [:memory].tap do |expr|
    expr.push(label.to_sexpr) if label
    expr.push(number)
    if min
      expr.push(min)
      expr.push(max) if max
    end
  end
end