use of gov.sandia.n2a.language.Renderer in project n2a by frothga.
the class EquationEntry method toString.
@Override
public String toString() {
Renderer renderer = new Renderer();
render(renderer);
return renderer.result.toString();
}
use of gov.sandia.n2a.language.Renderer in project n2a by frothga.
the class EquationSet method dump.
public String dump(boolean showNamespace, String prefix) {
Renderer renderer;
if (showNamespace) {
class Prefixer extends Renderer {
public boolean render(Operator op) {
if (!(op instanceof AccessVariable))
return false;
AccessVariable av = (AccessVariable) op;
if (av.reference == null || av.reference.variable == null) {
result.append("<unresolved!>" + av.name);
} else {
result.append("<" + av.reference.variable.container.prefix() + ">" + av.reference.variable.nameString());
}
return true;
}
}
renderer = new Prefixer();
} else {
renderer = new Renderer();
}
renderer.result.append(prefix + name + "\n");
prefix = prefix + " ";
if (connectionBindings != null) {
for (ConnectionBinding c : connectionBindings) {
renderer.result.append(prefix + c.alias + " = ");
EquationSet s = c.endpoint;
if (showNamespace) {
renderer.result.append("<");
if (s.container != null) {
renderer.result.append(s.container.prefix());
}
renderer.result.append(">");
}
renderer.result.append(s.name + "\n");
}
}
for (Variable v : variables) {
if (// If no equations, then this is an implicit variable, so no need to list here.
v.equations.size() > 0) {
renderer.result.append(prefix + v.nameString());
renderer.result.append(" =" + v.combinerString());
if (v.equations.size() == 1) {
renderer.result.append(" ");
v.equations.first().render(renderer);
renderer.result.append("\n");
} else {
renderer.result.append("\n");
for (EquationEntry e : v.equations) {
renderer.result.append(prefix + " ");
e.render(renderer);
renderer.result.append("\n");
}
}
}
}
for (EquationSet e : parts) {
renderer.result.append(e.dump(showNamespace, prefix));
}
return renderer.result.toString();
}
Aggregations