Class: Frame

Inherits:
Hash show all
Defined in:
lib/scope.rb

Instance Method Summary collapse

Instance Method Details

#add_return_type(type) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/scope.rb', line 14

def add_return_type(type)
    if not is_function_frame?
        raise "Return type allowed only for function frames"
    end

    if not type.is_union_type?
        raise "Expected union type"
    end

    @return_type ||= Ikra::Types::UnionType.new
    @return_type.expand(type)
end

#function_frame!Object



5
6
7
# File 'lib/scope.rb', line 5

def function_frame!
    @is_function_frame = true
end

#is_function_frame?Boolean



9
10
11
12
# File 'lib/scope.rb', line 9

def is_function_frame?
    @is_function_frame ||= false
    @is_function_frame
end

#return_typeObject



27
28
29
30
31
32
33
34
# File 'lib/scope.rb', line 27

def return_type
    if not is_function_frame?
        raise "Return type allowed only for function frames"
    end

    @return_type ||= Ikra::Types::UnionType.new
    @return_type
end

#variable_namesObject



36
37
38
# File 'lib/scope.rb', line 36

def variable_names
    keys
end