append("#extension ext_texture_array: require\n");
formatted += '\n';
- visit(s.content);
+ s.content.visit(*this);
return formatted;
}
source_line = line;
}
+void Formatter::visit(Block &block)
+{
+ unsigned brace_indent = indent;
+ bool use_braces = (block.use_braces || (indent && block.body.size()!=1));
+ if(use_braces)
+ append(format("%s{\n", string(brace_indent*2, ' ')));
+
+ SetForScope<unsigned> set(indent, indent+(indent>0 || use_braces));
+ string spaces(indent*2, ' ');
+ bool first = true;
+ for(NodeList<Statement>::iterator i=block.body.begin(); i!=block.body.end(); ++i)
+ {
+ if((*i)->source==BUILTIN_SOURCE)
+ continue;
+ if(!first)
+ append('\n');
+ first = false;
+ set_source((*i)->source, (*i)->line);
+ append(spaces);
+ (*i)->visit(*this);
+ }
+
+ if(use_braces)
+ append(format("\n%s}", string(brace_indent*2, ' ')));
+}
+
void Formatter::visit(Literal &literal)
{
append(literal.token);
append(var.name);
}
+void Formatter::visit(InterfaceBlockReference &iface)
+{
+ append(iface.name);
+}
+
void Formatter::visit(MemberAccess &memacc)
{
memacc.left->visit(*this);
void Formatter::visit(UnaryExpression &unary)
{
- if(unary.prefix)
- append(unary.oper);
+ if(unary.oper->type==Operator::PREFIX)
+ append(unary.oper->token);
unary.expression->visit(*this);
- if(!unary.prefix)
- append(unary.oper);
+ if(unary.oper->type==Operator::POSTFIX)
+ append(unary.oper->token);
}
void Formatter::visit(BinaryExpression &binary)
{
binary.left->visit(*this);
- append(binary.oper);
+ append(binary.oper->token);
binary.right->visit(*this);
- append(binary.after);
+ if(binary.oper->token[0]=='[')
+ append(']');
}
void Formatter::visit(Assignment &assign)
{
assign.left->visit(*this);
- append(format(" %s ", assign.oper));
+ append(format(" %s ", assign.oper->token));
assign.right->visit(*this);
}
append(';');
}
-void Formatter::visit(Block &block)
-{
- unsigned brace_indent = indent;
- bool use_braces = (block.use_braces || (indent && block.body.size()!=1));
- if(use_braces)
- append(format("%s{\n", string(brace_indent*2, ' ')));
-
- SetForScope<unsigned> set(indent, indent+(indent>0 || use_braces));
- string spaces(indent*2, ' ');
- for(NodeList<Statement>::iterator i=block.body.begin(); i!=block.body.end(); ++i)
- {
- if(i!=block.body.begin())
- append('\n');
- set_source((*i)->source, (*i)->line);
- append(spaces);
- (*i)->visit(*this);
- }
-
- if(use_braces)
- append(format("\n%s}", string(brace_indent*2, ' ')));
-}
-
void Formatter::visit(Import &import)
{
append(format("import %s;", import.module));
{
if(i!=layout.qualifiers.begin())
append(", ");
- append(i->identifier);
- if(!i->value.empty())
- append(format("=%s", i->value));
+ append(i->name);
+ if(i->has_value)
+ append(format("=%d", i->value));
}
append(')');
}
SetForScope<string> set(block_interface, iface.interface);
append(format("%s %s\n", iface.interface, iface.name));
iface.members.visit(*this);
+ if(!iface.instance_name.empty())
+ {
+ append(' ');
+ append(iface.instance_name);
+ if(iface.array)
+ append("[]");
+ }
append(';');
}
}
}
+void Formatter::visit(Passthrough &pass)
+{
+ append("passthrough");
+ if(pass.subscript)
+ {
+ append('[');
+ pass.subscript->visit(*this);
+ append(']');
+ }
+ append(';');
+}
+
void Formatter::visit(Return &ret)
{
append("return");