Class: Duby::AST::Null

Inherits:
Node 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

#[], #each, #expr?, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s

Constructor Details

#initialize(parent, line_number) ⇒ Null

Returns a new instance of Null.



83
84
85
# File 'lib/duby/ast/literal.rb', line 83

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

Instance Method Details

#compile(compiler, expression) ⇒ Object



211
212
213
214
215
216
# File 'lib/duby/compiler.rb', line 211

def compile(compiler, expression)
  if expression
    compiler.line(line_number)
    compiler.null
  end
end

#infer(typer) ⇒ Object



87
88
89
90
91
# File 'lib/duby/ast/literal.rb', line 87

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