Sha256: a4f03c138e63a1fa7953ffa1ded5aa49b1b85d402c3dedf208719f62abf052c9

Contents?: true

Size: 1.51 KB

Versions: 6

Compression:

Stored size: 1.51 KB

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2020 Eric Crane.  All rights reserved.
#
# The execution environment.
# The current state of running scripts and messaging.
#

module GlooLang
  module Exec
    class ExecEnv

      attr_accessor :verbs, :actions, :scripts, :here

      VERB_STACK = 'verbs'.freeze
      ACTION_STACK = 'actions'.freeze
      SCRIPT_STACK = 'scripts'.freeze
      HERE_STACK = 'here'.freeze

      #
      # Set up the execution environment.
      #
      def initialize
        $log.debug 'exec env intialized...'

        @verbs = GlooLang::Exec::Stack.new VERB_STACK
        @actions = GlooLang::Exec::Stack.new ACTION_STACK
        @scripts = GlooLang::Exec::Stack.new SCRIPT_STACK
        @here = GlooLang::Exec::Stack.new HERE_STACK
      end

      #
      # Get the here object.
      #
      def here_obj
        return nil if @here.stack.empty?

        return @here.stack.last
      end

      #
      # Push a script onto the stack.
      #
      def push_script( script )
        @scripts.push script
        @here.push script.obj
      end

      #
      # Pop a script off the stack.
      #
      def pop_script
        @scripts.pop
        @here.pop
      end

      #
      # Push an action onto the stack.
      #
      def push_action( action )
        @actions.push action
        # @here.push action.to
      end

      #
      # Pop an action off the stack.
      #
      def pop_action
        @actions.pop
        # @here.pop
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gloo-lang-0.9.8 lib/gloo_lang/exec/exec_env.rb
gloo-lang-0.9.7 lib/gloo_lang/exec/exec_env.rb
gloo-lang-0.9.6 lib/gloo_lang/exec/exec_env.rb
gloo-lang-0.9.5 lib/gloo_lang/exec/exec_env.rb
gloo-lang-0.9.4 lib/gloo_lang/exec/exec_env.rb
gloo-lang-0.9.3 lib/gloo_lang/exec/exec_env.rb