Class: MilkTea::Lowerer::ModuleContext

Inherits:
Object
  • Object
show all
Defined in:
lib/milk_tea/core/lowering/lowering_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeModuleContext

Returns a new instance of ModuleContext.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 16

def initialize
  @imports = {}
  @types = {}
  @values = {}
  @functions = {}
  @interfaces = {}
  @struct_types = {}
  @union_types = {}
  @opaque_types = {}
  @methods = {}
  @attributes = {}
  @attribute_applications = {}
  @implemented_interfaces = {}
  @current_type_substitutions = nil
  @resolved_expr_types = {}
  @resolved_call_kinds = {}
  @const_values = {}
end

Instance Attribute Details

#analysisObject

Returns the value of attribute analysis.



6
7
8
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 6

def analysis
  @analysis
end

#astObject

Returns the value of attribute ast.



7
8
9
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 7

def ast
  @ast
end

#attribute_applicationsObject

Returns the value of attribute attribute_applications.



9
10
11
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 9

def attribute_applications
  @attribute_applications
end

#attributesObject

Returns the value of attribute attributes.



9
10
11
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 9

def attributes
  @attributes
end

#const_valuesObject

Returns the value of attribute const_values.



14
15
16
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 14

def const_values
  @const_values
end

#current_analysis_pathObject

Returns the value of attribute current_analysis_path.



6
7
8
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 6

def current_analysis_path
  @current_analysis_path
end

#current_type_substitutionsObject

Returns the value of attribute current_type_substitutions.



11
12
13
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 11

def current_type_substitutions
  @current_type_substitutions
end

#directivesObject

Returns the value of attribute directives.



7
8
9
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 7

def directives
  @directives
end

#functionsObject

Returns the value of attribute functions.



8
9
10
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 8

def functions
  @functions
end

#implemented_interfacesObject

Returns the value of attribute implemented_interfaces.



9
10
11
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 9

def implemented_interfaces
  @implemented_interfaces
end

#importsObject

Returns the value of attribute imports.



8
9
10
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 8

def imports
  @imports
end

#interfacesObject

Returns the value of attribute interfaces.



8
9
10
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 8

def interfaces
  @interfaces
end

#methodsObject

Returns the value of attribute methods.



9
10
11
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 9

def methods
  @methods
end

#module_kindObject

Returns the value of attribute module_kind.



7
8
9
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 7

def module_kind
  @module_kind
end

#module_nameObject

Returns the value of attribute module_name.



7
8
9
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 7

def module_name
  @module_name
end

#module_prefixObject

Returns the value of attribute module_prefix.



7
8
9
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 7

def module_prefix
  @module_prefix
end

#opaque_typesObject

Returns the value of attribute opaque_types.



10
11
12
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 10

def opaque_types
  @opaque_types
end

#resolved_call_kindsObject

Returns the value of attribute resolved_call_kinds.



13
14
15
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 13

def resolved_call_kinds
  @resolved_call_kinds
end

#resolved_expr_typesObject

Returns the value of attribute resolved_expr_types.



12
13
14
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 12

def resolved_expr_types
  @resolved_expr_types
end

#struct_typesObject

Returns the value of attribute struct_types.



10
11
12
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 10

def struct_types
  @struct_types
end

#typesObject

Returns the value of attribute types.



8
9
10
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 8

def types
  @types
end

#union_typesObject

Returns the value of attribute union_types.



10
11
12
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 10

def union_types
  @union_types
end

#valuesObject

Returns the value of attribute values.



8
9
10
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 8

def values
  @values
end

Instance Method Details

#install(analysis, module_roots: nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 35

def install(analysis, module_roots: nil)
  @analysis = analysis
  @ast = analysis.ast
  @module_name = analysis.module_name
  @module_kind = analysis.module_kind
  @imports = analysis.imports
  @types = analysis.types
  @values = analysis.values
  @functions = analysis.functions
  @interfaces = analysis.interfaces
  @methods = analysis.methods
  @attributes = analysis.attributes
  @attribute_applications = analysis.attribute_applications
  @implemented_interfaces = analysis.implemented_interfaces
  @directives = analysis.directives
  @resolved_expr_types = analysis.resolved_expr_types
  @resolved_call_kinds = analysis.resolved_call_kinds
  @const_values = analysis.const_values
  @struct_types = {}
  @union_types = {}
  @opaque_types = {}
end

#restore(saved) ⇒ Object



75
76
77
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 75

def restore(saved)
  saved.each { |k, v| send(:"#{k}=", v) }
end

#saveObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/milk_tea/core/lowering/lowering_context.rb', line 58

def save
  {
    analysis: @analysis, current_analysis_path: @current_analysis_path,
    ast: @ast, module_name: @module_name, module_prefix: @module_prefix,
    module_kind: @module_kind, directives: @directives,
    imports: @imports, types: @types, values: @values, functions: @functions,
    interfaces: @interfaces, methods: @methods, attributes: @attributes,
    attribute_applications: @attribute_applications,
    implemented_interfaces: @implemented_interfaces,
    struct_types: @struct_types, union_types: @union_types,
    opaque_types: @opaque_types, current_type_substitutions: @current_type_substitutions,
    resolved_expr_types: @resolved_expr_types,
    resolved_call_kinds: @resolved_call_kinds,
    const_values: @const_values,
  }
end