Class: Rlang::Parser::IVar

Inherits:
Object show all
Includes:
Log
Defined in:
lib/rlang/parser/ivar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Log

included, logger, #logger, logger=

Constructor Details

#initialize(klass, name, wtype = WType::DEFAULT) ⇒ IVar

Returns a new instance of IVar.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rlang/parser/ivar.rb', line 17

def initialize(klass, name, wtype=WType::DEFAULT)
  @klass = klass
  @name = name
  @wtype = wtype
  # this is the offset of the instance variable
  # in memory in the order they are declared
  # It is computed at the end of a class
  # definition
  @offset = nil
  logger.debug "Instance variable #{name} created"
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



14
15
16
# File 'lib/rlang/parser/ivar.rb', line 14

def klass
  @klass
end

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/rlang/parser/ivar.rb', line 14

def name
  @name
end

#offsetObject

Returns the value of attribute offset.



15
16
17
# File 'lib/rlang/parser/ivar.rb', line 15

def offset
  @offset
end

#wtypeObject

Returns the value of attribute wtype.



15
16
17
# File 'lib/rlang/parser/ivar.rb', line 15

def wtype
  @wtype
end

Instance Method Details

#sizeObject



29
30
31
# File 'lib/rlang/parser/ivar.rb', line 29

def size
  @wtype.size
end

#wasm_nameObject



33
34
35
# File 'lib/rlang/parser/ivar.rb', line 33

def wasm_name
  "$#{@name}"
end

#wasm_typeObject



37
38
39
# File 'lib/rlang/parser/ivar.rb', line 37

def wasm_type
  @wtype.wasm_type
end