Search in sources :

Example 1 with Part

use of gov.sandia.n2a.backend.internal.Part in project n2a by frothga.

the class Instance method resolve.

public void resolve(TreeSet<VariableReference> references) {
    for (VariableReference r : references) {
        Instance result = this;
        Object last = r.resolution.get(r.resolution.size() - 1);
        for (Object o : r.resolution) {
            result = ((Resolver) o).resolve(result);
            if (// Resolution is done and this is a global variable.
            o == last && r.variable.global) {
                if (result instanceof Part) {
                    // Need to locate our population.
                    InternalBackendData bed = (InternalBackendData) result.equations.backendData;
                    result = (Instance) result.container.valuesObject[bed.populationIndex];
                }
            } else {
                if (result instanceof Population) {
                    // Need to drill down to an instance of the population.
                    // This is only possible with a singleton.
                    InternalBackendData bed = (InternalBackendData) result.equations.backendData;
                    if (!bed.singleton) {
                        Backend.err.get().println("ERROR: Ambiguous reference to " + result.equations.prefix());
                        throw new Backend.AbortRun();
                    }
                    result = (Instance) result.valuesObject[bed.instances];
                }
            }
        }
        valuesObject[r.index] = result;
    }
}
Also used : VariableReference(gov.sandia.n2a.eqset.VariableReference) Part(gov.sandia.n2a.backend.internal.Part) Population(gov.sandia.n2a.backend.internal.Population) InternalBackendData(gov.sandia.n2a.backend.internal.InternalBackendData)

Aggregations

InternalBackendData (gov.sandia.n2a.backend.internal.InternalBackendData)1 Part (gov.sandia.n2a.backend.internal.Part)1 Population (gov.sandia.n2a.backend.internal.Population)1 VariableReference (gov.sandia.n2a.eqset.VariableReference)1