Class: Rlang::Parser::CVar

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Log

included, logger, #logger, logger=

Constructor Details

#initialize(klass, name, value = 0, wtype = WType::DEFAULT) ⇒ CVar

Returns a new instance of CVar.



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

def initialize(klass, name, value=0, wtype=WType::DEFAULT)
  @klass = klass
  @name = name
  @wtype = wtype
  # Allocate and initialize the new cvar
  raise "Error: #{self.class} #{self.wasm_name} already created!" if DAta.exist? self.wasm_name.to_sym
  @data = DAta.new(self.wasm_name.to_sym, value, wtype) unless wtype.name == :Class
  logger.debug "creating #{self.class} #{self.class_name}::#{name} @ #{@address} with value #{value} / wtype #{wtype}"
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



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

def klass
  @klass
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#wtypeObject

Returns the value of attribute wtype.



16
17
18
# File 'lib/rlang/parser/cvar.rb', line 16

def wtype
  @wtype
end

Instance Method Details

#addressObject



32
33
34
# File 'lib/rlang/parser/cvar.rb', line 32

def address
  @data.address
end

#class_nameObject



28
29
30
# File 'lib/rlang/parser/cvar.rb', line 28

def class_name
  @klass.path_name
end

#valueObject



36
37
38
# File 'lib/rlang/parser/cvar.rb', line 36

def value
  @data.value
end

#wasm_nameObject



40
41
42
# File 'lib/rlang/parser/cvar.rb', line 40

def wasm_name
  "$#{self.class_name}::#{@name}"
end

#wasm_typeObject



44
45
46
# File 'lib/rlang/parser/cvar.rb', line 44

def wasm_type
  @wtype.wasm_type
end