gloo-lang 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/lib/VERSION +1 -1
  3. data/lib/gloo_lang/app/args.rb +3 -2
  4. data/lib/gloo_lang/app/engine.rb +23 -23
  5. data/lib/gloo_lang/app/help.rb +10 -9
  6. data/lib/gloo_lang/app/log.rb +5 -3
  7. data/lib/gloo_lang/app/settings.rb +10 -9
  8. data/lib/gloo_lang/convert/converter.rb +9 -2
  9. data/lib/gloo_lang/core/baseo.rb +2 -1
  10. data/lib/gloo_lang/core/dictionary.rb +16 -6
  11. data/lib/gloo_lang/core/event_manager.rb +9 -8
  12. data/lib/gloo_lang/core/factory.rb +11 -10
  13. data/lib/gloo_lang/core/gloo_system.rb +9 -8
  14. data/lib/gloo_lang/core/heap.rb +5 -4
  15. data/lib/gloo_lang/core/here.rb +2 -2
  16. data/lib/gloo_lang/core/obj.rb +9 -8
  17. data/lib/gloo_lang/core/obj_finder.rb +3 -3
  18. data/lib/gloo_lang/core/parser.rb +6 -5
  19. data/lib/gloo_lang/core/pn.rb +20 -16
  20. data/lib/gloo_lang/core/verb.rb +2 -1
  21. data/lib/gloo_lang/exec/dispatch.rb +8 -8
  22. data/lib/gloo_lang/exec/exec_env.rb +7 -6
  23. data/lib/gloo_lang/exec/runner.rb +10 -10
  24. data/lib/gloo_lang/exec/script.rb +6 -5
  25. data/lib/gloo_lang/exec/stack.rb +8 -7
  26. data/lib/gloo_lang/expr/expression.rb +3 -2
  27. data/lib/gloo_lang/objs/basic/alias.rb +4 -4
  28. data/lib/gloo_lang/objs/basic/boolean.rb +3 -3
  29. data/lib/gloo_lang/objs/basic/container.rb +2 -2
  30. data/lib/gloo_lang/objs/basic/decimal.rb +3 -3
  31. data/lib/gloo_lang/objs/basic/integer.rb +3 -3
  32. data/lib/gloo_lang/objs/basic/script.rb +1 -1
  33. data/lib/gloo_lang/objs/basic/string.rb +3 -3
  34. data/lib/gloo_lang/objs/basic/text.rb +2 -2
  35. data/lib/gloo_lang/objs/ctrl/each.rb +3 -3
  36. data/lib/gloo_lang/objs/ctrl/repeat.rb +2 -2
  37. data/lib/gloo_lang/objs/data/markdown.rb +2 -2
  38. data/lib/gloo_lang/objs/data/query.rb +4 -4
  39. data/lib/gloo_lang/objs/data/table.rb +3 -3
  40. data/lib/gloo_lang/objs/dt/date.rb +1 -1
  41. data/lib/gloo_lang/objs/dt/datetime.rb +2 -2
  42. data/lib/gloo_lang/objs/dt/time.rb +1 -1
  43. data/lib/gloo_lang/objs/ror/erb.rb +2 -2
  44. data/lib/gloo_lang/objs/ror/eval.rb +3 -3
  45. data/lib/gloo_lang/objs/web/http_get.rb +3 -3
  46. data/lib/gloo_lang/objs/web/http_post.rb +8 -8
  47. data/lib/gloo_lang/objs/web/json.rb +5 -5
  48. data/lib/gloo_lang/objs/web/slack.rb +1 -1
  49. data/lib/gloo_lang/objs/web/teams.rb +1 -1
  50. data/lib/gloo_lang/objs/web/uri.rb +6 -6
  51. data/lib/gloo_lang/persist/file_loader.rb +6 -5
  52. data/lib/gloo_lang/persist/file_saver.rb +2 -1
  53. data/lib/gloo_lang/persist/file_storage.rb +6 -5
  54. data/lib/gloo_lang/persist/persist_man.rb +9 -8
  55. data/lib/gloo_lang/utils/stats.rb +5 -4
  56. data/lib/gloo_lang/verbs/context.rb +4 -4
  57. data/lib/gloo_lang/verbs/create.rb +3 -3
  58. data/lib/gloo_lang/verbs/execute.rb +4 -4
  59. data/lib/gloo_lang/verbs/help.rb +23 -23
  60. data/lib/gloo_lang/verbs/if.rb +3 -3
  61. data/lib/gloo_lang/verbs/list.rb +7 -7
  62. data/lib/gloo_lang/verbs/load.rb +3 -3
  63. data/lib/gloo_lang/verbs/move.rb +6 -6
  64. data/lib/gloo_lang/verbs/put.rb +6 -6
  65. data/lib/gloo_lang/verbs/quit.rb +1 -1
  66. data/lib/gloo_lang/verbs/run.rb +5 -5
  67. data/lib/gloo_lang/verbs/save.rb +1 -1
  68. data/lib/gloo_lang/verbs/show.rb +5 -5
  69. data/lib/gloo_lang/verbs/tell.rb +5 -4
  70. data/lib/gloo_lang/verbs/unless.rb +3 -3
  71. data/lib/gloo_lang/verbs/version.rb +1 -1
  72. data/lib/gloo_lang/verbs/wait.rb +1 -1
  73. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd3e269694e1c7aef191b9fcd1bae34b29932fc2215f90f372cfd5d5d2748bc0
