public static Statement generate(Context context, Object o) {
if (o instanceof VariableReference) {
return context.getVariable(((VariableReference) o).getName());
}
else if (o instanceof Variable) {
Variable v = (Variable) o;
if (context.isScoped(v)) {
return v.getReference();
}
else {
throw new OutOfScopeException("variable cannot be referenced from this scope: " + v.getName());
}
}
else if (o instanceof Statement) {
((Statement) o).generate(context);
return (Statement) o;