X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Fsyntax.cpp;h=bb8d7dab046f2ea1293927d93aa3e415818e12d4;hp=32a7b12c6639aebd69344aa7a2f6408c67de308f;hb=b7ecc29c204faede028556d1942b2d61d5cda9ee;hpb=d8bdf61007978e2c3670a22a58e2f105e8347537 diff --git a/source/glsl/syntax.cpp b/source/glsl/syntax.cpp index 32a7b12c..bb8d7dab 100644 --- a/source/glsl/syntax.cpp +++ b/source/glsl/syntax.cpp @@ -1,3 +1,4 @@ +#include #include #include "syntax.h" #include "visitor.h" @@ -69,8 +70,8 @@ template NodeContainer::NodeContainer(const NodeContainer &c): C(c) { - for(typename C::iterator i=this->begin(); i!=this->end(); ++i) - *i = (*i)->clone(); + for(auto &i: *this) + i = i->clone(); } @@ -138,14 +139,16 @@ void InterfaceBlockReference::visit(NodeVisitor &visitor) MemberAccess::MemberAccess(): - declaration(0) + declaration(0), + index(-1) { } MemberAccess::MemberAccess(const MemberAccess &other): Expression(other), left(other.left), member(other.member), - declaration(0) + declaration(0), + index(-1) { } void MemberAccess::visit(NodeVisitor &visitor) @@ -269,6 +272,7 @@ void InterfaceLayout::visit(NodeVisitor &visitor) BasicTypeDeclaration::BasicTypeDeclaration(): kind(ALIAS), size(0), + sign(true), base_type(0) { } @@ -276,6 +280,7 @@ BasicTypeDeclaration::BasicTypeDeclaration(const BasicTypeDeclaration &other): TypeDeclaration(other), kind(other.kind), size(other.size), + sign(other.sign), base(other.base), base_type(0) { } @@ -455,7 +460,7 @@ Stage::Stage(Stage::Type t): const char *Stage::get_stage_name(Type type) { - static const char *names[] = { "shared", "vertex", "geometry", "fragment" }; + static const char *const names[] = { "shared", "vertex", "geometry", "fragment" }; return names[type]; } @@ -485,6 +490,19 @@ string get_unused_variable_name(const Block &block, const string &base) } } +int get_layout_value(const Layout &layout, const string &name, int def_value) +{ + auto i = find_member(layout.qualifiers, name, &Layout::Qualifier::name); + return (i!=layout.qualifiers.end() ? i->value : def_value); +} + +void add_to_chain(Assignment::Target &target, Assignment::Target::ChainType type, unsigned index) +{ + if(target.chain_len<7) + target.chain[target.chain_len] = type | min(index, 0x3F); + ++target.chain_len; +} + } // namespace SL } // namespace GL } // namespace Msp