Class: Mirah::AST::Boolean
- Includes:
- Literal
- Defined in:
- lib/mirah/ast/literal.rb,
lib/mirah/compiler/literal.rb
Instance Attribute Summary
Attributes included from Literal
Attributes included from Typed
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #compile(compiler, expression) ⇒ Object
- #infer(typer, expression) ⇒ Object
-
#initialize(parent, line_number, literal) ⇒ Boolean
constructor
A new instance of Boolean.
Methods included from Literal
Methods inherited from Node
#<<, ===, #[], #[]=, #_dump, _load, #_set_parent, child, child_name, #child_nodes, #each, #empty?, #expr?, #inferred_type!, #initialize_copy, #insert, #inspect, #inspect_children, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #string_value, #temp, #to_s, #top_level?, #validate_child, #validate_children
Constructor Details
#initialize(parent, line_number, literal) ⇒ Boolean
Returns a new instance of Boolean.
146 147 148 149 |
# File 'lib/mirah/ast/literal.rb', line 146 def initialize(parent, line_number, literal) super(parent, line_number) @literal = literal end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/mirah/compiler/literal.rb', line 79 def compile(compiler, expression) if expression compiler.line(line_number) compiler.boolean(literal) end rescue Exception => ex raise Mirah::InternalCompilerError.wrap(ex, self) end |
#infer(typer, expression) ⇒ Object
151 152 153 154 155 |
# File 'lib/mirah/ast/literal.rb', line 151 def infer(typer, expression) return @inferred_type if resolved? resolved! @inferred_type ||= typer.boolean_type end |