Class: Stone::AST::ConstantDefinition
- Inherits:
-
Expression
- Object
- Stone::AST
- Expression
- Stone::AST::ConstantDefinition
- Defined in:
- lib/stone/ast/constant_definition.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#value_expression ⇒ Object
readonly
Returns the value of attribute value_expression.
Attributes inherited from Stone::AST
Instance Method Summary collapse
-
#initialize(identifier, value_expression) ⇒ ConstantDefinition
constructor
A new instance of ConstantDefinition.
- #to_llir(builder, mod, scope = Stone::Scope.top_level) ⇒ Object
- #type(_context = nil) ⇒ Object
Constructor Details
#initialize(identifier, value_expression) ⇒ ConstantDefinition
Returns a new instance of ConstantDefinition.
10 11 12 13 14 |
# File 'lib/stone/ast/constant_definition.rb', line 10 def initialize(identifier, value_expression) @identifier = identifier @value_expression = value_expression @name = :constant_definition end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
8 9 10 |
# File 'lib/stone/ast/constant_definition.rb', line 8 def identifier @identifier end |
#value_expression ⇒ Object (readonly)
Returns the value of attribute value_expression.
8 9 10 |
# File 'lib/stone/ast/constant_definition.rb', line 8 def value_expression @value_expression end |
Instance Method Details
#to_llir(builder, mod, scope = Stone::Scope.top_level) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/stone/ast/constant_definition.rb', line 16 def to_llir(builder, mod, scope = Stone::Scope.top_level) return register_record_type(mod, builder, scope) if value_expression.is_a?(Stone::AST::RecordDefinition) llvm_value = value_expression.to_llir(builder, mod, scope) return handle_record_definition(mod, llvm_value) if value_expression.is_a?(Stone::AST::RecordDefinition) return register_function_alias(mod, llvm_value, scope) if llvm_value.is_a?(LLVM::Function) handle_value_expression(mod, scope) create_global(mod, builder, llvm_value, scope) end |
#type(_context = nil) ⇒ Object
28 29 30 31 32 |
# File 'lib/stone/ast/constant_definition.rb', line 28 def type(_context = nil) # ConstantDefinition doesn't have a value itself, it defines a binding # Return nil to indicate this isn't an expression nil end |