Class: Duby::AST::Fixnum

Inherits:
Node show all
Includes:
Literal
Defined in:
lib/duby/compiler.rb,
lib/duby/ast/literal.rb

Direct Known Subclasses

JVM::Types::FixnumLiteralNode

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

#[], #each, #expr?, #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.



11
12
13
14
# File 'lib/duby/ast/literal.rb', line 11

def initialize(parent, line_number, literal)
  super(parent, line_number)
  @literal = literal
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/duby/ast/literal.rb', line 22

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

Returns:



26
27
28
# File 'lib/duby/ast/literal.rb', line 26

def eql?(other)
  self.class == other.class && @literal.eql?(other.literal)
end

#infer(typer) ⇒ Object



16
17
18
19
20
# File 'lib/duby/ast/literal.rb', line 16

def infer(typer)
  return @inferred_type if resolved?
  resolved!
  @inferred_type = typer.fixnum_type
end