Class: Yadriggy::VariableCall
- Inherits:
-
IdentifierOrCall
- Object
- ASTnode
- Name
- IdentifierOrCall
- Yadriggy::VariableCall
- Defined in:
- lib/yadriggy/ast.rb,
lib/yadriggy/ast_value.rb
Overview
Method call without parentheses or arguments.
Instance Attribute Summary
Attributes inherited from Name
Attributes inherited from ASTnode
Class Method Summary collapse
Instance Method Summary collapse
-
#accept(evaluator) ⇒ void
A method for Visitor pattern.
-
#const_value ⇒ Object
Returns Undef because const_value is supposed to return the resulting value of executing this variable call.
-
#do_invocation ⇒ Object
Gets the resulting value of the invocation of this method.
-
#initialize(sexp) ⇒ VariableCall
constructor
A new instance of VariableCall.
-
#invoked_method ⇒ Object
Gets a Method object called by this AST node.
-
#value ⇒ Object
Gets an ASTree object representing the method body invoked by this AST node.
Methods inherited from Name
Methods inherited from ASTnode
#add_child, #add_children, #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) ⇒ VariableCall
Returns a new instance of VariableCall.
219 220 221 |
# File 'lib/yadriggy/ast.rb', line 219 def initialize(sexp) super(sexp[1]) end |
Class Method Details
.tag ⇒ Object
217 |
# File 'lib/yadriggy/ast.rb', line 217 def self.tag() :vcall end |
Instance Method Details
#accept(evaluator) ⇒ void
This method returns an undefined value.
A method for Visitor pattern.
226 227 228 |
# File 'lib/yadriggy/ast.rb', line 226 def accept(evaluator) evaluator.variable_call(self) end |
#const_value ⇒ Object
Returns Undef because const_value is supposed to return the resulting value of executing this variable call.
98 |
# File 'lib/yadriggy/ast_value.rb', line 98 def const_value() Undef end |
#do_invocation ⇒ Object
Gets the resulting value of the invocation of this method.
119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/yadriggy/ast_value.rb', line 119 def do_invocation() obj = get_receiver_object if obj.nil? Undef else begin obj.send(@name) rescue NameError Undef end end end |
#invoked_method ⇒ Object
Gets a Method object called by this AST node. If this AST node belongs to UnboundMethod, Undef will be returned.
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/yadriggy/ast_value.rb', line 104 def invoked_method() obj = get_receiver_object if obj.nil? Undef else begin obj.method(@name) rescue NameError Undef end end end |
#value ⇒ Object
Gets an ASTree object representing the method body invoked by this AST node. Undef may be returned if the method is not found.
86 87 88 89 90 91 92 93 |
# File 'lib/yadriggy/ast_value.rb', line 86 def value() mth = invoked_method if mth == Undef Undef else root.reify(mth) || Undef end end |