Class: Stone::AST::Reference
- Inherits:
-
Expression
- Object
- Stone::AST
- Expression
- Stone::AST::Reference
- Defined in:
- lib/stone/ast/reference.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Attributes inherited from Stone::AST
Instance Method Summary collapse
-
#initialize(identifier, type: nil) ⇒ Reference
constructor
A new instance of Reference.
- #record_instance?(mod) ⇒ Boolean
- #to_llir(builder, mod, scope = Stone::Scope.top_level) ⇒ Object
- #to_s ⇒ Object
- #type(context = nil) ⇒ Object
Constructor Details
#initialize(identifier, type: nil) ⇒ Reference
11 12 13 14 15 |
# File 'lib/stone/ast/reference.rb', line 11 def initialize(identifier, type: nil) @identifier = identifier @type = type @name = :reference end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
9 10 11 |
# File 'lib/stone/ast/reference.rb', line 9 def identifier @identifier end |
Instance Method Details
#record_instance?(mod) ⇒ Boolean
38 39 40 |
# File 'lib/stone/ast/reference.rb', line 38 def record_instance?(mod) mod.record_instance?(identifier) end |
#to_llir(builder, mod, scope = Stone::Scope.top_level) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/stone/ast/reference.rb', line 42 def to_llir(builder, mod, scope = Stone::Scope.top_level) # Check lambda parameters first - they should shadow outer scope definitions lookup_parameter(builder, mod) || lookup_in_scope(scope) || lookup_global(builder, mod) || lookup_function(mod) || lookup_record_type(mod) || fail_with_reference_error end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/stone/ast/reference.rb', line 52 def to_s identifier end |
#type(context = nil) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/stone/ast/reference.rb', line 17 def type(context = nil) return @type if @type return nil unless context type_from_context(context) || type_from_module(context) end |