Class: GlooLang::Exec::ExecEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/gloo_lang/exec/exec_env.rb

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine) ⇒ ExecEnv

Set up the execution environment.



22
23
24
25
26
27
28
29
30
# File 'lib/gloo_lang/exec/exec_env.rb', line 22

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

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



12
13
14
# File 'lib/gloo_lang/exec/exec_env.rb', line 12

def actions
  @actions
end

#hereObject

Returns the value of attribute here.



12
13
14
# File 'lib/gloo_lang/exec/exec_env.rb', line 12

def here
  @here
end

#scriptsObject

Returns the value of attribute scripts.



12
13
14
# File 'lib/gloo_lang/exec/exec_env.rb', line 12

def scripts
  @scripts
end

#verbsObject

Returns the value of attribute verbs.



12
13
14
# File 'lib/gloo_lang/exec/exec_env.rb', line 12

def verbs
  @verbs
end

Instance Method Details

#here_objObject

Get the here object.



35
36
37
38
39
# File 'lib/gloo_lang/exec/exec_env.rb', line 35

def here_obj
  return nil if @here.stack.empty?

  return @here.stack.last
end

#pop_actionObject

Pop an action off the stack.



68
69
70
71
# File 'lib/gloo_lang/exec/exec_env.rb', line 68

def pop_action
  @actions.pop
  # @here.pop
end

#pop_scriptObject

Pop a script off the stack.



52
53
54
55
# File 'lib/gloo_lang/exec/exec_env.rb', line 52

def pop_script
  @scripts.pop
  @here.pop
end

#push_action(action) ⇒ Object

Push an action onto the stack.



60
61
62
63
# File 'lib/gloo_lang/exec/exec_env.rb', line 60

def push_action( action )
  @actions.push action
  # @here.push action.to
end

#push_script(script) ⇒ Object

Push a script onto the stack.



44
45
46
47
# File 'lib/gloo_lang/exec/exec_env.rb', line 44

def push_script( script )
  @scripts.push script
  @here.push script.obj
end