diff --git a/src/libs/glsl/glslsemantic.cpp b/src/libs/glsl/glslsemantic.cpp index f550d642e3c..4469acca8e5 100644 --- a/src/libs/glsl/glslsemantic.cpp +++ b/src/libs/glsl/glslsemantic.cpp @@ -28,10 +28,13 @@ **************************************************************************/ #include "glslsemantic.h" +#include "glslengine.h" using namespace GLSL; -Semantic::Semantic() +Semantic::Semantic(Engine *engine) + : _engine(engine) + , _type(0) { } @@ -49,9 +52,13 @@ void Semantic::statement(StatementAST *ast) accept(ast); } -void Semantic::type(TypeAST *ast) +const Type *Semantic::type(TypeAST *ast) { + const Type *t = _engine->undefinedType(); + std::swap(_type, t); accept(ast); + std::swap(_type, t); + return t; } void Semantic::declaration(DeclarationAST *ast) @@ -86,14 +93,16 @@ bool Semantic::visit(TranslationUnitAST *ast) bool Semantic::visit(FunctionIdentifierAST *ast) { // ast->name - type(ast->type); + const Type *ty = type(ast->type); + Q_UNUSED(ty); return false; } bool Semantic::visit(StructTypeAST::Field *ast) { // ast->name - type(ast->type); + const Type *ty = type(ast->type); + Q_UNUSED(ty); return false; } @@ -160,7 +169,8 @@ bool Semantic::visit(FunctionCallExpressionAST *ast) bool Semantic::visit(DeclarationExpressionAST *ast) { - type(ast->type); + const Type *ty = type(ast->type); + Q_UNUSED(ty); // ast->name expression(ast->initializer); return false; @@ -264,7 +274,8 @@ bool Semantic::visit(NamedTypeAST *ast) bool Semantic::visit(ArrayTypeAST *ast) { - type(ast->elementType); + const Type *elementType = type(ast->elementType); + Q_UNUSED(elementType); expression(ast->size); return false; } @@ -295,26 +306,30 @@ bool Semantic::visit(QualifiedTypeAST *ast) // declarations bool Semantic::visit(PrecisionDeclarationAST *ast) { - type(ast->type); + const Type *ty = type(ast->type); + Q_UNUSED(ty); return false; } bool Semantic::visit(ParameterDeclarationAST *ast) { - type(ast->type); + const Type *ty = type(ast->type); + Q_UNUSED(ty); return false; } bool Semantic::visit(VariableDeclarationAST *ast) { - type(ast->type); + const Type *ty = type(ast->type); + Q_UNUSED(ty); expression(ast->initializer); return false; } bool Semantic::visit(TypeDeclarationAST *ast) { - type(ast->type); + const Type *ty = type(ast->type); + Q_UNUSED(ty); return false; } @@ -342,7 +357,8 @@ bool Semantic::visit(InitDeclarationAST *ast) bool Semantic::visit(FunctionDeclarationAST *ast) { - type(ast->returnType); + const Type *returnType = type(ast->returnType); + Q_UNUSED(returnType); for (List *it = ast->params; it; it = it->next) { ParameterDeclarationAST *decl = it->value; declaration(decl); diff --git a/src/libs/glsl/glslsemantic.h b/src/libs/glsl/glslsemantic.h index 5e4386e0fea..fdbcdc3978a 100644 --- a/src/libs/glsl/glslsemantic.h +++ b/src/libs/glsl/glslsemantic.h @@ -36,12 +36,12 @@ namespace GLSL { class GLSL_EXPORT Semantic: protected Visitor { public: - Semantic(); + Semantic(Engine *engine); virtual ~Semantic(); void expression(ExpressionAST *ast); void statement(StatementAST *ast); - void type(TypeAST *ast); + const Type *type(TypeAST *ast); void declaration(DeclarationAST *ast); void translationUnit(TranslationUnitAST *ast); void functionIdentifier(FunctionIdentifierAST *ast); @@ -92,6 +92,10 @@ protected: virtual bool visit(InvariantDeclarationAST *ast); virtual bool visit(InitDeclarationAST *ast); virtual bool visit(FunctionDeclarationAST *ast); + +private: + Engine *_engine; + const Type *_type; }; } // namespace GLSL