4
- data.tar.gz: 7976911ab79e1679c1940e43217f4c8fc533bab59fbf2a71b857ee4a7aeefed2
3
+ metadata.gz: 402d31f29ed04334fc22758dd7aaa7cc230f66ccf341e3cc5b1cedc42fdf998d
4
+ data.tar.gz: 10d69c788bf1975b3beb2eb79eff6d18a919f2956678be2d6649b407b6b1ad9e
5
5
  SHA512:
6
- metadata.gz: f9be9692d331f3767e78efc2e9a5fcb5d826e11429240cf77ae9d134a41408b2fbed7a144b54a6ba8291619ddc4bb108cecf3743deb53f96e425018937d8fc28
7
- data.tar.gz: b29cc45d25aa4472d8112caaf08c20deccf245c9f3a0e3392e102a558e4c13daba147b9077d057d9fb67b847bc04e0ffdd5642292376857bacf1cf33896473ae
6
+ metadata.gz: 5887c6675f3ca5c7df494f351b7e25c06a118dcc73c84fe0e94242b59d1dcb3ce130216c4e164761a6e0a49855ce49ac88ede67f0a3434594069c8ac693fe937
7
+ data.tar.gz: 7849d0fc9c9dabcdb70238b0b1d5b5108fc7c3ed6e41c9d3608ada059ed1d0c514fdcdb8ddb1cb24d8a616beef3933e84e5c6faac2d81bc6a8019bdb00bcf5e6
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.8
1
+ 0.9.9
@@ -19,7 +19,8 @@ module GlooLang
19
19
  #
20
20
  # Create arguments and setup.
21
21
  #
22
- def initialize( params = [] )
22
+ def initialize( engine, params = [] )
23
+ @engine = engine
23
24
  @switches = []
24
25
  @files = []
25
26
 
@@ -84,7 +85,7 @@ module GlooLang
84
85
  else
85
86
  Mode.default_mode
86
87
  end
87
- $log.debug "running in #{mode} mode"
88
+ @engine.log.debug "running in #{mode} mode"
88
89
 
89
90
  return mode
90
91
  end
@@ -11,6 +11,7 @@ module GlooLang
11
11
  module App
12
12
  class Engine
13
13
 
14
+ attr_reader :settings, :log
14
15
  attr_reader :args, :mode, :running, :platform,
15
16
  :dictionary, :parser, :heap, :factory
16
17
  attr_accessor :last_cmd, :persist_man, :event_manager,
@@ -20,14 +21,13 @@ module GlooLang
20
21
  # Set up the engine with basic elements.
