Class: Stone::TypeContext
- Inherits:
-
Object
- Object
- Stone::TypeContext
- Defined in:
- lib/stone/type_context.rb
Instance Attribute Summary collapse
-
#llvm_module ⇒ Object
readonly
Returns the value of attribute llvm_module.
Instance Method Summary collapse
- #bind(name, type) ⇒ Object
-
#initialize(llvm_module = nil) ⇒ TypeContext
constructor
A new instance of TypeContext.
- #lookup(name) ⇒ Object
- #record_definition(name) ⇒ Object
- #record_type?(name) ⇒ Boolean
- #with_llvm_module(mod) ⇒ Object
Constructor Details
#initialize(llvm_module = nil) ⇒ TypeContext
Returns a new instance of TypeContext.
6 7 8 9 |
# File 'lib/stone/type_context.rb', line 6 def initialize(llvm_module = nil) @llvm_module = llvm_module @bindings = {} end |
Instance Attribute Details
#llvm_module ⇒ Object (readonly)
Returns the value of attribute llvm_module.
4 5 6 |
# File 'lib/stone/type_context.rb', line 4 def llvm_module @llvm_module end |
Instance Method Details
#bind(name, type) ⇒ Object
11 12 13 |
# File 'lib/stone/type_context.rb', line 11 def bind(name, type) @bindings[name] = type end |
#lookup(name) ⇒ Object
15 16 17 |
# File 'lib/stone/type_context.rb', line 15 def lookup(name) @bindings[name] end |
#record_definition(name) ⇒ Object
31 32 33 34 35 |
# File 'lib/stone/type_context.rb', line 31 def record_definition(name) return nil unless @llvm_module @llvm_module.record_types&.[](name) end |
#record_type?(name) ⇒ Boolean
25 26 27 28 29 |
# File 'lib/stone/type_context.rb', line 25 def record_type?(name) return false unless @llvm_module @llvm_module.record_type?(name) end |
#with_llvm_module(mod) ⇒ Object
19 20 21 22 23 |
# File 'lib/stone/type_context.rb', line 19 def with_llvm_module(mod) new_context = self.class.new(mod) new_context.instance_variable_set(:@bindings, @bindings.dup) new_context end |