Class: Duby::AST::Fixnum
- Inherits:
-
Node
- Object
- Node
- Duby::AST::Fixnum
show all
- Includes:
- Literal
- Defined in:
- lib/duby/compiler.rb,
lib/duby/ast/literal.rb
Instance Attribute Summary
Attributes included from Literal
#literal
Attributes included from Typed
#type
Attributes inherited from Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary
collapse
Methods included from Literal
#to_s
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) ⇒ Fixnum
Returns a new instance of Fixnum.
18
19
20
21
|
# File 'lib/duby/ast/literal.rb', line 18
def initialize(parent, line_number, literal)
super(parent, line_number)
@literal = literal
end
|
Instance Method Details
#==(other) ⇒ Object
29
30
31
|
# File 'lib/duby/ast/literal.rb', line 29
def ==(other)
@literal == other.literal
end
|
#compile(compiler, expression) ⇒ Object
6
7
8
9
10
11
|
# File 'lib/duby/compiler.rb', line 6
def compile(compiler, expression)
if expression
compiler.line(line_number)
compiler.fixnum(literal)
end
end
|
#eql?(other) ⇒ Boolean
33
34
35
|
# File 'lib/duby/ast/literal.rb', line 33
def eql?(other)
self.class == other.class && @literal.eql?(other.literal)
end
|
#infer(typer) ⇒ Object
23
24
25
26
27
|
# File 'lib/duby/ast/literal.rb', line 23
def infer(typer)
return @inferred_type if resolved?
resolved!
@inferred_type = typer.fixnum_type
end
|