21
22
  #
22
23
  def initialize( params = [], platform=Platform, log=Log )
23
- $engine = self
24
- @args = Args.new( params )
25
- $settings = Settings.new( ENV[ 'GLOO_ENV' ] )
24
+ @args = Args.new( self, params )
25
+ @settings = Settings.new( self, ENV[ 'GLOO_ENV' ] )
26
26
 
27
- $log = log.new( @args.quiet? )
27
+ @log = Log.new( self, @args.quiet? )
28
28
  @platform = platform.new
29
29
 
30
- $log.debug 'engine intialized...'
30
+ @log.debug 'engine intialized...'
31
31
  end
32
32
 
33
33
  #
@@ -35,24 +35,24 @@ module GlooLang
35
35
  # Load object and verb definitions and setup engine elements.
36
36
  #
37
37
  def start
38
- $log.debug 'starting the engine...'
39
- $log.debug Info.display_title
38
+ @log.debug 'starting the engine...'
39
+ @log.debug Info.display_title
40
40
  @mode = @args.detect_mode
41
41
  @running = true
42
42
 
43
- @dictionary = GlooLang::Core::Dictionary.instance
44
- @dictionary.init
45
- @parser = GlooLang::Core::Parser.new
46
- @heap = GlooLang::Core::Heap.new
47
- @factory = GlooLang::Core::Factory.new
48
- @persist_man = GlooLang::Persist::PersistMan.new
49
- @event_manager = GlooLang::Core::EventManager.new
43
+ @dictionary = GlooLang::Core::Dictionary.get
50
44
 
51
- @exec_env = GlooLang::Exec::ExecEnv.new
52
- @help = GlooLang::App::Help.new
53
- @converter = GlooLang::Convert::Converter.new
45
+ @parser = GlooLang::Core::Parser.new( self )
46
+ @heap = GlooLang::Core::Heap.new( self )
47
+ @factory = GlooLang::Core::Factory.new( self )
48
+ @persist_man = GlooLang::Persist::PersistMan.new( self )
49
+ @event_manager = GlooLang::Core::EventManager.new( self )
54
50
 
55
- $log.debug 'the engine has started'
51
+ @exec_env = GlooLang::Exec::ExecEnv.new( self )
52
+ @help = GlooLang::App::Help.new( self )
53
+ @converter = GlooLang::Convert::Converter.new( self )
54
+
55
+ @log.debug 'the engine has started'
56
56
  run_mode
57
57
  end
58
58
 
@@ -64,7 +64,7 @@ module GlooLang
64
64
  # Run gloo in the selected mode.
65
65
  #
66
66
  def run_mode
67
- $log.debug "running gloo in #{@mode} mode"
67
+ @log.debug "running gloo in #{@mode} mode"
68
68
 
69
69
  if @mode == Mode::VERSION
70
70
  run_version
@@ -107,7 +107,7 @@ module GlooLang
107
107
  # Get the setting for the start_with file and open it.
108
108
  #
109
109
  def open_start_file
110
- name = $settings.start_with
110
+ name = @settings.start_with
111
111
  @persist_man.load( name ) if name
112
112
  end
113
113
 
@@ -154,7 +154,7 @@ module GlooLang
154
154
  # Do any clean up and quit.
155
155
  #
156
156
  def quit
157
- $log.debug 'quitting...'
157
+ @log.debug 'quitting...'
158
158
  end
159
159
 
160
160
  # ---------------------------------------------------------------------
@@ -193,8 +193,8 @@ module GlooLang
193
193
  # Write it to the log and set the heap error value.
194
194
  #
195
195
  def err( msg )
196
- $log.error msg
197
- self.heap.error.set_to msg
196
+ @log.error msg
197
+ @heap.error.set_to msg
198
198
  end
199
199
 
200
200
  end
@@ -16,7 +16,8 @@ module GlooLang
16
16
  # Set up the help system.
17
17
  # We won't load help topics until we know we need them.
18
18
  #
19
- def initialize
19
+ def initialize( engine )
20
+ @engine = engine
20
21
  @topics = nil
