Sha256: a259efb73644bb8eeafd9d51a94a1877a6c47b79ee1966a2c5a5ea0e3a419798

Contents?: true

Size: 885 Bytes

Versions: 1

Compression:

Stored size: 885 Bytes

Contents

# # frozen_string_literal: true

require_relative 'word'
require_relative '../forthic_module'

module Forthic
  class StartModuleWord < Word
    # @param [Interpreter] interp
    def execute(interp)
      # The app module is the only module with a blank name
      if self.name == ""
        interp.module_stack_push(interp.get_app_module)
        return
      end

      # If the module is used by the current module, push it onto the stack, otherwise
      # create a new module.
      mod = interp.cur_module.find_module(self.name)
      unless mod
        mod = ForthicModule.new(self.name)
        interp.cur_module.register_module(mod.name, mod.name, mod)

        # If we're at the app module, also register with interpreter
        if interp.cur_module.name == ""
          interp.register_module(mod)
        end
      end
      interp.module_stack_push(mod)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
forthic-0.1.0 lib/forthic/words/start_module_word.rb