Class: Sol::RuntimeModel::SolClass

Inherits:
SolObject
  • Object
show all
Defined in:
lib/sol/runtime/class.rb

Overview

Represents a Sol class in the Ruby world. Classes are objects in Sol so they inherit from SolObject

Instance Attribute Summary collapse

Attributes inherited from SolObject

#ruby_value, #runtime_class

Instance Method Summary collapse

Methods inherited from SolObject

#call

Constructor Details

#initializeSolClass

Create a new class. Number is an instance of Class for example



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sol/runtime/class.rb', line 13

def initialize

	@runtime_methods = {}

	# Check if we're bootstrapping (launching the runtime). During this process the
	# runtime is not fully initialised and core classes do not yet exists, so we defer
	# using those once the language is bootstrapped.
	# This solves the chicken-or-the-egg problem with the Class class. We can
	# initialise Class then set Class.class = Class.
	if defined?(Runtime) # RuntimeModel is a temporary name

		runtime_class = Runtime["Class"]

	else

		runtime_class = nil

	end

	super(runtime_class)

end

Instance Attribute Details

#runtime_methodsObject (readonly)

Returns the value of attribute runtime_methods.



10
11
12
# File 'lib/sol/runtime/class.rb', line 10

def runtime_methods
  @runtime_methods
end

Instance Method Details

#lookup(method_name) ⇒ Object

Lookup a method



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/sol/runtime/class.rb', line 37

def lookup(method_name)

	method = @runtime_methods[method_name]

	unless method

		raise "Method not found: #{method_name}"

	end

	return method

end

#newObject

Create a new instance of the class



52
53
54
55
56
# File 'lib/sol/runtime/class.rb', line 52

def new

	SolObject.new(self)

end

#new_with_value(value) ⇒ Object

Create an instance of this Sol class that holds a Ruby value



59
60
61
62
63
# File 'lib/sol/runtime/class.rb', line 59

def new_with_value(value)

	SolObject.new(self, value)

end