21
22
  end
22
23
 
@@ -25,7 +26,7 @@ module GlooLang
25
26
  # This is the what is shown when help is run from the CLI.
26
27
  #
27
28
  def show_app_help
28
- puts Info.display_title unless $engine.args.quiet?
29
+ puts Info.display_title unless @engine.args.quiet?
29
30
  self.show_topic APPLICATION
30
31
  end
31
32
 
@@ -54,21 +55,21 @@ module GlooLang
54
55
  # screen, it won't paginate.
55
56
  #
56
57
  def page_topic( topic )
57
- return if $engine.args.quiet?
58
+ return if @engine.args.quiet?
58
59
 
59
60
  data = self.get_topic_data( topic )
60
- page = data.lines.count > Settings.page_size
61
- $engine.platform.show( data, topic_is_md?( topic ), page )
61
+ page = data.lines.count > Settings.page_size( @engine )
62
+ @engine.platform.show( data, topic_is_md?( topic ), page )
62
63
  end
63
64
 
64
65
  #
65
66
  # Show a help topic.
66
67
  #
67
68
  def show_topic( topic )
68
- return if $engine.args.quiet?
69
+ return if @engine.args.quiet?
69
70
 
70
71
  data = self.get_topic_data( topic )
71
- $engine.platform.show( data, topic_is_md?( topic ), false )
72
+ @engine.platform.show( data, topic_is_md?( topic ), false )
72
73
  end
73
74
 
74
75
  #
@@ -92,7 +93,7 @@ module GlooLang
92
93
  return if @topics
93
94
 
94
95
  @topics = {}
95
- $log.debug 'loading help file index...'
96
+ @engine.log.debug 'loading help file index...'
96
97
 
97
98
  pn = File.dirname( File.absolute_path( __FILE__ ) )
98
99
  pn = File.dirname( pn )
@@ -109,7 +110,7 @@ module GlooLang
109
110
  @topics[ key ] = md_file
110
111
  end
111
112
 
112
- $log.debug "Found #{@topics.count} help files"
113
+ @engine.log.debug "Found #{@topics.count} help files"
113
114
  end
114
115
 
115
116
  end
@@ -9,15 +9,17 @@ module GlooLang
9
9
  module App
10
10
  class Log
11
11
 
12
- attr_reader :logger, :quiet
12
+ attr_accessor :quiet
13
+ attr_reader :logger
13
14
 
14
15
  #
15
16
  # Set up a logger.
16
17
  # If quiet is true, then message are written to the log
17
18
  # but not to the console.
18
19
  #
19
- def initialize( quiet=true )
20
- f = File.join( $settings.log_path, 'gloo.log' )
20
+ def initialize( engine, quiet=true )
21
+ @engine = engine
22
+ f = File.join( @engine.settings.log_path, 'gloo.log' )
21
23
  @logger = Logger.new( f )
22
24
  @logger.level = Logger::DEBUG
23
25
  @quite = quiet
@@ -18,7 +18,8 @@ module GlooLang
18
18
  # Load setting from the yml file.
19
19
  # The mode parameter is used to determine if we are running in TEST.
20
20
  #
21
- def initialize( mode )
21
+ def initialize( engine, mode )
22
+ @engine = engine
22
23
  @mode = mode
23
24
  init_root
24
25
  init_path_settings
@@ -49,8 +50,8 @@ module GlooLang
49
50
  puts "\nApplication Settings:"
50
51
  puts ' Startup with: ' + @start_with
51
52
  puts ' Indent in Listing: ' + @list_indent.to_s
52
- puts ' Screen Lines: ' + GlooLang::App::Settings.lines.to_s
53
- puts ' Page Size: ' + GlooLang::App::Settings.page_size.to_s
53
+ puts ' Screen Lines: ' + GlooLang::App::Settings.lines( @engine ).to_s
54
+ puts ' Page Size: ' + GlooLang::App::Settings.page_size( @engine ).to_s
54
55
  puts ''
55
56
  self.show_paths
