package carray.ast;

import polyglot.ast.Ext;
import polyglot.ast.ExtFactory;

/**
 * This class defines extension factory methods specifically for carray
 * extension (and not for extensions of carray).
 */
public final class CArrayExtFactory_c extends CArrayAbstractExtFactory_c {

    public CArrayExtFactory_c() {
        super();
    }

    public CArrayExtFactory_c(ExtFactory nextExtFactory) {
        super(nextExtFactory);
    }

    @Override
    protected Ext extNodeImpl() {
        // Return a default extension object for this extension, which simply
        // forward any operation to the base language.
        return new CArrayExt();
    }

    @Override
    protected Ext extArrayAccessAssignImpl() {
        // We want to override some operations for ArrayAccessAssign, so
        // return an extension object specific to carray.
        return new CArrayArrayAccessAssignExt();
    }

    @Override
    protected Ext extArrayInitImpl() {
        // We want to remove top-level ArrayInit nodes before translation, so
        // return an extension object specific to carray that defines the
        // removal procedure.
        return new CArrayArrayInitExt();
    }

    @Override
    protected Ext extNewArrayImpl() {
        return new CArrayNewArrayExt();
    }

    // The following factory methods are for translating CArray features.

    @Override
    protected Ext extArrayAccessImpl() {
        return new CArrayArrayAccessExt();
    }

    @Override
    protected Ext extSourceFileImpl() {
        return new CArraySourceFileExt();
    }
}
