]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programsyntax.cpp
Support layout declarations on variables
[libs/gl.git] / source / programsyntax.cpp
index 6e4d070e2b3e480cd29b09ccabbb7e7ae4194415..c6e0f6d40e9bc9ca97583adf07454af208bcadf9 100644 (file)
@@ -54,17 +54,25 @@ void UnaryExpression::visit(NodeVisitor &visitor)
 }
 
 
-BinaryExpression::BinaryExpression():
-       assignment(false)
+void BinaryExpression::visit(NodeVisitor &visitor)
+{
+       visitor.visit(*this);
+}
+
+
+Assignment::Assignment():
+       self_referencing(false),
+       target_declaration(0)
 { }
 
-void BinaryExpression::visit(NodeVisitor &visitor)
+void Assignment::visit(NodeVisitor &visitor)
 {
        visitor.visit(*this);
 }
 
 
 FunctionCall::FunctionCall():
+       declaration(0),
        constructor(false)
 { }
 
@@ -80,12 +88,24 @@ void ExpressionStatement::visit(NodeVisitor &visitor)
 }
 
 
+void Import::visit(NodeVisitor &visitor)
+{
+       visitor.visit(*this);
+}
+
+
 void Layout::visit(NodeVisitor &visitor)
 {
        visitor.visit(*this);
 }
 
 
+void InterfaceLayout::visit(NodeVisitor &visitor)
+{
+       visitor.visit(*this);
+}
+
+
 StructDeclaration::StructDeclaration()
 {
        members.use_braces = true;
@@ -110,7 +130,8 @@ void VariableDeclaration::visit(NodeVisitor &visitor)
 }
 
 
-InterfaceBlock::InterfaceBlock()
+InterfaceBlock::InterfaceBlock():
+       array(false)
 {
        members.use_braces = true;
 }
@@ -122,7 +143,15 @@ void InterfaceBlock::visit(NodeVisitor &visitor)
 
 
 FunctionDeclaration::FunctionDeclaration():
-       definition(false)
+       definition(0)
+{ }
+
+FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration &other):
+       return_type(other.return_type),
+       name(other.name),
+       parameters(other.parameters),
+       definition(other.definition==&other ? this : other.definition),
+       body(other.body)
 { }
 
 void FunctionDeclaration::visit(NodeVisitor &visitor)
@@ -137,6 +166,12 @@ void Conditional::visit(NodeVisitor &visitor)
 }
 
 
+void Iteration::visit(NodeVisitor &visitor)
+{
+       visitor.visit(*this);
+}
+
+
 void Passthrough::visit(NodeVisitor &visitor)
 {
        visitor.visit(*this);
@@ -149,9 +184,9 @@ void Return::visit(NodeVisitor &visitor)
 }
 
 
-void Iteration::visit(NodeVisitor &visitor)
+void NodeVisitor::visit(Assignment &assign)
 {
-       visitor.visit(*this);
+       visit(static_cast<BinaryExpression &>(assign));
 }
 
 
@@ -193,6 +228,11 @@ void TraversingVisitor::visit(ExpressionStatement &expr)
        expr.expression->visit(*this);
 }
 
+void TraversingVisitor::visit(InterfaceLayout &layout)
+{
+       layout.layout.visit(*this);
+}
+
 void TraversingVisitor::visit(StructDeclaration &strct)
 {
        strct.members.visit(*this);
@@ -200,6 +240,8 @@ void TraversingVisitor::visit(StructDeclaration &strct)
 
 void TraversingVisitor::visit(VariableDeclaration &var)
 {
+       if(var.layout)
+               var.layout->visit(*this);
        if(var.init_expression)
                var.init_expression->visit(*this);
        if(var.array_size)