Esempio n. 1
0
  def __init__(self, tree):
    self.children = [[], []]
    # self.children is of length 2:
    # 0. List of length 1 or 2.
    #    If length 1, it is just an ASTIdentifiers.
    #    If length 2, the first is an arbitrary expression and the second is an
    #    identifier (a field access of the first).
    #    e.g.:
    #      (i.j).k => [Expression for "(i.j)", Expression for "k"]
    # 1. List of argument expressions (possibly empty)
    if tree.children[0].value == 'Identifiers':
      self.children[0] = [ASTExpression.get_expr_node(tree.children[0])]
      if tree.children[2].value == 'ArgumentList':
        self.children[1] = ASTUtils.get_arg_list(tree.children[2])
    else:
      prefix_exprs = [ASTExpression.get_expr_node(tree.children[0]),
                      ASTExpression.get_expr_node(tree.children[2])]

      arg_list = []
      if tree.children[4].value == 'ArgumentList':
        arg_list = ASTUtils.get_arg_list(tree.children[4])

      self.children = [prefix_exprs, arg_list]

    super(ASTMethodInvocation, self).__init__()
Esempio n. 2
0
  def __init__(self, tree):
    # Children is of length 2:
    # 0. ASTType corresponding to class type.
    # 1. List of arguments (possibly empty).
    self.children = [ASTType(tree.children[1].children[0]), []]

    if tree.children[3].value == 'ArgumentList':
      self.children[1] = ASTUtils.get_arg_list(tree.children[3])

    super(ASTClassInstanceCreation, self).__init__()