Class: Ikra::TypeInference::SymbolTable::Variable

Inherits:
Object
  • Object
show all
Defined in:
lib/types/inference/symbol_table.rb

Overview

Represents a lexical or local variable. Variables have a type and can read and/or written, all of which is stored in this class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type: Types::UnionType.new, kind: :local) ⇒ Variable

Returns a new instance of Variable.



23
24
25
26
27
28
# File 'lib/types/inference/symbol_table.rb', line 23

def initialize(type: Types::UnionType.new, kind: :local)
    @type = type.dup
    @kind = kind
    @read = false
    @written = false
end

Instance Attribute Details

#kindObject (readonly)

Determines the kind of the variables: lexial or local



18
19
20
# File 'lib/types/inference/symbol_table.rb', line 18

def kind
  @kind
end

#readObject

Returns the value of attribute read.



20
21
22
# File 'lib/types/inference/symbol_table.rb', line 20

def read
  @read
end

#typeObject (readonly)

Returns the value of attribute type.



15
16
17
# File 'lib/types/inference/symbol_table.rb', line 15

def type
  @type
end

#writtenObject

Returns the value of attribute written.



21
22
23
# File 'lib/types/inference/symbol_table.rb', line 21

def written
  @written
end