Class: MilkTea::Types::Function
- Defined in:
- lib/milk_tea/core/types/types.rb
Instance Attribute Summary collapse
-
#external ⇒ Object
readonly
Returns the value of attribute external.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#receiver_editable ⇒ Object
readonly
Returns the value of attribute receiver_editable.
-
#receiver_type ⇒ Object
readonly
Returns the value of attribute receiver_type.
-
#return_type ⇒ Object
readonly
Returns the value of attribute return_type.
-
#variadic ⇒ Object
readonly
Returns the value of attribute variadic.
Instance Method Summary collapse
- #children ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(name, params:, return_type:, receiver_type: nil, receiver_editable: false, variadic: false, external: false) ⇒ Function
constructor
A new instance of Function.
- #to_s ⇒ Object
Methods inherited from Base
#accept, #bitwise?, #boolean?, #field_c_name, #float?, #integer?, #numeric?, #sendable?, #void?
Constructor Details
#initialize(name, params:, return_type:, receiver_type: nil, receiver_editable: false, variadic: false, external: false) ⇒ Function
Returns a new instance of Function.
1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 |
# File 'lib/milk_tea/core/types/types.rb', line 1323 def initialize(name, params:, return_type:, receiver_type: nil, receiver_editable: false, variadic: false, external: false) @name = name @params = params.freeze @return_type = return_type @receiver_type = receiver_type @receiver_editable = receiver_editable @variadic = variadic @external = external @hash = [self.class, @params, return_type, receiver_type, receiver_editable, variadic].hash freeze end |
Instance Attribute Details
#external ⇒ Object (readonly)
Returns the value of attribute external.
1321 1322 1323 |
# File 'lib/milk_tea/core/types/types.rb', line 1321 def external @external end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
1346 1347 1348 |
# File 'lib/milk_tea/core/types/types.rb', line 1346 def hash @hash end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
1321 1322 1323 |
# File 'lib/milk_tea/core/types/types.rb', line 1321 def name @name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
1321 1322 1323 |
# File 'lib/milk_tea/core/types/types.rb', line 1321 def params @params end |
#receiver_editable ⇒ Object (readonly)
Returns the value of attribute receiver_editable.
1321 1322 1323 |
# File 'lib/milk_tea/core/types/types.rb', line 1321 def receiver_editable @receiver_editable end |
#receiver_type ⇒ Object (readonly)
Returns the value of attribute receiver_type.
1321 1322 1323 |
# File 'lib/milk_tea/core/types/types.rb', line 1321 def receiver_type @receiver_type end |
#return_type ⇒ Object (readonly)
Returns the value of attribute return_type.
1321 1322 1323 |
# File 'lib/milk_tea/core/types/types.rb', line 1321 def return_type @return_type end |
#variadic ⇒ Object (readonly)
Returns the value of attribute variadic.
1321 1322 1323 |
# File 'lib/milk_tea/core/types/types.rb', line 1321 def variadic @variadic end |
Instance Method Details
#children ⇒ Object
1356 1357 1358 1359 1360 1361 |
# File 'lib/milk_tea/core/types/types.rb', line 1356 def children result = params.flat_map { |p| [p.type, p.boundary_type].compact } result << return_type result << receiver_type if receiver_type result end |
#eql?(other) ⇒ Boolean Also known as: ==
1335 1336 1337 1338 1339 1340 1341 1342 |
# File 'lib/milk_tea/core/types/types.rb', line 1335 def eql?(other) other.is_a?(Function) && other.params == params && other.return_type == return_type && other.receiver_type == receiver_type && other.receiver_editable == receiver_editable && other.variadic == variadic end |
#to_s ⇒ Object
1349 1350 1351 1352 1353 1354 |
# File 'lib/milk_tea/core/types/types.rb', line 1349 def to_s pieces = [] pieces << receiver_type.to_s if receiver_type pieces << name if name "fn #{pieces.join('.')}" end |