56
57
  puts ''
@@ -94,23 +95,23 @@ module GlooLang
94
95
  #
95
96
  # Get the number of vertical lines on screen.
96
97
  #
97
- def self.lines
98
- $engine.platform.lines
98
+ def self.lines engine
99
+ engine.platform.lines
99
100
  end
100
101
 
101
102
  #
102
103
  # Get the number of horizontal columns on screen.
103
104
  #
104
- def self.cols
105
- $engine.platform.cols
105
+ def self.cols engine
106
+ engine.platform.cols
106
107
  end
107
108
 
108
109
  #
109
110
  # Get the default page size.
110
111
  # This is the number of lines of text we can show.
111
112
  #
112
- def self.page_size
113
- Settings.lines - 3
113
+ def self.page_size engine
114
+ Settings.lines( engine ) - 3
114
115
  end
115
116
 
116
117
  #
@@ -8,6 +8,13 @@ module GlooLang
8
8
  module Convert
9
9
  class Converter
10
10
 
11
+ #
12
+ # Initializer.
13
+ #
14
+ def initialize( engine )
15
+ @engine = engine
16
+ end
17
+
11
18
  # ---------------------------------------------------------------------
12
19
  # Convert
13
20
  # ---------------------------------------------------------------------
@@ -23,8 +30,8 @@ module GlooLang
23
30
  o = clazz.new
24
31
  return o.convert( value )
25
32
  rescue => e
26
- $log.error e.message
27
- $engine.heap.error.set_to e.message
33
+ @engine.log.error e.message
34
+ @engine.heap.error.set_to e.message
28
35
  end
29
36
 
30
37
  return default
@@ -14,7 +14,8 @@ module GlooLang
14
14
  NOT_IMPLEMENTED_ERR = 'Not implemented yet!'.freeze
15
15
 
16
16
  # Set up the object.
17
- def initialize
17
+ def initialize( engine )
18
+ @engine = engine
18
19
  @name = ''
19
20
  end
20
21
 
@@ -24,6 +24,16 @@ module GlooLang
24
24
  @keywords = []
25
25
  end
26
26
 
27
+ #
28
+ # Get the singleton Dictionary and Initialize
29
+ # if this is the first time.
30
+ #
31
+ def self.get
32
+ o = GlooLang::Core::Dictionary.instance
33
+ o.init if o.verbs.count == 0
34
+ return o
35
+ end
36
+
27
37
  #
28
38
  # Register a verb.
29
39
  #
@@ -42,7 +52,7 @@ module GlooLang
42
52
  # Initialize verbs and objects in the dictionary.
43
53
  #
44
54
  def init
45
- $log.debug 'initializing dictionaries'
55
+ # @engine.log.debug 'initializing dictionaries'
46
56
  init_verbs
47
57
  init_objs
48
58
  end
@@ -140,7 +150,7 @@ module GlooLang
140
150
  #
141
151
  def add_key( keyword )
142
152
  if @keywords.include?( keyword )
143
- $log.error "duplicate keyword '#{keyword}'"
153
+ # @engine.log.error "duplicate keyword '#{keyword}'"
144
154
  return
145
155
  end
146
156
 
@@ -151,9 +161,9 @@ module GlooLang
151
161
  # Init the list of objects.
152
162
  #
153
163
  def init_objs
154
- $log.debug "initializing #{@obj_references.count} objects"
164
+ # @engine.log.debug "initializing #{@obj_references.count} objects"
155
165
  @obj_references.each do |o|
156
- $log.debug o
166
+ # @engine.log.debug o
157
167
  @objs[ o.typename ] = o
158
168
  @objs[ o.short_typename ] = o
159
169
  add_key o.typename
@@ -165,9 +175,9 @@ module GlooLang
165
175
  # Init the list of verbs.
166
176
  #
167
177
  def init_verbs
168
- $log.debug "initializing #{@verb_references.count} verbs"
178
+ # @engine.log.debug "initializing #{@verb_references.count} verbs"
169
179
  @verb_references.each do |v|
