Sha256: caf55e7b325bfef1f60c2fd412ad8bdcd6b0af0535980edef6804e56c46cc9db

Contents?: true

Size: 925 Bytes

Versions: 43

Compression:

Stored size: 925 Bytes

Contents

# frozen_string_literal: true

require_relative 'entry'
require_relative '../datatype/all_datatypes'

module Loxxy
  module BackEnd
    # Representation of a Lox variable.
    # It is a named slot that can be associated with a value at the time.
    class Variable
      include Entry # Add expected behaviour for symbol table entries

      # @return [Datatype::BuiltinDatatype] the value assigned to the variable
      attr_reader :value

      # Create a variable with given name and initial value
      # @param aName [String] The name of the variable
      # @param aValue [Datatype::BuiltinDatatype] the initial assigned value
      def initialize(aName, aValue = Datatype::Nil.instance)
        init_name(aName)
        assign(aValue)
      end

      # @param aValue [Datatype::BuiltinDatatype] the assigned value
      def assign(aValue)
        @value = aValue
      end
    end # class
  end # module
end # module

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
loxxy-0.1.17 lib/loxxy/back_end/variable.rb
loxxy-0.1.16 lib/loxxy/back_end/variable.rb
loxxy-0.1.15 lib/loxxy/back_end/variable.rb
loxxy-0.1.14 lib/loxxy/back_end/variable.rb
loxxy-0.1.13 lib/loxxy/back_end/variable.rb
loxxy-0.1.12 lib/loxxy/back_end/variable.rb
loxxy-0.1.11 lib/loxxy/back_end/variable.rb
loxxy-0.1.10 lib/loxxy/back_end/variable.rb
loxxy-0.1.09 lib/loxxy/back_end/variable.rb
loxxy-0.1.08 lib/loxxy/back_end/variable.rb
loxxy-0.1.07 lib/loxxy/back_end/variable.rb
loxxy-0.1.06 lib/loxxy/back_end/variable.rb
loxxy-0.1.05 lib/loxxy/back_end/variable.rb
loxxy-0.1.04 lib/loxxy/back_end/variable.rb
loxxy-0.1.03 lib/loxxy/back_end/variable.rb
loxxy-0.1.02 lib/loxxy/back_end/variable.rb
loxxy-0.1.01 lib/loxxy/back_end/variable.rb
loxxy-0.1.0 lib/loxxy/back_end/variable.rb
loxxy-0.0.28 lib/loxxy/back_end/variable.rb
loxxy-0.0.27 lib/loxxy/back_end/variable.rb