Sha256: d03e0bb5630602d69a7042879d5b173605884af52e4cb676b699199e298bf5bc

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

module Duby::AST
  class Array < Node
    def initialize(parent, line_number, &block)
      super(parent, line_number, &block)
    end
  end
  
  class Fixnum < Node
    include Literal
    
    def initialize(parent, line_number, literal)
      super(parent, line_number)
      @literal = literal
    end
    
    def infer(typer)
      return @inferred_type if resolved?
      resolved!
      @inferred_type = typer.fixnum_type
    end
    
    def ==(other)
      @literal == other.literal
    end
    
    def eql?(other)
      self.class == other.class && @literal.eql?(other.literal)
    end
  end
  
  class Float < Node
    include Literal
    
    def initialize(parent, line_number, literal)
      super(parent, line_number)
      @literal = literal
    end
    
    def infer(typer)
      return @inferred_type if resolved?
      resolved!
      @inferred_type = typer.float_type
    end
  end
  
  class Hash < Node; end
  
  class String < Node
    include Literal
    
    def initialize(parent, line_number, literal)
      super(parent, line_number)
      @literal = literal
    end
    
    def infer(typer)
      return @inferred_type if resolved?
      resolved!
      @inferred_type ||= typer.string_type
    end
  end
  
  class Symbol < Node; end
  
  class Boolean < Node
    include Literal
    
    def initialize(parent, line_number, literal)
      super(parent, line_number)
      @literal = literal
    end
    
    def infer(typer)
      return @inferred_type if resolved?
      resolved!
      @inferred_type ||= typer.boolean_type
    end
  end

  class Null < Node
    include Literal

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
duby-0.0.1 lib/duby/ast/literal.rb