170
- $log.debug v
180
+ # @engine.log.debug v
171
181
  @verbs[ v.keyword ] = v
172
182
  @verbs[ v.keyword_shortcut ] = v
173
183
  # v.send( :new ).run
@@ -12,8 +12,9 @@ module GlooLang
12
12
  #
13
13
  # Set up the event manager.
14
14
  #
15
- def initialize
16
- $log.debug 'event manager intialized...'
15
+ def initialize( engine )
16
+ @engine = engine
17
+ @engine.log.debug 'event manager intialized...'
17
18
  end
18
19
 
19
20
  #
@@ -23,9 +24,9 @@ module GlooLang
23
24
  def on_load( obj = nil, in_heap = false )
24
25
  return unless obj || in_heap
25
26
 
26
- $log.debug 'on_load event'
27
- arr = GlooLang::Core::ObjFinder.by_name 'on_load', obj
28
- arr.each { |o| GlooLang::Exec::Dispatch.message 'run', o }
27
+ @engine.log.debug 'on_load event'
28
+ arr = GlooLang::Core::ObjFinder.by_name( @engine, 'on_load', obj )
29
+ arr.each { |o| GlooLang::Exec::Dispatch.message( @engine, 'run', o ) }
29
30
  end
30
31
 
31
32
  #
@@ -34,9 +35,9 @@ module GlooLang
34
35
  def on_unload( obj )
35
36
  return unless obj
36
37
 
37
- $log.debug 'on_unload event'
38
- arr = GlooLang::Core::ObjFinder.by_name 'on_unload', obj
39
- arr.each { |o| GlooLang::Exec::Dispatch.message 'run', o }
38
+ @engine.log.debug 'on_unload event'
39
+ arr = GlooLang::Core::ObjFinder.by_name( @engine, 'on_unload', obj )
40
+ arr.each { |o| GlooLang::Exec::Dispatch.message( @engine, 'run', o ) }
40
41
  end
41
42
 
42
43
  end
@@ -15,8 +15,9 @@ module GlooLang
15
15
  #
16
16
  # Set up the object factory.
17
17
  #
18
- def initialize
19
- $log.debug 'object factory intialized...'
18
+ def initialize( engine )
19
+ @engine = engine
20
+ @engine.log.debug 'object factory intialized...'
20
21
  end
21
22
 
22
23
  # ---------------------------------------------------------------------
@@ -140,7 +141,7 @@ module GlooLang
140
141
  objtype = find_type params[ :type ]
141
142
  return nil unless objtype
142
143
 
143
- pn = GlooLang::Core::Pn.new params[ :name ]
144
+ pn = GlooLang::Core::Pn.new( @engine, params[ :name ] )
144
145
  parent = params[ :parent ]
145
146
  if parent.nil?
146
147
  parent = pn.get_parent
@@ -150,11 +151,11 @@ module GlooLang
150
151
  end
151
152
 
152
153
  if pn.exists? && params[ :squash_duplicates ]
153
- $log.debug "Updating existing object: #{obj_name}"
154
+ @engine.log.debug "Updating existing object: #{obj_name}"
154
155
  return self.update_existing pn, params[ :value ]
155
156
  end
156
157
 
157
- $log.debug "Creating new object: #{obj_name}"
158
+ @engine.log.debug "Creating new object: #{obj_name}"
158
159
  return create_new obj_name, params[ :value ], objtype, parent
159
160
  end
160
161
 
@@ -163,11 +164,11 @@ module GlooLang
163
164
  #
164
165
  def create_new( name, value, type, parent )
165
166
  unless parent
166
- $log.error "Could not create object. Bad path: #{name}"
167
+ @engine.log.error "Could not create object. Bad path: #{name}"
167
168
  return nil
168
169
  end
169
170
 
170
- o = type.new
171
+ o = type.new( @engine )
171
172
  o.name = name
172
173
  o.set_value value
173
174
  parent.add_child( o )
@@ -190,15 +191,15 @@ module GlooLang
190
191
  #
191
192
  def find_type( type_name )
