Class: Mirah::AST::Null

Inherits:
Node
  • Object
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) ⇒ Null

Returns a new instance of Null.



161
162
163
# File 'lib/mirah/ast/literal.rb', line 161

def initialize(parent, line_number)
  super(parent, line_number)
end

Instance Method Details

#compile(compiler, expression) ⇒ Object



98
99
100
101
102
103
104
105
# File 'lib/mirah/compiler/literal.rb', line 98

def compile(compiler, expression)
  if expression
    compiler.line(line_number)
    compiler.null
  end
rescue Exception => ex
  raise Mirah::InternalCompilerError.wrap(ex, self)
end

#infer(typer, expression) ⇒ Object



165
166
167
168
169
# File 'lib/mirah/ast/literal.rb', line 165

def infer(typer, expression)
  return @inferred_type if resolved?
  resolved!
  @inferred_type ||= typer.null_type
end