Programming-Language-Design / src / ast / definition / classes / FuncDefinition.java
FuncDefinition.java
Raw
package ast.definition.classes;

import ast.definition.AbstractDefinition;
import ast.statement.Statement;
import ast.type.Type;
import visitor.Visitor;

import java.util.ArrayList;
import java.util.List;

public class FuncDefinition extends AbstractDefinition {
    List<Statement> functionStmts;

    public FuncDefinition(int line, int column, String name, Type type, List<Statement> functionStmts) {
        super(line, column, name, type);
        this.functionStmts = new ArrayList<>(functionStmts);
    }

    public List<Statement> getFunctionStmts() {
        return functionStmts;
    }

    @Override
    public String toString() {
        return getName() + " " + getType() + "{ " + getFunctionStmts() + "}";
    }

    @Override
    public <TP, TR> TR accept(Visitor<TP, TR> v, TP param) {
        return v.visit(this, param);
    }
}