192
193
  type_name = 'untyped' if type_name.nil? || type_name.strip.empty?
193
- t = $engine.dictionary.find_obj( type_name )
194
+ t = @engine.dictionary.find_obj( type_name )
194
195
 
195
196
  if t.nil?
196
- $log.warn "Could not find type, '#{type_name}'"
197
+ @engine.log.warn "Could not find type, '#{type_name}'"
197
198
  return nil
198
199
  end
199
200
 
200
201
  unless t.can_create?
201
- $log.error "'#{type_name}' cannot be created."
202
+ @engine.log.error "'#{type_name}' cannot be created."
202
203
  return nil
203
204
  end
204
205
 
@@ -18,7 +18,8 @@ module GlooLang
18
18
  attr_reader :pn
19
19
 
20
20
  # Set up the object.
21
- def initialize( pn )
21
+ def initialize( engine, pn )
22
+ @engine = engine
22
23
  @pn = pn
23
24
  end
24
25
 
@@ -137,7 +138,7 @@ module GlooLang
137
138
  o = "msg_#{msg}"
138
139
  return self.public_send( o ) if self.respond_to? o
139
140
 
140
- $log.error "Message #{msg} not implemented"
141
+ @engine.log.error "Message #{msg} not implemented"
141
142
  return false
142
143
  end
143
144
 
@@ -163,22 +164,22 @@ module GlooLang
163
164
 
164
165
  # Get the Gloo home directory
165
166
  def msg_gloo_home
166
- return $settings.user_root
167
+ return @engine.settings.user_root
167
168
  end
168
169
 
169
170
  # Get the Gloo configuration directory
170
171
  def msg_gloo_config
171
- return $settings.config_path
172
+ return @engine.settings.config_path
172
173
  end
173
174
 
174
175
  # Get the Gloo projects directory
175
176
  def msg_gloo_projects
176
- return $settings.project_path
177
+ return @engine.settings.project_path
177
178
  end
178
179
 
179
180
  # Get the Gloo log directory
180
181
  def msg_gloo_log
181
- return $settings.log_path
182
+ return @engine.settings.log_path
182
183
  end
183
184
 
184
185
  # ---------------------------------------------------------------------
@@ -196,12 +197,12 @@ module GlooLang
196
197
 
197
198
  # Get the number of lines on screen.
198
199
  def msg_screen_lines
199
- return GlooLang::App::Settings.lines
200
+ return GlooLang::App::Settings.lines( @engine )
200
201
  end
201
202
 
202
203
  # Get the number of columns on screen.
203
204
  def msg_screen_cols
204
- return GlooLang::App::Settings.cols
205
+ return GlooLang::App::Settings.cols( @engine )
205
206
  end
206
207
 
207
208
  # ---------------------------------------------------------------------
@@ -19,13 +19,14 @@ module GlooLang
19
19
  #
20
20
  # Set up the object heap.
21
21
  #
22
- def initialize
23
- $log.debug 'object heap intialized...'
22
+ def initialize( engine )
23
+ @engine = engine
24
+ @engine.log.debug 'object heap intialized...'
24
25
 
25
- @root = GlooLang::Objs::Container.new
26
+ @root = GlooLang::Objs::Container.new( @engine)
26
27
  @root.name = 'root'
27
28
 
28
- @context = Pn.root
29
+ @context = Pn.root engine
29
30
  @it = It.new
30
31
  @error = Error.new
31
32
  end
@@ -21,8 +21,8 @@ module GlooLang
21
21
  #
22
22
  # Expand here reference if present.
23
23
  #
24
- def self.expand_here( pn )
25
- target = $engine.exec_env.here_obj
24
+ def self.expand_here( engine, pn )
25
+ target = engine.exec_env.here_obj
26
26
 
27
27
  here = pn.elements.first
28
28
  remainder = pn.elements[ 1..-1 ].join( '.' )
@@ -15,7 +15,8 @@ module GlooLang
15
15
  #
16
16
  # Set up the object.
17
17
  #
