Class: Duby::AST::Float
- Includes:
- Literal
- Defined in:
- lib/duby/compiler.rb,
lib/duby/ast/literal.rb
Direct Known Subclasses
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) ⇒ Object
-
#initialize(parent, line_number, literal) ⇒ Float
constructor
A new instance of Float.
Methods included from Literal
Methods inherited from Node
#<<, ===, #[], #_set_parent, child, child_name, #each, #empty?, #expr?, #initialize_copy, #insert, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s
Constructor Details
#initialize(parent, line_number, literal) ⇒ Float
Returns a new instance of Float.
41 42 43 44 |
# File 'lib/duby/ast/literal.rb', line 41 def initialize(parent, line_number, literal) super(parent, line_number) @literal = literal end |
Instance Method Details
#compile(compiler, expression) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/duby/compiler.rb', line 45 def compile(compiler, expression) if expression compiler.line(line_number) compiler.float(literal) end end |
#infer(typer) ⇒ Object
46 47 48 49 50 |
# File 'lib/duby/ast/literal.rb', line 46 def infer(typer) return @inferred_type if resolved? resolved! @inferred_type = typer.float_type end |