javatreetree-nodes

Type Passing / Changing


public abstract class ASTNode3 extends ASTNode {

    ASTNode child1;
    ASTNode child2;
    ASTNode child3;

    public ASTNode3(ASTNode c1, ASTNode c2, ASTNode c3) {
    child1 = c1;
    child2 = c2;
    child3 = c3;
    }

    public ASTNode getChild1() {
    return child1;
    }

    public ASTNode getChild2() {
    return child2;
    }

    public ASTNode getChild3() {
    return child3;
    }
}

public class IRProc extends ASTNode3 {

    public IRProc (String p, Vector v, IRCmdSeq cmds) {
    super(p,v,cmds);
    }

I extended the ASTNode as shown below, but when i try to pass in a Vector and a String as arguments I keep getting errors. How can I pass in these values without affecting the node. I was thinking of creating an intermediate class that handle the type, but i don't know how to.


Solution

  • In the line

    super(p,v,cmds);
    

    you try to call the constructor ASTNode3(ASTNode c1, ASTNode c2, ASTNode c3) with the arguments String p, Vector v, IRCmdSeq cmds. This doesn't match.

    You have to create instances of ASTNode to call super(). How you do this depends on what you want to do. Perhaps you should explain what kind of information p, v and cmds actually contain.