X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fsyntax.cpp;h=502c274810074c00b488711e55cae6e15ae29c7c;hb=c4aeeced7b397d46772577775bd3a0d6c4706cba;hp=e7a3990e5c1478b3fcdf8e5727226b05ba688582;hpb=22d5405729048ee2677a1e45e309e6328de64a26;p=libs%2Fgl.git diff --git a/source/glsl/syntax.cpp b/source/glsl/syntax.cpp index e7a3990e..502c2748 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) { } @@ -369,7 +374,7 @@ InterfaceBlock::InterfaceBlock(): InterfaceBlock::InterfaceBlock(const InterfaceBlock &other): Statement(other), interface(other.interface), - name(other.name), + block_name(other.block_name), members(other.members), instance_name(other.instance_name), array(other.array), @@ -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