Class: Mirah::AST::Float
- 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) ⇒ Float
constructor
A new instance of Float.
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) ⇒ Float
Returns a new instance of Float.
56 57 58 59 |
# File 'lib/mirah/ast/literal.rb', line 56 def initialize(parent, line_number, literal) super(parent, line_number) @literal = literal end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/mirah/compiler/literal.rb', line 68 def compile(compiler, expression) if expression compiler.line(line_number) compiler.float(inferred_type, literal) end rescue Exception => ex raise Mirah::InternalCompilerError.wrap(ex, self) end |
#infer(typer, expression) ⇒ Object
61 62 63 |
# File 'lib/mirah/ast/literal.rb', line 61 def infer(typer, expression) resolve_if(typer) {@inferred_type = typer.float_type(@literal)} end |