Class: Stone::AST::BooleanLiteral
- Inherits:
-
Expression
- Object
- Stone::AST
- Expression
- Stone::AST::BooleanLiteral
- Defined in:
- lib/stone/ast/boolean_literal.rb
Constant Summary collapse
- TRUE =
1- FALSE =
0
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Stone::AST
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value) ⇒ BooleanLiteral
constructor
A new instance of BooleanLiteral.
- #to_llir(_builder, _mod, _scope = Stone::Scope.top_level) ⇒ Object
- #type(_context = nil) ⇒ Object
Constructor Details
#initialize(value) ⇒ BooleanLiteral
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/stone/ast/boolean_literal.rb', line 21 def initialize(value) @name = :boolean_literal case value when "TRUE" @value = TRUE when "FALSE" @value = FALSE else fail "expected TRUE or FALSE" end end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
19 20 21 |
# File 'lib/stone/ast/boolean_literal.rb', line 19 def value @value end |
Class Method Details
.parse(text, location) ⇒ Object
13 14 15 16 17 |
# File 'lib/stone/ast/boolean_literal.rb', line 13 def self.parse(text, location) new(text) rescue ex raise Stone::Error(ex., location) # TODO: Make a more specific error? end |
Instance Method Details
#to_llir(_builder, _mod, _scope = Stone::Scope.top_level) ⇒ Object
33 34 35 |
# File 'lib/stone/ast/boolean_literal.rb', line 33 def to_llir(_builder, _mod, _scope = Stone::Scope.top_level) @value == TRUE ? LLVM::TRUE : LLVM::FALSE end |
#type(_context = nil) ⇒ Object
37 38 39 |
# File 'lib/stone/ast/boolean_literal.rb', line 37 def type(_context = nil) Stone::Type::Bool end |