Class: Mirah::AST::Fixnum
- Inherits:
-
Node
- Object
- Node
- Mirah::AST::Fixnum
show all
- Includes:
- Literal
- Defined in:
- lib/mirah/ast/literal.rb,
lib/mirah/compiler/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
#string_value, #to_s
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) ⇒ Fixnum
Returns a new instance of Fixnum.
35
36
37
38
|
# File 'lib/mirah/ast/literal.rb', line 35
def initialize(parent, line_number, literal)
super(parent, line_number)
@literal = literal
end
|
Instance Method Details
#==(other) ⇒ Object
44
45
46
|
# File 'lib/mirah/ast/literal.rb', line 44
def ==(other)
@literal == other.literal
end
|
#compile(compiler, expression) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/mirah/compiler/literal.rb', line 19
def compile(compiler, expression)
if expression
compiler.line(line_number)
compiler.fixnum(inferred_type, literal)
end
rescue Exception => ex
raise Mirah::InternalCompilerError.wrap(ex, self)
end
|
#eql?(other) ⇒ Boolean
48
49
50
|
# File 'lib/mirah/ast/literal.rb', line 48
def eql?(other)
self.class == other.class && @literal.eql?(other.literal)
end
|
#infer(typer, expression) ⇒ Object
40
41
42
|
# File 'lib/mirah/ast/literal.rb', line 40
def infer(typer, expression)
resolve_if(typer) {@inferred_type = typer.fixnum_type(@literal)}
end
|