forked from qt-creator/qt-creator
Get the types from the AST nodes.
This commit is contained in:
@@ -28,10 +28,13 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "glslsemantic.h"
|
#include "glslsemantic.h"
|
||||||
|
#include "glslengine.h"
|
||||||
|
|
||||||
using namespace GLSL;
|
using namespace GLSL;
|
||||||
|
|
||||||
Semantic::Semantic()
|
Semantic::Semantic(Engine *engine)
|
||||||
|
: _engine(engine)
|
||||||
|
, _type(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,9 +52,13 @@ void Semantic::statement(StatementAST *ast)
|
|||||||
accept(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);
|
accept(ast);
|
||||||
|
std::swap(_type, t);
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Semantic::declaration(DeclarationAST *ast)
|
void Semantic::declaration(DeclarationAST *ast)
|
||||||
@@ -86,14 +93,16 @@ bool Semantic::visit(TranslationUnitAST *ast)
|
|||||||
bool Semantic::visit(FunctionIdentifierAST *ast)
|
bool Semantic::visit(FunctionIdentifierAST *ast)
|
||||||
{
|
{
|
||||||
// ast->name
|
// ast->name
|
||||||
type(ast->type);
|
const Type *ty = type(ast->type);
|
||||||
|
Q_UNUSED(ty);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Semantic::visit(StructTypeAST::Field *ast)
|
bool Semantic::visit(StructTypeAST::Field *ast)
|
||||||
{
|
{
|
||||||
// ast->name
|
// ast->name
|
||||||
type(ast->type);
|
const Type *ty = type(ast->type);
|
||||||
|
Q_UNUSED(ty);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +169,8 @@ bool Semantic::visit(FunctionCallExpressionAST *ast)
|
|||||||
|
|
||||||
bool Semantic::visit(DeclarationExpressionAST *ast)
|
bool Semantic::visit(DeclarationExpressionAST *ast)
|
||||||
{
|
{
|
||||||
type(ast->type);
|
const Type *ty = type(ast->type);
|
||||||
|
Q_UNUSED(ty);
|
||||||
// ast->name
|
// ast->name
|
||||||
expression(ast->initializer);
|
expression(ast->initializer);
|
||||||
return false;
|
return false;
|
||||||
@@ -264,7 +274,8 @@ bool Semantic::visit(NamedTypeAST *ast)
|
|||||||
|
|
||||||
bool Semantic::visit(ArrayTypeAST *ast)
|
bool Semantic::visit(ArrayTypeAST *ast)
|
||||||
{
|
{
|
||||||
type(ast->elementType);
|
const Type *elementType = type(ast->elementType);
|
||||||
|
Q_UNUSED(elementType);
|
||||||
expression(ast->size);
|
expression(ast->size);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -295,26 +306,30 @@ bool Semantic::visit(QualifiedTypeAST *ast)
|
|||||||
// declarations
|
// declarations
|
||||||
bool Semantic::visit(PrecisionDeclarationAST *ast)
|
bool Semantic::visit(PrecisionDeclarationAST *ast)
|
||||||
{
|
{
|
||||||
type(ast->type);
|
const Type *ty = type(ast->type);
|
||||||
|
Q_UNUSED(ty);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Semantic::visit(ParameterDeclarationAST *ast)
|
bool Semantic::visit(ParameterDeclarationAST *ast)
|
||||||
{
|
{
|
||||||
type(ast->type);
|
const Type *ty = type(ast->type);
|
||||||
|
Q_UNUSED(ty);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Semantic::visit(VariableDeclarationAST *ast)
|
bool Semantic::visit(VariableDeclarationAST *ast)
|
||||||
{
|
{
|
||||||
type(ast->type);
|
const Type *ty = type(ast->type);
|
||||||
|
Q_UNUSED(ty);
|
||||||
expression(ast->initializer);
|
expression(ast->initializer);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Semantic::visit(TypeDeclarationAST *ast)
|
bool Semantic::visit(TypeDeclarationAST *ast)
|
||||||
{
|
{
|
||||||
type(ast->type);
|
const Type *ty = type(ast->type);
|
||||||
|
Q_UNUSED(ty);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +357,8 @@ bool Semantic::visit(InitDeclarationAST *ast)
|
|||||||
|
|
||||||
bool Semantic::visit(FunctionDeclarationAST *ast)
|
bool Semantic::visit(FunctionDeclarationAST *ast)
|
||||||
{
|
{
|
||||||
type(ast->returnType);
|
const Type *returnType = type(ast->returnType);
|
||||||
|
Q_UNUSED(returnType);
|
||||||
for (List<ParameterDeclarationAST *> *it = ast->params; it; it = it->next) {
|
for (List<ParameterDeclarationAST *> *it = ast->params; it; it = it->next) {
|
||||||
ParameterDeclarationAST *decl = it->value;
|
ParameterDeclarationAST *decl = it->value;
|
||||||
declaration(decl);
|
declaration(decl);
|
||||||
|
|||||||
@@ -36,12 +36,12 @@ namespace GLSL {
|
|||||||
class GLSL_EXPORT Semantic: protected Visitor
|
class GLSL_EXPORT Semantic: protected Visitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Semantic();
|
Semantic(Engine *engine);
|
||||||
virtual ~Semantic();
|
virtual ~Semantic();
|
||||||
|
|
||||||
void expression(ExpressionAST *ast);
|
void expression(ExpressionAST *ast);
|
||||||
void statement(StatementAST *ast);
|
void statement(StatementAST *ast);
|
||||||
void type(TypeAST *ast);
|
const Type *type(TypeAST *ast);
|
||||||
void declaration(DeclarationAST *ast);
|
void declaration(DeclarationAST *ast);
|
||||||
void translationUnit(TranslationUnitAST *ast);
|
void translationUnit(TranslationUnitAST *ast);
|
||||||
void functionIdentifier(FunctionIdentifierAST *ast);
|
void functionIdentifier(FunctionIdentifierAST *ast);
|
||||||
@@ -92,6 +92,10 @@ protected:
|
|||||||
virtual bool visit(InvariantDeclarationAST *ast);
|
virtual bool visit(InvariantDeclarationAST *ast);
|
||||||
virtual bool visit(InitDeclarationAST *ast);
|
virtual bool visit(InitDeclarationAST *ast);
|
||||||
virtual bool visit(FunctionDeclarationAST *ast);
|
virtual bool visit(FunctionDeclarationAST *ast);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Engine *_engine;
|
||||||
|
const Type *_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GLSL
|
} // namespace GLSL
|
||||||
|
|||||||
Reference in New Issue
Block a user