Class: TypedRb::Model::TmVar

Inherits:
Expr show all
Defined in:
lib/typed/model/tm_var.rb

Overview

variable

Instance Attribute Summary collapse

Attributes inherited from Expr

#col, #line, #node, #type

Instance Method Summary collapse

Constructor Details

#initialize(val, node) ⇒ TmVar

Returns a new instance of TmVar.



10
11
12
13
# File 'lib/typed/model/tm_var.rb', line 10

def initialize(val, node)
  super(node)
  @val = val.to_s
end

Instance Attribute Details

#valObject

Returns the value of attribute val.



8
9
10
# File 'lib/typed/model/tm_var.rb', line 8

def val
  @val
end

Instance Method Details

#check_type(context) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/typed/model/tm_var.rb', line 19

def check_type(context)
  type = context.get_type_for(@val)
  if type.nil?
    fail TypeCheckError.new("Type error checking local var #{@val}: Cannot find binding local var in the typing context", node)
  end
  type
end

#to_sObject



15
16
17
# File 'lib/typed/model/tm_var.rb', line 15

def to_s
  "#{GenSym.resolve(@val)}"
end