]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.cpp
Unlink declarations on destruction
[libs/gl.git] / source / glsl / syntax.cpp
index 957b49cea61a149fc213f9dbe71ecc9fa9774d1b..bda0dd1d7b2a0d673bcea91fc1fdbab23307ce37 100644 (file)
@@ -73,7 +73,15 @@ Statement::Statement():
 
 
 Block::Block():
-       use_braces(false)
+       use_braces(false),
+       parent(0)
+{ }
+
+Block::Block(const Block &other):
+       Node(other),
+       body(other.body),
+       use_braces(other.use_braces),
+       parent(0)
 { }
 
 void Block::visit(NodeVisitor &visitor)
@@ -109,6 +117,21 @@ void VariableReference::visit(NodeVisitor &visitor)
 }
 
 
+InterfaceBlockReference::InterfaceBlockReference():
+       declaration(0)
+{ }
+
+InterfaceBlockReference::InterfaceBlockReference(const InterfaceBlockReference &other):
+       name(other.name),
+       declaration(0)
+{ }
+
+void InterfaceBlockReference::visit(NodeVisitor &visitor)
+{
+       visitor.visit(*this);
+}
+
+
 MemberAccess::MemberAccess():
        declaration(0)
 { }
@@ -239,6 +262,12 @@ VariableDeclaration::VariableDeclaration(const VariableDeclaration &other):
        layout(other.layout)
 { }
 
+VariableDeclaration::~VariableDeclaration()
+{
+       if(linked_declaration && linked_declaration->linked_declaration==this)
+               linked_declaration->linked_declaration = 0;
+}
+
 void VariableDeclaration::visit(NodeVisitor &visitor)
 {
        visitor.visit(*this);
@@ -246,11 +275,27 @@ void VariableDeclaration::visit(NodeVisitor &visitor)
 
 
 InterfaceBlock::InterfaceBlock():
-       array(false)
+       array(false),
+       linked_block(0)
 {
        members.use_braces = true;
 }
 
+InterfaceBlock::InterfaceBlock(const InterfaceBlock &other):
+       interface(other.interface),
+       name(other.name),
+       members(other.members),
+       instance_name(other.instance_name),
+       array(other.array),
+       linked_block(0)
+{ }
+
+InterfaceBlock::~InterfaceBlock()
+{
+       if(linked_block && linked_block->linked_block==this)
+               linked_block->linked_block = 0;
+}
+
 void InterfaceBlock::visit(NodeVisitor &visitor)
 {
        visitor.visit(*this);