summaryrefslogtreecommitdiff
path: root/src/main/java/io/devnulllabs/openjava/ptree/ConstructorInvocation.java
blob: 539142ed836fe261bd71ec99fd30767faa38397c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * ConstructorInvocation.java 1.0
 *
 * Jun 20, 1997 mich
 * Sep 29, 1997 bv
 * Oct 11, 1997 mich
 *
 * @see io.devnulllabs.openjava.ptree.ParseTree
 * @version 1.0 last updated:  Oct 11, 1997
 * @author  Michiaki Tatsubori
 */
package io.devnulllabs.openjava.ptree;

import io.devnulllabs.openjava.ptree.util.ParseTreeVisitor;

/**
 * The ConstructorInvocation class presents expression statement node
 * of parse tree
 *
 * @see io.devnulllabs.openjava.ptree.ParseTree
 * @see io.devnulllabs.openjava.ptree.NonLeaf
 * @see io.devnulllabs.openjava.ptree.Statement
 * @see io.devnulllabs.openjava.ptree.ExpressionList
 */
public class ConstructorInvocation extends NonLeaf {

    private boolean _isSelfInvocation = true;

    /**
     * Constructs a new constructor invocation.
     * i.e. <code>this(..)</code>
     *
     * @param exprs arguments for this constructor invocation
     */
    public ConstructorInvocation(ExpressionList exprs) {
        super();
        this._isSelfInvocation = true;
        if (exprs == null)
            exprs = new ExpressionList();
        set(exprs);
    }

    /**
     * Constructs a new constructor invocation.
     * i.e. <code>super(..)</code>
     *
     * @param exprs arguments for this constructor invocation
     * @param enclosing outerclass qualifier.
     */
    public ConstructorInvocation(ExpressionList exprs, Expression enclosing) {
        super();
        this._isSelfInvocation = false;
        if (exprs == null)
            exprs = new ExpressionList();
        set(exprs, enclosing);
    }

    ConstructorInvocation() {
        super();
    }

    /*********need modification for copy******/

    public boolean isSelfInvocation() {
        return _isSelfInvocation;
    }

    /**
     * Gets the expressions as arguments for this invocation.
     *
     * @return  the expressions.
     */
    public ExpressionList getArguments() {
        return (ExpressionList) elementAt(0);
    }

    public Expression getEnclosing() {
        return (Expression) elementAt(1);
    }

    public void accept(ParseTreeVisitor v) throws ParseTreeException {
        v.visit(this);
    }

}