namespace SL {
Formatter::Formatter():
+ stage(0),
+ mode(Compiler::PROGRAM),
source_index(0),
source_line(1),
indent(0),
parameter_list(false)
{ }
-void Formatter::apply(Stage &s)
+const string &Formatter::apply(Stage &s, Compiler::Mode m)
{
+ mode = m;
+ stage = &s;
+
GLApi api = get_gl_api();
const Version &ver = s.required_version;
if(!s.required_extensions.empty())
formatted += '\n';
- StageVisitor::apply(s);
+ visit(s.content);
+
+ return formatted;
}
void Formatter::append(const string &text)
else
{
unsigned l = line;
- if(stage->required_version<Version(3, 30))
+ if(mode==Compiler::PROGRAM && stage && stage->required_version<Version(3, 30))
--l;
formatted += format("#line %d %d\n", l, index);
}
if(!var.interface.empty() && var.interface!=block_interface)
{
string interface = var.interface;
- if(stage->required_version<Version(1, 30))
+ if(mode==Compiler::PROGRAM && stage && stage->required_version<Version(1, 30))
{
if(stage->type==Stage::VERTEX && var.interface=="in")
interface = "attribute";