Class: Stone::AST::FunctionCall
- Inherits:
-
Expression
- Object
- Stone::AST
- Expression
- Stone::AST::FunctionCall
- Defined in:
- lib/stone/ast/function_call.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#function_name ⇒ Object
readonly
Returns the value of attribute function_name.
Attributes inherited from Stone::AST
Instance Method Summary collapse
-
#initialize(function_name, arguments) ⇒ FunctionCall
constructor
A new instance of FunctionCall.
- #to_llir(builder, mod, scope = Stone::Scope.top_level) ⇒ Object
- #to_s ⇒ Object
- #type(context = nil) ⇒ Object
Constructor Details
#initialize(function_name, arguments) ⇒ FunctionCall
Returns a new instance of FunctionCall.
12 13 14 15 16 |
# File 'lib/stone/ast/function_call.rb', line 12 def initialize(function_name, arguments) @function_name = function_name @arguments = arguments @name = :function_call end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
10 11 12 |
# File 'lib/stone/ast/function_call.rb', line 10 def arguments @arguments end |
#function_name ⇒ Object (readonly)
Returns the value of attribute function_name.
10 11 12 |
# File 'lib/stone/ast/function_call.rb', line 10 def function_name @function_name end |
Instance Method Details
#to_llir(builder, mod, scope = Stone::Scope.top_level) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/stone/ast/function_call.rb', line 18 def to_llir(builder, mod, scope = Stone::Scope.top_level) # NULL comparisons with non-NULL values are always unequal (different types) return null_comparison_result if mixed_null_comparison? # TODO: Record equality should be delegated to the type system. # When the type system is refactored, equality should be polymorphic: # - Global `==` checks that both args are the same type # - If same type, delegate to type-specific comparison # - This special case should be removed return generate_record_equality(builder, mod, scope) if record_equality_comparison?(mod) # TODO: Record instantiation should not be special-cased here. # When the type system is refactored, record constructors should be # regular functions, and this check should be removed. return instantiate_record(builder, mod, scope) if mod.record_type?(function_name) # For chained comparisons, generate inline comparison logic return generate_chained_comparison(builder, mod, scope) if chained_comparison? # For chained boolean operations, generate inline logic return generate_chained_boolean(builder, mod, scope) if chained_boolean? # Regular function call generate_function_call(builder, mod, scope) end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/stone/ast/function_call.rb', line 43 def to_s "#{function_name}(#{arguments.join(', ')})" end |
#type(context = nil) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/stone/ast/function_call.rb', line 47 def type(context = nil) return Stone::Type::Bool if comparison_operator? || boolean_operator? return record_constructor_type if context&.record_type?(function_name) function_return_type end |