Module: Ikra::Types::RubyType

Included in:
Symbolic::ArrayCommand, ArrayType, ClassType, InterpreterOnlyType, PrimitiveType, StructType, UnionType, UnknownType
Defined in:
lib/types/types/ruby_type.rb

Overview

Defines the minimal interface for Ikra types. Instances of UnionType are expected in most cases.

Constant Summary collapse

@@next_class_id =
10

Instance Method Summary collapse

Instance Method Details

#class_idObject



47
48
49
50
51
52
53
54
# File 'lib/types/types/ruby_type.rb', line 47

def class_id
    if @class_id == nil
        @class_id = @@next_class_id
        @@next_class_id += 1
    end

    @class_id
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/types/types/ruby_type.rb', line 56

def eql?(other)
    return self == other
end

#hashObject



60
61
62
63
# File 'lib/types/types/ruby_type.rb', line 60

def hash
    # TODO: Implement
    return 0
end

#inspectObject



14
15
16
# File 'lib/types/types/ruby_type.rb', line 14

def inspect
    return to_s
end

#is_primitive?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/types/types/ruby_type.rb', line 26

def is_primitive?
    false
end

#is_union_type?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/types/types/ruby_type.rb', line 30

def is_union_type?
    false
end

#should_generate_self_arg?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/types/types/ruby_type.rb', line 34

def should_generate_self_arg?
    return true
end

#to_array_typeObject



38
39
40
41
# File 'lib/types/types/ruby_type.rb', line 38

def to_array_type
    # TODO: This should probably not return a union type by default
    return ArrayType.new(self).to_union_type
end

#to_c_typeObject

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/types/types/ruby_type.rb', line 22

def to_c_type
    raise NotImplementedError
end

#to_ruby_typeObject

Raises:

  • (NotImplementedError)


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

def to_ruby_type
    raise NotImplementedError
end

#to_strObject



10
11
12
# File 'lib/types/types/ruby_type.rb', line 10

def to_str
    return to_s
end

#to_union_typeObject



43
44
45
# File 'lib/types/types/ruby_type.rb', line 43

def to_union_type
    return UnionType.new(self)
end