Class: Fable::VariablePointerValue

Inherits:
Value show all
Defined in:
lib/fable/value.rb

Instance Attribute Summary collapse

Attributes inherited from Value

#value_object

Attributes inherited from RuntimeObject

#original_object, #own_debug_metadata, #parent, #path

Instance Method Summary collapse

Methods inherited from Value

#bad_cast_exception, create

Methods inherited from RuntimeObject

#compact_path_string, #convert_path_to_relative, #debug_line_number_of_path, #debug_metadata, #indentation_string, #resolve_path, #root_content_container

Constructor Details

#initialize(variable_name = nil, context_index = -1)) ⇒ VariablePointerValue

Returns a new instance of VariablePointerValue.



239
240
241
242
# File 'lib/fable/value.rb', line 239

def initialize(variable_name=nil, context_index = -1)
  super(variable_name)
  self.context_index = context_index
end

Instance Attribute Details

#context_indexObject

Where the variable is located -1 = default, unknown, to be determined 0 = in global scope 1+ = callstack element index + 1 (so that the first doesn’t conflict with special global scope)



226
227
228
# File 'lib/fable/value.rb', line 226

def context_index
  @context_index
end

Instance Method Details

#cast(new_type) ⇒ Object



244
245
246
247
248
249
250
# File 'lib/fable/value.rb', line 244

def cast(new_type)
  if new_type == self.class
    return self
  end

  raise bad_cast_exception(new_type)
end

#copyObject



256
257
258
# File 'lib/fable/value.rb', line 256

def copy
  return VariablePointerValue.new(variable_name, context_index)
end

#to_sObject



252
253
254
# File 'lib/fable/value.rb', line 252

def to_s
  return "VariablePointerValue(#{variable_name})"
end

#truthy?Boolean

Returns:

  • (Boolean)

Raises:



235
236
237
# File 'lib/fable/value.rb', line 235

def truthy?
  raise Error, "Shouldn't be checking the truthiness of a variable pointer"
end

#value_typeObject



231
232
233
# File 'lib/fable/value.rb', line 231

def value_type
  return OrderedValueTypes[VariablePointerValue]
end