Class: Halunke::Runtime::HObject
- Inherits:
-
Object
- Object
- Halunke::Runtime::HObject
- Defined in:
- lib/halunke/runtime/hobject.rb
Instance Attribute Summary collapse
-
#dict ⇒ Object
readonly
Returns the value of attribute dict.
-
#runtime_class ⇒ Object
readonly
Returns the value of attribute runtime_class.
-
#source_code_position ⇒ Object
readonly
Returns the value of attribute source_code_position.
Instance Method Summary collapse
-
#initialize(runtime_class, dict, source_code_position:) ⇒ HObject
constructor
A new instance of HObject.
- #inspect(context) ⇒ Object
- #receive_message(context, message_name, message_value, source_code_position: NullSourceCodePosition.new) ⇒ Object
Constructor Details
#initialize(runtime_class, dict, source_code_position:) ⇒ HObject
Returns a new instance of HObject.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/halunke/runtime/hobject.rb', line 10 def initialize(runtime_class, dict, source_code_position:) @runtime_class = runtime_class @dict = {} @source_code_position = source_code_position dict.each_pair do |hkey, value| key = hkey.ruby_value raise HUnknownAttribute.new("Unknown attribute '#{key}' for #{@runtime_class.name}", source_code_position) unless @runtime_class.allowed_attribute? key @dict[key] = value end end |
Instance Attribute Details
#dict ⇒ Object (readonly)
Returns the value of attribute dict.
6 7 8 |
# File 'lib/halunke/runtime/hobject.rb', line 6 def dict @dict end |
#runtime_class ⇒ Object (readonly)
Returns the value of attribute runtime_class.
7 8 9 |
# File 'lib/halunke/runtime/hobject.rb', line 7 def runtime_class @runtime_class end |
#source_code_position ⇒ Object (readonly)
Returns the value of attribute source_code_position.
8 9 10 |
# File 'lib/halunke/runtime/hobject.rb', line 8 def source_code_position @source_code_position end |
Instance Method Details
#inspect(context) ⇒ Object
32 33 34 |
# File 'lib/halunke/runtime/hobject.rb', line 32 def inspect(context) (context, "inspect", []).ruby_value end |
#receive_message(context, message_name, message_value, source_code_position: NullSourceCodePosition.new) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/halunke/runtime/hobject.rb', line 21 def (context, , , source_code_position: NullSourceCodePosition.new) if == "@ else" @dict.fetch([0].ruby_value, [1]) else m = @runtime_class.lookup() m.(context, "call", [HArray.create_instance([self].concat())]) end rescue KeyError raise HUnknownMessage.new(self.inspect(context), , @runtime_class.instance_methods.keys, source_code_position) end |