Class: MilkTea::ModuleBinding

Inherits:
Data
  • Object
show all
Defined in:
lib/milk_tea/core/bindings/module_binding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attribute_applicationsObject (readonly)

Returns the value of attribute attribute_applications

Returns:

  • (Object)

    the current value of attribute_applications



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def attribute_applications
  @attribute_applications
end

#attributesObject (readonly)

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def attributes
  @attributes
end

#functionsObject (readonly)

Returns the value of attribute functions

Returns:

  • (Object)

    the current value of functions



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def functions
  @functions
end

#implemented_interfacesObject (readonly)

Returns the value of attribute implemented_interfaces

Returns:

  • (Object)

    the current value of implemented_interfaces



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def implemented_interfaces
  @implemented_interfaces
end

#importsObject (readonly)

Returns the value of attribute imports

Returns:

  • (Object)

    the current value of imports



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def imports
  @imports
end

#interfacesObject (readonly)

Returns the value of attribute interfaces

Returns:

  • (Object)

    the current value of interfaces



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def interfaces
  @interfaces
end

#methodsObject (readonly)

Returns the value of attribute methods

Returns:

  • (Object)

    the current value of methods



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def methods
  @methods
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def name
  @name
end

#private_attributesObject (readonly)

Returns the value of attribute private_attributes

Returns:

  • (Object)

    the current value of private_attributes



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def private_attributes
  @private_attributes
end

#private_functionsObject (readonly)

Returns the value of attribute private_functions

Returns:

  • (Object)

    the current value of private_functions



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def private_functions
  @private_functions
end

#private_implemented_interfacesObject (readonly)

Returns the value of attribute private_implemented_interfaces

Returns:

  • (Object)

    the current value of private_implemented_interfaces



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def private_implemented_interfaces
  @private_implemented_interfaces
end

#private_interfacesObject (readonly)

Returns the value of attribute private_interfaces

Returns:

  • (Object)

    the current value of private_interfaces



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def private_interfaces
  @private_interfaces
end

#private_methodsObject (readonly)

Returns the value of attribute private_methods

Returns:

  • (Object)

    the current value of private_methods



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def private_methods
  @private_methods
end

#private_typesObject (readonly)

Returns the value of attribute private_types

Returns:

  • (Object)

    the current value of private_types



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def private_types
  @private_types
end

#private_valuesObject (readonly)

Returns the value of attribute private_values

Returns:

  • (Object)

    the current value of private_values



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def private_values
  @private_values
end

#type_declarationsObject (readonly)

Returns the value of attribute type_declarations

Returns:

  • (Object)

    the current value of type_declarations



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def type_declarations
  @type_declarations
end

#typesObject (readonly)

Returns the value of attribute types

Returns:

  • (Object)

    the current value of types



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def types
  @types
end

#valuesObject (readonly)

Returns the value of attribute values

Returns:

  • (Object)

    the current value of values



4
5
6
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 4

def values
  @values
end

Instance Method Details

#private_attribute?(name) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 13

def private_attribute?(name)
  private_attributes.key?(name)
end

#private_function?(name) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 21

def private_function?(name)
  private_functions.key?(name)
end

#private_interface?(name) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 9

def private_interface?(name)
  private_interfaces.key?(name)
end

#private_method?(receiver_type, name) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
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/bindings/module_binding.rb', line 25

def private_method?(receiver_type, name)
  return true if private_methods.fetch(receiver_type, {}).key?(name)

  if receiver_type.is_a?(Types::GenericInstance)
    dispatch_receiver_type = Types::Registry.generic_instance(
      receiver_type.name,
      receiver_type.arguments.each_with_index.map do |argument, index|
        argument.is_a?(Types::LiteralTypeArg) ? argument : Types::TypeVar.new("__receiver_arg#{index}")
      end,
    )
    return true if dispatch_receiver_type != receiver_type && private_methods.fetch(dispatch_receiver_type, {}).key?(name)
  end

  if receiver_type.is_a?(Types::Nullable)
    dispatch_base_type = receiver_type.base
    if dispatch_base_type.is_a?(Types::StructInstance)
      dispatch_base_type = dispatch_base_type.definition
    elsif dispatch_base_type.is_a?(Types::GenericInstance)
      dispatch_base_type = Types::Registry.generic_instance(
        dispatch_base_type.name,
        dispatch_base_type.arguments.each_with_index.map do |argument, index|
          argument.is_a?(Types::LiteralTypeArg) ? argument : Types::TypeVar.new("__receiver_arg#{index}")
        end,
      )
    end

    dispatch_receiver_type = Types::Registry.nullable(dispatch_base_type)
    return true if dispatch_receiver_type != receiver_type && private_methods.fetch(dispatch_receiver_type, {}).key?(name)
  end

  receiver_type.is_a?(Types::StructInstance) && private_methods.fetch(receiver_type.definition, {}).key?(name)
end

#private_type?(name) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 5

def private_type?(name)
  private_types.key?(name)
end

#private_value?(name) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/milk_tea/core/bindings/module_binding.rb', line 17

def private_value?(name)
  private_values.key?(name)
end