Class: Yadriggy::Super

Inherits:
ASTnode show all
Defined in:
lib/yadriggy/ast.rb,
lib/yadriggy/ast_value.rb

Overview

Reserved word ‘super`. `super` is a reserved word but no position (line numbre) is associated with it. Hence Super is not a subclass of Reserved.

Instance Attribute Summary

Attributes inherited from ASTnode

#parent, #usertype

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ASTnode

#add_child, #add_children, #const_value, #const_value_in_class, #get_context_class, #get_receiver_object, #is_proc?, #pretty_print, #root, #source_location, #source_location_string, #value_in_class

Constructor Details

#initialize(sexp) ⇒ Super



237
# File 'lib/yadriggy/ast.rb', line 237

def initialize(sexp) end

Class Method Details

.tagObject



235
# File 'lib/yadriggy/ast.rb', line 235

def self.tag() :zsuper end

Instance Method Details

#accept(evaluator) ⇒ void

This method returns an undefined value.

A method for Visitor pattern.



242
243
244
# File 'lib/yadriggy/ast.rb', line 242

def accept(evaluator)
  evaluator.super_method(self)
end

#invoked_methodObject

Gets the super method (Method or UnboundMethod object) or nil. If this AST node is not a part of method body, Undef is returned.



253
254
255
256
257
258
259
260
# File 'lib/yadriggy/ast_value.rb', line 253

def invoked_method()
  mthd = root.context
  if mthd.is_a?(Method) || mthd.is_a?(UnboundMethod)
    mthd.super_method
  else
    Undef
  end
end

#valueObject

Gets an ASTree object representing the method body invoked by this call to super. Undef may be returned if the method is not found.



240
241
242
243
244
245
246
247
# File 'lib/yadriggy/ast_value.rb', line 240

def value()
  mth = invoked_method
  if mth == Undef
    Undef
  else
    root.reify(mth) || Undef
  end
end