Class: Yadriggy::LocalVarType

Inherits:
OptionalRole show all
Defined in:
lib/yadriggy/type.rb

Overview

Type of the value of a local variable.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OptionalRole

#==, #supertype

Methods inherited from Type

#!=, #<=, #copy, #eql?, error_found!, #exact_type, #has_role?, #name, role, #supertype

Constructor Details

#initialize(type, definition) ⇒ LocalVarType

Returns a new instance of LocalVarType.

Parameters:

  • type (Type)

    a Type object that this role is added to.

  • definition (ASTnode|nil)

    the AST node of the local variable. nil if an initial value is not set.



749
750
751
752
# File 'lib/yadriggy/type.rb', line 749

def initialize(type, definition)
  super(type)
  @definition = definition
end

Instance Attribute Details

#definitionASTnode|Undef|nil

Returns the AST node where the variable appears for the first time, in other words, where the variable's type is defined. Undef if a value is assigned to the variable more than once. nil if an initial value has not been assigned to the variable yet.

Returns:

  • (ASTnode|Undef|nil)

    the AST node where the variable appears for the first time, in other words, where the variable's type is defined. Undef if a value is assigned to the variable more than once. nil if an initial value has not been assigned to the variable yet.



744
745
746
# File 'lib/yadriggy/type.rb', line 744

def definition
  @definition
end