]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.cpp
Further refactor block and scope management
[libs/gl.git] / source / glsl / syntax.cpp
index e508ed890c0ddc5a35c0180acdde11f7675d5f8e..0b9ecb54ca9d0aef569b9ebc4fe7477ec8202415 100644 (file)
@@ -73,7 +73,17 @@ Statement::Statement():
 
 
 Block::Block():
-       use_braces(false)
+       use_braces(false),
+       anonymous(false),
+       parent(0)
+{ }
+
+Block::Block(const Block &other):
+       Node(other),
+       body(other.body),
+       use_braces(other.use_braces),
+       anonymous(other.anonymous),
+       parent(0)
 { }
 
 void Block::visit(NodeVisitor &visitor)
@@ -98,12 +108,27 @@ VariableReference::VariableReference():
        declaration(0)
 { }
 
+VariableReference::VariableReference(const VariableReference &other):
+       name(other.name),
+       declaration(0)
+{ }
+
 void VariableReference::visit(NodeVisitor &visitor)
 {
        visitor.visit(*this);
 }
 
 
+MemberAccess::MemberAccess():
+       declaration(0)
+{ }
+
+MemberAccess::MemberAccess(const MemberAccess &other):
+       left(other.left),
+       member(other.member),
+       declaration(0)
+{ }
+
 void MemberAccess::visit(NodeVisitor &visitor)
 {
        visitor.visit(*this);
@@ -131,6 +156,11 @@ Assignment::Assignment():
        target_declaration(0)
 { }
 
+Assignment::Assignment(const Assignment &other):
+       self_referencing(other.self_referencing),
+       target_declaration(0)
+{ }
+
 void Assignment::visit(NodeVisitor &visitor)
 {
        visitor.visit(*this);
@@ -142,6 +172,13 @@ FunctionCall::FunctionCall():
        constructor(false)
 { }
 
+FunctionCall::FunctionCall(const FunctionCall &other):
+       name(other.name),
+       declaration(0),
+       constructor(other.constructor),
+       arguments(other.arguments)
+{ }
+
 void FunctionCall::visit(NodeVisitor &visitor)
 {
        visitor.visit(*this);
@@ -196,6 +233,22 @@ VariableDeclaration::VariableDeclaration():
        linked_declaration(0)
 { }
 
+VariableDeclaration::VariableDeclaration(const VariableDeclaration &other):
+       constant(other.constant),
+       sampling(other.sampling),
+       interpolation(other.interpolation),
+       interface(other.interface),
+       precision(other.precision),
+       type(other.type),
+       type_declaration(0),
+       name(other.name),
+       array(other.array),
+       array_size(other.array_size),
+       init_expression(other.init_expression),
+       linked_declaration(0),
+       layout(other.layout)
+{ }
+
 void VariableDeclaration::visit(NodeVisitor &visitor)
 {
        visitor.visit(*this);
@@ -222,7 +275,7 @@ FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration &other):
        return_type(other.return_type),
        name(other.name),
        parameters(other.parameters),
-       definition(other.definition==&other ? this : other.definition),
+       definition(other.definition==&other ? this : 0),
        body(other.body)
 { }
 
@@ -262,14 +315,20 @@ void Jump::visit(NodeVisitor &visitor)
 }
 
 
-Stage::Stage(StageType t):
+Stage::Stage(Stage::Type t):
        type(t),
        previous(0)
 { }
 
+const char *Stage::get_stage_name(Type type)
+{
+       static const char *names[] = { "shared", "vertex", "geometry", "fragment" };
+       return names[type];
+}
+
 
 Module::Module():
-       shared(SHARED)
+       shared(Stage::SHARED)
 { }
 
 } // namespace SL