Sha256: c24ff0eb08500695c6127029e8ef497ee768c20e07cc858727ee141a339f4f8c

Contents?: true

Size: 951 Bytes

Versions: 1

Compression:

Stored size: 951 Bytes

Contents

# frozen_string_literal: true

require_relative '../datatype/all_datatypes'

module Loxxy
  module BackEnd
    # Representation of a Lox class.
    class LoxClass
      # @return [String] The name of the class
      attr_reader :name

      # @return [Array<>] the list of methods
      attr_reader :methods
      attr_reader :stack

      # Create a class with given name
      # @param aName [String] The name of the class
      def initialize(aName, theMethods, anEngine)
        @name = aName.dup
        @methods = theMethods
        @stack = anEngine.stack
      end

      def accept(_visitor)
        stack.push self
      end

      # Logical negation.
      # As a function is a truthy thing, its negation is thus false.
      # @return [Datatype::False]
      def !
        Datatype::False.instance
      end

      # Text representation of a Lox function
      def to_str
        name
      end
    end # class
  end # module
end # module

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
loxxy-0.1.11 lib/loxxy/back_end/lox_class.rb