Sha256: 8a21c78ab59705bda00cc097e1b8062f337f887f1f8848fcf84f7caa0f7f51af
Contents?: true
Size: 1.15 KB
Versions: 3
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true require_relative '../datatype/all_datatypes' module Loxxy module BackEnd # rubocop: disable Style/AccessorGrouping # Representation of a Lox function. # It is a named slot that can be associated with a value at the time. class Function # @return [String] attr_reader :name # @return [Array<>] the parameters attr_reader :parameters attr_reader :body attr_reader :stack # 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, parameterList, aBody, aStack) @name = aName.dup @parameters = parameterList @body = aBody @stack = aStack end def accept(_visitor) stack.push self end def call(aVisitor) body.empty? ? Datatype::Nil.instance : body.accept(aVisitor) end # Text representation of a Lox function def to_str "<fn #{name}>" end end # class # rubocop: enable Style/AccessorGrouping end # module end # module
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
loxxy-0.1.03 | lib/loxxy/back_end/function.rb |
loxxy-0.1.02 | lib/loxxy/back_end/function.rb |
loxxy-0.1.01 | lib/loxxy/back_end/function.rb |