Sha256: fd4321d6686b6f1c5ae90297cf9c932f5d435132302dfb07ae7a7ea98491d5a6

Contents?: true

Size: 1.6 KB

Versions: 23

Compression:

Stored size: 1.6 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( engine )
        @engine = engine
        @engine.log.debug 'exec env intialized...'

        @verbs = GlooLang::Exec::Stack.new( @engine, VERB_STACK )
        @actions = GlooLang::Exec::Stack.new( @engine, ACTION_STACK )
        @scripts = GlooLang::Exec::Stack.new( @engine, SCRIPT_STACK )
        @here = GlooLang::Exec::Stack.new( @engine, 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

23 entries across 23 versions & 1 rubygems

Version Path
gloo-lang-1.4.3 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.4.2 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.4.1 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.4.0 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.3.2 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.3.1 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.3.0 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.2.8 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.2.7 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.2.6 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.2.5 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.2.4 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.2.3 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.2.2 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.2.1 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.2.0 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.1.0 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.0.2 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.0.1 lib/gloo_lang/exec/exec_env.rb
gloo-lang-1.0.0 lib/gloo_lang/exec/exec_env.rb