Class: Node

Inherits:
Object
  • Object
show all
Defined in:
lib/decompiler/node/as_code.rb,
lib/decompiler/node/as_expression.rb,
lib/decompiler/method/signature/node.rb

Direct Known Subclasses

ARGSCAT, ARRAY, BLOCK, ZARRAY

Defined Under Namespace

Classes: ARGSCAT, ARRAY, BLOCK, BMETHOD, METHOD, SCOPE, ZARRAY

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define_code(klass, &block) ⇒ Object



26
27
28
29
30
# File 'lib/decompiler/node/as_code.rb', line 26

def define_code(klass, &block)
  if const_defined?(klass) then
    const_get(klass).instance_eval { define_method(:as_code_impl, &block) }
  end
end

.define_expression(klass, &block) ⇒ Object



34
35
36
37
38
# File 'lib/decompiler/node/as_expression.rb', line 34

def define_expression(klass, &block)
  if const_defined?(klass) then
    const_get(klass).instance_eval { define_method(:as_expression_impl, &block) }
  end
end

Instance Method Details

#as_code(indent = 0, *args) ⇒ Object



9
10
11
# File 'lib/decompiler/node/as_code.rb', line 9

def as_code(indent=0, *args)
  return as_code_impl(self, indent, *args)
end

#as_expression(*args) ⇒ Object

Return an string describing this node as a single expression. By default, this just returns the name of the node’s type, but some node types override this method to produce more meaningful output.



11
12
13
# File 'lib/decompiler/node/as_expression.rb', line 11

def as_expression(*args)
  return as_expression_impl(self, *args)
end

#as_paren_expression(*args) ⇒ Object

Return a string as with as_expression, but surround it with parens if it is a composite expression, so that it can be used to form more complex expressions.



18
19
20
21
22
23
24
# File 'lib/decompiler/node/as_expression.rb', line 18

def as_paren_expression(*args)
  expr = self.as_expression(*args)
  if not OMIT_PARENS[self.class] then
    expr = "(#{expr})"
  end
  return expr
end