Class: GlooLang::Core::Heap

Inherits:
Object
  • Object
show all
Defined in:
lib/gloo_lang/core/heap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine) ⇒ Heap

Set up the object heap.



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gloo_lang/core/heap.rb', line 22

def initialize( engine )
  @engine = engine
  @engine.log.debug 'object heap intialized...'

  @root = GlooLang::Objs::Container.new( @engine )
  @root.name = 'root'

  @context = Pn.root @engine
  @it = It.new
  @error = Error.new
end

Instance Attribute Details

#contextObject (readonly)

The context is a reference to an object, usually a container. The context will be the root by default.



15
16
17
# File 'lib/gloo_lang/core/heap.rb', line 15

def context
  @context
end

#errorObject (readonly)

Returns the value of attribute error.



17
18
19
# File 'lib/gloo_lang/core/heap.rb', line 17

def error
  @error
end

#itObject (readonly)

Returns the value of attribute it.



17
18
19
# File 'lib/gloo_lang/core/heap.rb', line 17

def it
  @it
end

#rootObject (readonly)

Returns the value of attribute root.



17
18
19
# File 'lib/gloo_lang/core/heap.rb', line 17

def root
  @root
end

Instance Method Details

#error?Boolean

Is there one or more errors?

Returns:

  • (Boolean)


47
48
49
# File 'lib/gloo_lang/core/heap.rb', line 47

def error?
  return @error.error_count.positive?
end

#unload(obj) ⇒ Object

Unload the given obj–remove it from the heap.



37
38
39
40
41
42
# File 'lib/gloo_lang/core/heap.rb', line 37

def unload( obj )
  can = obj.parent.nil? ? @root : obj.parent
  return unless can

  can.remove_child obj
end