Class: Stone::AST::TypeOfExpression
- Inherits:
-
Expression
- Object
- Stone::AST
- Expression
- Stone::AST::TypeOfExpression
- Defined in:
- lib/stone/ast/type_of_expression.rb
Instance Attribute Summary collapse
-
#inner_expression ⇒ Object
readonly
Returns the value of attribute inner_expression.
Attributes inherited from Stone::AST
Instance Method Summary collapse
-
#initialize(inner_expression) ⇒ TypeOfExpression
constructor
A new instance of TypeOfExpression.
- #to_llir(builder, mod, scope = Stone::Scope.top_level) ⇒ Object
- #to_s ⇒ Object
- #type(_context = nil) ⇒ Object
Constructor Details
#initialize(inner_expression) ⇒ TypeOfExpression
12 13 14 15 |
# File 'lib/stone/ast/type_of_expression.rb', line 12 def initialize(inner_expression) @inner_expression = inner_expression @name = :type_of_expression end |
Instance Attribute Details
#inner_expression ⇒ Object (readonly)
Returns the value of attribute inner_expression.
10 11 12 |
# File 'lib/stone/ast/type_of_expression.rb', line 10 def inner_expression @inner_expression end |
Instance Method Details
#to_llir(builder, mod, scope = Stone::Scope.top_level) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/stone/ast/type_of_expression.rb', line 21 def to_llir(builder, mod, scope = Stone::Scope.top_level) # Union field access: extract type tag at runtime return @inner_expression.extract_union_type_tag(builder, mod, scope) if union_field_access?(mod) # Default: return compile-time type constant context = Stone::TypeContext.new(mod) result_type = @inner_expression.type(context) Stone::RTTI.type_constant_for(mod, result_type) end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/stone/ast/type_of_expression.rb', line 31 def to_s "Type.of(#{@inner_expression})" end |
#type(_context = nil) ⇒ Object
17 18 19 |
# File 'lib/stone/ast/type_of_expression.rb', line 17 def type(_context = nil) Stone::Type::Type end |