18
- def initialize
18
+ def initialize( engine )
19
+ @engine = engine
19
20
  @value = ''
20
21
  @children = []
21
22
  @parent = nil
@@ -152,7 +153,7 @@ module GlooLang
152
153
  :type => type,
153
154
  :value => nil,
154
155
  :parent => self }
155
- return $engine.factory.create params
156
+ return @engine.factory.create params
156
157
  end
157
158
 
158
159
  #
@@ -193,7 +194,7 @@ module GlooLang
193
194
  end
194
195
 
195
196
  if self.type_display == GlooLang::Objs::Alias.typename
196
- ln = GlooLang::Core::Pn.new( self.value )
197
+ ln = GlooLang::Core::Pn.new( @engine, self.value )
197
198
  redirect = ln.resolve
198
199
  return redirect.find_child( name )
199
200
  end
@@ -256,7 +257,7 @@ module GlooLang
256
257
  @params = params
257
258
  return self.dispatch msg if self.can_receive_message? msg
258
259
 
259
- $log.error "Object #{self.name} cannot receive message #{msg}"
260
+ @engine.log.error "Object #{self.name} cannot receive message #{msg}"
260
261
  return false
261
262
  end
262
263
 
@@ -269,7 +270,7 @@ module GlooLang
269
270
  self.public_send( o )
270
271
  return true
271
272
  else
272
- $log.error "Message #{msg} not implemented"
273
+ @engine.log.error "Message #{msg} not implemented"
273
274
  return false
274
275
  end
275
276
  end
@@ -279,12 +280,12 @@ module GlooLang
279
280
  #
280
281
  def msg_unload
281
282
  if self.root?
282
- $log.error 'Cannot unload the root object.'
283
+ @engine.log.error 'Cannot unload the root object.'
283
284
  return
284
285
  end
285
286
 
286
- $engine.event_manager.on_unload self
287
- $engine.heap.unload self
287
+ @engine.event_manager.on_unload self
288
+ @engine.heap.unload self
288
289
  end
289
290
 
290
291
  # ---------------------------------------------------------------------
@@ -13,13 +13,13 @@ module GlooLang
13
13
  # the given name.
14
14
  # If the container isn't provided, root will be used.
15
15
  #
16
- def self.by_name( name, container = nil )
17
- container = $engine.heap.root if container.nil?
16
+ def self.by_name( engine, name, container = nil )
17
+ container = engine.heap.root if container.nil?
18
18
  arr = []
19
19
 
20
20
  container.children.each do |o|
21
21
  arr << o if o.name == name
22
- arr += by_name( name, o ) if o.child_count.positive?
22
+ arr += by_name( engine, name, o ) if o.child_count.positive?
23
23
  end
24
24
 
25
25
  return arr
@@ -12,8 +12,9 @@ module GlooLang
12
12
  #
13
13
  # Set up the parser.
14
14
  #
15
- def initialize
16
- $log.debug 'parser intialized...'
15
+ def initialize( engine )
16
+ @engine = engine
17
+ @engine.log.debug 'parser intialized...'
17
18
  end
18
19
 
19
20
  #
@@ -25,9 +26,9 @@ module GlooLang
25
26
  tokens = GlooLang::Core::Tokens.new( cmd )
26
27
  dic = GlooLang::Core::Dictionary.instance
27
28
  verb = dic.find_verb( tokens.verb )
28
- return verb.new( tokens, params ) if verb
29
+ return verb.new( @engine, tokens, params ) if verb
29
30
 
30
- $log.error "Verb '#{tokens.verb}' was not found."
31
+ @engine.log.error "Verb '#{tokens.verb}' was not found."
31
32
  return nil
32
33
  end
33
34
 
@@ -51,7 +52,7 @@ module GlooLang
51
52
  #
52
53
  def run( cmd )
53
54
  v = parse_immediate( cmd )
54
- GlooLang::Exec::Runner.go( v ) if v
55
+ GlooLang::Exec::Runner.go( @engine, v ) if v
55
56
  end
56
57
 
57
58
  end