Files
qt-creator/src/libs/glsl/glslsemantic.h

129 lines
4.5 KiB
C
Raw Normal View History

/****************************************************************************
2010-11-25 10:29:57 +01:00
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
2010-11-25 10:29:57 +01:00
**
** This file is part of Qt Creator.
2010-11-25 10:29:57 +01:00
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
2010-11-25 10:29:57 +01:00
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
2010-12-17 17:14:20 +01:00
**
****************************************************************************/
2011-04-13 08:42:33 +02:00
#pragma once
2010-11-25 10:29:57 +01:00
#include "glslastvisitor.h"
#include "glsltype.h"
2010-11-25 10:29:57 +01:00
namespace GLSL {
class GLSL_EXPORT Semantic: protected Visitor
{
public:
2010-11-26 15:00:46 +01:00
Semantic();
~Semantic() override;
2010-11-25 10:29:57 +01:00
2010-11-26 12:08:43 +01:00
struct ExprResult {
ExprResult(const Type *type = 0, bool isConstant = false)
: type(type), isConstant(isConstant) {}
~ExprResult() { }
bool isValid() const {
if (! type)
return false;
else if (type->asUndefinedType() != 0)
return false;
return true;
}
explicit operator bool() const { return isValid(); }
2010-11-26 12:08:43 +01:00
const Type *type;
bool isConstant;
};
2010-11-26 15:00:46 +01:00
void translationUnit(TranslationUnitAST *ast, Scope *globalScope, Engine *engine);
ExprResult expression(ExpressionAST *ast, Scope *scope, Engine *engine);
2010-11-26 15:00:46 +01:00
protected:
Engine *switchEngine(Engine *engine);
Scope *switchScope(Scope *scope);
2010-11-30 16:10:07 +01:00
bool implicitCast(const Type *type, const Type *target) const;
2010-11-26 12:08:43 +01:00
ExprResult expression(ExpressionAST *ast);
void statement(StatementAST *ast);
2010-11-25 13:06:41 +01:00
const Type *type(TypeAST *ast);
void declaration(DeclarationAST *ast);
ExprResult functionIdentifier(FunctionIdentifierAST *ast);
2010-11-25 14:55:43 +01:00
Symbol *field(StructTypeAST::Field *ast);
void parameterDeclaration(ParameterDeclarationAST *ast, Function *fun);
2010-11-25 10:29:57 +01:00
bool visit(TranslationUnitAST *ast) override;
bool visit(FunctionIdentifierAST *ast) override;
bool visit(StructTypeAST::Field *ast) override;
2010-11-25 10:29:57 +01:00
// expressions
bool visit(IdentifierExpressionAST *ast) override;
bool visit(LiteralExpressionAST *ast) override;
bool visit(BinaryExpressionAST *ast) override;
bool visit(UnaryExpressionAST *ast) override;
bool visit(TernaryExpressionAST *ast) override;
bool visit(AssignmentExpressionAST *ast) override;
bool visit(MemberAccessExpressionAST *ast) override;
bool visit(FunctionCallExpressionAST *ast) override;
bool visit(DeclarationExpressionAST *ast) override;
2010-11-25 10:29:57 +01:00
// statements
bool visit(ExpressionStatementAST *ast) override;
bool visit(CompoundStatementAST *ast) override;
bool visit(IfStatementAST *ast) override;
bool visit(WhileStatementAST *ast) override;
bool visit(DoStatementAST *ast) override;
bool visit(ForStatementAST *ast) override;
bool visit(JumpStatementAST *ast) override;
bool visit(ReturnStatementAST *ast) override;
bool visit(SwitchStatementAST *ast) override;
bool visit(CaseLabelStatementAST *ast) override;
bool visit(DeclarationStatementAST *ast) override;
2010-11-25 10:29:57 +01:00
// types
bool visit(BasicTypeAST *ast) override;
bool visit(NamedTypeAST *ast) override;
bool visit(ArrayTypeAST *ast) override;
bool visit(StructTypeAST *ast) override;
bool visit(QualifiedTypeAST *ast) override;
2010-11-25 10:29:57 +01:00
// declarations
bool visit(PrecisionDeclarationAST *ast) override;
bool visit(ParameterDeclarationAST *ast) override;
bool visit(VariableDeclarationAST *ast) override;
bool visit(TypeDeclarationAST *ast) override;
bool visit(TypeAndVariableDeclarationAST *ast) override;
bool visit(InvariantDeclarationAST *ast) override;
bool visit(InitDeclarationAST *ast) override;
bool visit(FunctionDeclarationAST *ast) override;
2010-11-25 13:06:41 +01:00
private:
Engine *_engine;
2010-11-25 14:55:43 +01:00
Scope *_scope;
2010-11-26 12:08:43 +01:00
const Type *_type;
ExprResult _expr;
2010-11-25 10:29:57 +01:00
};
} // namespace GLSL