From 864c3bfc98bee160276e37495d2a364cb3a3f6c8 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 25 Nov 2010 12:19:57 +0100 Subject: Added the suffix AST to the ast nodes and some initial work on the GLSL type system. --- src/libs/glsl/glsl-lib.pri | 4 +- src/libs/glsl/glsl.g | 620 +++++++++++++++++----------------- src/libs/glsl/glsl.h | 14 + src/libs/glsl/glslast.cpp | 106 +++--- src/libs/glsl/glslast.h | 598 ++++++++++++++++---------------- src/libs/glsl/glslastvisitor.h | 144 ++++---- src/libs/glsl/glslengine.cpp | 53 +++ src/libs/glsl/glslengine.h | 30 ++ src/libs/glsl/glslparser.cpp | 564 +++++++++++++++---------------- src/libs/glsl/glslparser.h | 56 +-- src/libs/glsl/glslsemantic.cpp | 114 +++---- src/libs/glsl/glslsemantic.h | 86 ++--- src/libs/glsl/glsltypes.cpp | 197 +++++++++++ src/libs/glsl/glsltypes.h | 158 +++++++++ src/libs/glsl/tests/main.cpp | 2 +- src/plugins/glsleditor/glsleditor.cpp | 2 +- 16 files changed, 1600 insertions(+), 1148 deletions(-) create mode 100644 src/libs/glsl/glsltypes.cpp create mode 100644 src/libs/glsl/glsltypes.h (limited to 'src') diff --git a/src/libs/glsl/glsl-lib.pri b/src/libs/glsl/glsl-lib.pri index 0682af4960..7e4bcf7736 100644 --- a/src/libs/glsl/glsl-lib.pri +++ b/src/libs/glsl/glsl-lib.pri @@ -1,9 +1,9 @@ HEADERS += $$PWD/glsl.h $$PWD/glsllexer.h $$PWD/glslparser.h $$PWD/glslparsertable_p.h $$PWD/glslast.h \ $$PWD/glslastvisitor.h $$PWD/glslengine.h $$PWD/glslmemorypool.h $$PWD/glslastdump.h \ - $$PWD/glslsemantic.h + $$PWD/glslsemantic.h $$PWD/glsltypes.h SOURCES += $$PWD/glslkeywords.cpp $$PWD/glslparser.cpp $$PWD/glslparsertable.cpp \ $$PWD/glsllexer.cpp $$PWD/glslast.cpp \ $$PWD/glslastvisitor.cpp $$PWD/glslengine.cpp $$PWD/glslmemorypool.cpp $$PWD/glslastdump.cpp \ - $$PWD/glslsemantic.cpp + $$PWD/glslsemantic.cpp $$PWD/glsltypes.cpp OTHER_FILES = $$PWD/glsl.g diff --git a/src/libs/glsl/glsl.g b/src/libs/glsl/glsl.g index 934545d74a..1bbc63a11b 100644 --- a/src/libs/glsl/glsl.g +++ b/src/libs/glsl/glsl.g @@ -258,30 +258,30 @@ public: const QString *string; AST *ast; List *ast_list; - Declaration *declaration; - List *declaration_list; - Expression *expression; - List *expression_list; - Statement *statement; - List *statement_list; - Type *type; - StructType::Field *field; - List *field_list; - TranslationUnit *translation_unit; - FunctionIdentifier *function_identifier; + DeclarationAST *declaration; + List *declaration_list; + ExpressionAST *expression; + List *expression_list; + StatementAST *statement; + List *statement_list; + TypeAST *type; + StructTypeAST::Field *field; + List *field_list; + TranslationUnitAST *translation_unit; + FunctionIdentifierAST *function_identifier; AST::Kind kind; - Type::Precision precision; + TypeAST::Precision precision; struct { - Statement *thenClause; - Statement *elseClause; + StatementAST *thenClause; + StatementAST *elseClause; } ifstmt; struct { - Expression *condition; - Expression *increment; + ExpressionAST *condition; + ExpressionAST *increment; } forstmt; struct { - FunctionIdentifier *id; - List *arguments; + FunctionIdentifierAST *id; + List *arguments; } function; int qualifier; LayoutQualifier *layout; @@ -291,27 +291,27 @@ public: List *layout_list; } type_qualifier; struct { - Type *type; + TypeAST *type; const QString *name; } param_declarator; - ParameterDeclaration *param_declaration; - FunctionDeclaration *function_declaration; + ParameterDeclarationAST *param_declaration; + FunctionDeclarationAST *function_declaration; }; Parser(Engine *engine, const char *source, unsigned size, int variant); ~Parser(); - TranslationUnit *parse(); + TranslationUnitAST *parse(); private: // 1-based Value &sym(int n) { return _symStack[_tos + n - 1]; } AST *&ast(int n) { return _symStack[_tos + n - 1].ast; } const QString *&string(int n) { return _symStack[_tos + n - 1].string; } - Expression *&expression(int n) { return _symStack[_tos + n - 1].expression; } - Statement *&statement(int n) { return _symStack[_tos + n - 1].statement; } - Type *&type(int n) { return _symStack[_tos + n - 1].type; } - FunctionDeclaration *&function(int n) { return _symStack[_tos + n - 1].function_declaration; } + ExpressionAST *&expression(int n) { return _symStack[_tos + n - 1].expression; } + StatementAST *&statement(int n) { return _symStack[_tos + n - 1].statement; } + TypeAST *&type(int n) { return _symStack[_tos + n - 1].type; } + FunctionDeclarationAST *&function(int n) { return _symStack[_tos + n - 1].function_declaration; } inline int consumeToken() { return _index++; } inline const Token &tokenAt(int index) const { return _tokens.at(index); } @@ -376,9 +376,9 @@ private: return node; } - Type *makeBasicType(int token, BasicType::Category category) + TypeAST *makeBasicType(int token, BasicTypeAST::Category category) { - Type *type = new (_engine->pool()) BasicType(token, spell[token], category); + TypeAST *type = new (_engine->pool()) BasicTypeAST(token, spell[token], category); type->lineno = yyloc >= 0 ? (_tokens[yyloc].line + 1) : 0; return type; } @@ -499,7 +499,7 @@ Parser::~Parser() { } -TranslationUnit *Parser::parse() +TranslationUnitAST *Parser::parse() { int action = 0; int yytoken = -1; @@ -579,28 +579,28 @@ switch(ruleno) { variable_identifier ::= IDENTIFIER ; /. case $rule_number: { - ast(1) = makeAstNode(string(1)); + ast(1) = makeAstNode(string(1)); } break; ./ primary_expression ::= NUMBER ; /. case $rule_number: { - ast(1) = makeAstNode(string(1)); + ast(1) = makeAstNode(string(1)); } break; ./ primary_expression ::= TRUE ; /. case $rule_number: { - ast(1) = makeAstNode(_engine->identifier("true", 4)); + ast(1) = makeAstNode(_engine->identifier("true", 4)); } break; ./ primary_expression ::= FALSE ; /. case $rule_number: { - ast(1) = makeAstNode(_engine->identifier("false", 5)); + ast(1) = makeAstNode(_engine->identifier("false", 5)); } break; ./ @@ -628,7 +628,7 @@ case $rule_number: { postfix_expression ::= postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_ArrayAccess, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_ArrayAccess, expression(1), expression(3)); } break; ./ @@ -642,21 +642,21 @@ case $rule_number: { postfix_expression ::= postfix_expression DOT IDENTIFIER ; /. case $rule_number: { - ast(1) = makeAstNode(expression(1), string(3)); + ast(1) = makeAstNode(expression(1), string(3)); } break; ./ postfix_expression ::= postfix_expression INC_OP ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_PostIncrement, expression(1)); + ast(1) = makeAstNode(AST::Kind_PostIncrement, expression(1)); } break; ./ postfix_expression ::= postfix_expression DEC_OP ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_PostDecrement, expression(1)); + ast(1) = makeAstNode(AST::Kind_PostDecrement, expression(1)); } break; ./ @@ -677,7 +677,7 @@ case $rule_number: { function_call_or_method ::= function_call_generic ; /. case $rule_number: { - ast(1) = makeAstNode + ast(1) = makeAstNode (sym(1).function.id, sym(1).function.arguments); } break; ./ @@ -685,7 +685,7 @@ case $rule_number: { function_call_or_method ::= postfix_expression DOT function_call_generic ; /. case $rule_number: { - ast(1) = makeAstNode + ast(1) = makeAstNode (expression(1), sym(3).function.id, sym(3).function.arguments); } break; ./ @@ -725,7 +725,7 @@ function_call_header_with_parameters ::= function_call_header assignment_express case $rule_number: { sym(1).function.id = sym(1).function_identifier; sym(1).function.arguments = - makeAstNode< List >(expression(2)); + makeAstNode< List >(expression(2)); } break; ./ @@ -733,7 +733,7 @@ function_call_header_with_parameters ::= function_call_header_with_parameters CO /. case $rule_number: { sym(1).function.arguments = - makeAstNode< List > + makeAstNode< List > (sym(1).function.arguments, expression(3)); } break; ./ @@ -748,14 +748,14 @@ case $rule_number: { function_identifier ::= type_specifier ; /. case $rule_number: { - ast(1) = makeAstNode(type(1)); + ast(1) = makeAstNode(type(1)); } break; ./ function_identifier ::= IDENTIFIER ; /. case $rule_number: { - ast(1) = makeAstNode(string(1)); + ast(1) = makeAstNode(string(1)); } break; ./ @@ -769,21 +769,21 @@ case $rule_number: { unary_expression ::= INC_OP unary_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_PreIncrement, expression(2)); + ast(1) = makeAstNode(AST::Kind_PreIncrement, expression(2)); } break; ./ unary_expression ::= DEC_OP unary_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_PreDecrement, expression(2)); + ast(1) = makeAstNode(AST::Kind_PreDecrement, expression(2)); } break; ./ unary_expression ::= unary_operator unary_expression ; /. case $rule_number: { - ast(1) = makeAstNode(sym(1).kind, expression(2)); + ast(1) = makeAstNode(sym(1).kind, expression(2)); } break; ./ @@ -825,21 +825,21 @@ case $rule_number: { multiplicative_expression ::= multiplicative_expression STAR unary_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_Multiply, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Multiply, expression(1), expression(3)); } break; ./ multiplicative_expression ::= multiplicative_expression SLASH unary_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_Divide, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Divide, expression(1), expression(3)); } break; ./ multiplicative_expression ::= multiplicative_expression PERCENT unary_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_Modulus, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Modulus, expression(1), expression(3)); } break; ./ @@ -853,14 +853,14 @@ case $rule_number: { additive_expression ::= additive_expression PLUS multiplicative_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_Plus, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Plus, expression(1), expression(3)); } break; ./ additive_expression ::= additive_expression DASH multiplicative_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_Minus, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Minus, expression(1), expression(3)); } break; ./ @@ -874,14 +874,14 @@ case $rule_number: { shift_expression ::= shift_expression LEFT_OP additive_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_ShiftLeft, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_ShiftLeft, expression(1), expression(3)); } break; ./ shift_expression ::= shift_expression RIGHT_OP additive_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_ShiftRight, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_ShiftRight, expression(1), expression(3)); } break; ./ @@ -895,28 +895,28 @@ case $rule_number: { relational_expression ::= relational_expression LEFT_ANGLE shift_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_LessThan, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_LessThan, expression(1), expression(3)); } break; ./ relational_expression ::= relational_expression RIGHT_ANGLE shift_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_GreaterThan, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_GreaterThan, expression(1), expression(3)); } break; ./ relational_expression ::= relational_expression LE_OP shift_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_LessEqual, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_LessEqual, expression(1), expression(3)); } break; ./ relational_expression ::= relational_expression GE_OP shift_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_GreaterEqual, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_GreaterEqual, expression(1), expression(3)); } break; ./ @@ -930,14 +930,14 @@ case $rule_number: { equality_expression ::= equality_expression EQ_OP relational_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_Equal, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Equal, expression(1), expression(3)); } break; ./ equality_expression ::= equality_expression NE_OP relational_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_NotEqual, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_NotEqual, expression(1), expression(3)); } break; ./ @@ -951,7 +951,7 @@ case $rule_number: { and_expression ::= and_expression AMPERSAND equality_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_BitwiseAnd, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_BitwiseAnd, expression(1), expression(3)); } break; ./ @@ -965,7 +965,7 @@ case $rule_number: { exclusive_or_expression ::= exclusive_or_expression CARET and_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_BitwiseXor, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_BitwiseXor, expression(1), expression(3)); } break; ./ @@ -979,7 +979,7 @@ case $rule_number: { inclusive_or_expression ::= inclusive_or_expression VERTICAL_BAR exclusive_or_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_BitwiseOr, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_BitwiseOr, expression(1), expression(3)); } break; ./ @@ -993,7 +993,7 @@ case $rule_number: { logical_and_expression ::= logical_and_expression AND_OP inclusive_or_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_LogicalAnd, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_LogicalAnd, expression(1), expression(3)); } break; ./ @@ -1007,7 +1007,7 @@ case $rule_number: { logical_xor_expression ::= logical_xor_expression XOR_OP logical_and_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_LogicalXor, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_LogicalXor, expression(1), expression(3)); } break; ./ @@ -1021,7 +1021,7 @@ case $rule_number: { logical_or_expression ::= logical_or_expression OR_OP logical_xor_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_LogicalOr, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_LogicalOr, expression(1), expression(3)); } break; ./ @@ -1035,7 +1035,7 @@ case $rule_number: { conditional_expression ::= logical_or_expression QUESTION expression COLON assignment_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_Conditional, expression(1), expression(3), expression(5)); + ast(1) = makeAstNode(AST::Kind_Conditional, expression(1), expression(3), expression(5)); } break; ./ @@ -1049,7 +1049,7 @@ case $rule_number: { assignment_expression ::= unary_expression assignment_operator assignment_expression ; /. case $rule_number: { - ast(1) = makeAstNode(sym(2).kind, expression(1), expression(3)); + ast(1) = makeAstNode(sym(2).kind, expression(1), expression(3)); } break; ./ @@ -1140,7 +1140,7 @@ case $rule_number: { expression ::= expression COMMA assignment_expression ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_Comma, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Comma, expression(1), expression(3)); } break; ./ @@ -1161,94 +1161,94 @@ case $rule_number: { declaration ::= init_declarator_list SEMICOLON ; /. case $rule_number: { - ast(1) = makeAstNode(sym(1).declaration_list); + ast(1) = makeAstNode(sym(1).declaration_list); } break; ./ declaration ::= PRECISION precision_qualifier type_specifier_no_prec SEMICOLON ; /. case $rule_number: { - ast(1) = makeAstNode(sym(2).precision, type(3)); + ast(1) = makeAstNode(sym(2).precision, type(3)); } break; ./ declaration ::= type_qualifier IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE SEMICOLON ; /. case $rule_number: { - if (sym(1).type_qualifier.qualifier != QualifiedType::Struct) { + if (sym(1).type_qualifier.qualifier != QualifiedTypeAST::Struct) { // TODO: issue an error if the qualifier is not "struct". } - Type *type = makeAstNode(string(2), sym(4).field_list); - ast(1) = makeAstNode(type); + TypeAST *type = makeAstNode(string(2), sym(4).field_list); + ast(1) = makeAstNode(type); } break; ./ declaration ::= type_qualifier IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE IDENTIFIER SEMICOLON ; /. case $rule_number: { - if ((sym(1).type_qualifier.qualifier & QualifiedType::Struct) == 0) { + if ((sym(1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) { // TODO: issue an error if the qualifier does not contain "struct". } - Type *type = makeAstNode(string(2), sym(4).field_list); - Type *qualtype = type; - if (sym(1).type_qualifier.qualifier != QualifiedType::Struct) { - qualtype = makeAstNode - (sym(1).type_qualifier.qualifier & ~QualifiedType::Struct, qualtype, + TypeAST *type = makeAstNode(string(2), sym(4).field_list); + TypeAST *qualtype = type; + if (sym(1).type_qualifier.qualifier != QualifiedTypeAST::Struct) { + qualtype = makeAstNode + (sym(1).type_qualifier.qualifier & ~QualifiedTypeAST::Struct, qualtype, sym(1).type_qualifier.layout_list); } - ast(1) = makeAstNode - (makeAstNode(type), - makeAstNode(qualtype, string(6))); + ast(1) = makeAstNode + (makeAstNode(type), + makeAstNode(qualtype, string(6))); } break; ./ declaration ::= type_qualifier IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE IDENTIFIER LEFT_BRACKET RIGHT_BRACKET SEMICOLON ; /. case $rule_number: { - if ((sym(1).type_qualifier.qualifier & QualifiedType::Struct) == 0) { + if ((sym(1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) { // TODO: issue an error if the qualifier does not contain "struct". } - Type *type = makeAstNode(string(2), sym(4).field_list); - Type *qualtype = type; - if (sym(1).type_qualifier.qualifier != QualifiedType::Struct) { - qualtype = makeAstNode - (sym(1).type_qualifier.qualifier & ~QualifiedType::Struct, qualtype, + TypeAST *type = makeAstNode(string(2), sym(4).field_list); + TypeAST *qualtype = type; + if (sym(1).type_qualifier.qualifier != QualifiedTypeAST::Struct) { + qualtype = makeAstNode + (sym(1).type_qualifier.qualifier & ~QualifiedTypeAST::Struct, qualtype, sym(1).type_qualifier.layout_list); } - ast(1) = makeAstNode - (makeAstNode(type), - makeAstNode - (makeAstNode(qualtype), string(6))); + ast(1) = makeAstNode + (makeAstNode(type), + makeAstNode + (makeAstNode(qualtype), string(6))); } break; ./ declaration ::= type_qualifier IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET SEMICOLON ; /. case $rule_number: { - if ((sym(1).type_qualifier.qualifier & QualifiedType::Struct) == 0) { + if ((sym(1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) { // TODO: issue an error if the qualifier does not contain "struct". } - Type *type = makeAstNode(string(2), sym(4).field_list); - Type *qualtype = type; - if (sym(1).type_qualifier.qualifier != QualifiedType::Struct) { - qualtype = makeAstNode - (sym(1).type_qualifier.qualifier & ~QualifiedType::Struct, qualtype, + TypeAST *type = makeAstNode(string(2), sym(4).field_list); + TypeAST *qualtype = type; + if (sym(1).type_qualifier.qualifier != QualifiedTypeAST::Struct) { + qualtype = makeAstNode + (sym(1).type_qualifier.qualifier & ~QualifiedTypeAST::Struct, qualtype, sym(1).type_qualifier.layout_list); } - ast(1) = makeAstNode - (makeAstNode(type), - makeAstNode - (makeAstNode(qualtype, expression(8)), string(6))); + ast(1) = makeAstNode + (makeAstNode(type), + makeAstNode + (makeAstNode(qualtype, expression(8)), string(6))); } break; ./ declaration ::= type_qualifier SEMICOLON ; /. case $rule_number: { - Type *type = makeAstNode - (sym(1).type_qualifier.qualifier, (Type *)0, + TypeAST *type = makeAstNode + (sym(1).type_qualifier.qualifier, (TypeAST *)0, sym(1).type_qualifier.layout_list); - ast(1) = makeAstNode(type); + ast(1) = makeAstNode(type); } break; ./ @@ -1276,7 +1276,7 @@ case $rule_number: { function_header_with_parameters ::= function_header parameter_declaration ; /. case $rule_number: { - function(1)->params = makeAstNode< List > + function(1)->params = makeAstNode< List > (sym(2).param_declaration); } break; ./ @@ -1284,7 +1284,7 @@ case $rule_number: { function_header_with_parameters ::= function_header_with_parameters COMMA parameter_declaration ; /. case $rule_number: { - function(1)->params = makeAstNode< List > + function(1)->params = makeAstNode< List > (function(1)->params, sym(3).param_declaration); } break; ./ @@ -1292,7 +1292,7 @@ case $rule_number: { function_header ::= fully_specified_type IDENTIFIER LEFT_PAREN ; /. case $rule_number: { - function(1) = makeAstNode(type(1), string(2)); + function(1) = makeAstNode(type(1), string(2)); } break; ./ @@ -1307,7 +1307,7 @@ case $rule_number: { parameter_declarator ::= type_specifier IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET ; /. case $rule_number: { - sym(1).param_declarator.type = makeAstNode(type(1), expression(4)); + sym(1).param_declarator.type = makeAstNode(type(1), expression(4)); sym(1).param_declarator.name = string(2); } break; ./ @@ -1315,11 +1315,11 @@ case $rule_number: { parameter_declaration ::= parameter_type_qualifier parameter_qualifier parameter_declarator ; /. case $rule_number: { - ast(1) = makeAstNode - (makeAstNode + ast(1) = makeAstNode + (makeAstNode (sym(1).qualifier, sym(3).param_declarator.type, (List *)0), - ParameterDeclaration::Qualifier(sym(2).qualifier), + ParameterDeclarationAST::Qualifier(sym(2).qualifier), sym(3).param_declarator.name); } break; ./ @@ -1327,9 +1327,9 @@ case $rule_number: { parameter_declaration ::= parameter_qualifier parameter_declarator ; /. case $rule_number: { - ast(1) = makeAstNode + ast(1) = makeAstNode (sym(2).param_declarator.type, - ParameterDeclaration::Qualifier(sym(1).qualifier), + ParameterDeclarationAST::Qualifier(sym(1).qualifier), sym(2).param_declarator.name); } break; ./ @@ -1337,10 +1337,10 @@ case $rule_number: { parameter_declaration ::= parameter_type_qualifier parameter_qualifier parameter_type_specifier ; /. case $rule_number: { - ast(1) = makeAstNode - (makeAstNode + ast(1) = makeAstNode + (makeAstNode (sym(1).qualifier, type(3), (List *)0), - ParameterDeclaration::Qualifier(sym(2).qualifier), + ParameterDeclarationAST::Qualifier(sym(2).qualifier), (const QString *)0); } break; ./ @@ -1348,8 +1348,8 @@ case $rule_number: { parameter_declaration ::= parameter_qualifier parameter_type_specifier ; /. case $rule_number: { - ast(1) = makeAstNode - (type(2), ParameterDeclaration::Qualifier(sym(1).qualifier), + ast(1) = makeAstNode + (type(2), ParameterDeclarationAST::Qualifier(sym(1).qualifier), (const QString *)0); } break; ./ @@ -1357,28 +1357,28 @@ case $rule_number: { parameter_qualifier ::= empty ; /. case $rule_number: { - sym(1).qualifier = ParameterDeclaration::In; + sym(1).qualifier = ParameterDeclarationAST::In; } break; ./ parameter_qualifier ::= IN ; /. case $rule_number: { - sym(1).qualifier = ParameterDeclaration::In; + sym(1).qualifier = ParameterDeclarationAST::In; } break; ./ parameter_qualifier ::= OUT ; /. case $rule_number: { - sym(1).qualifier = ParameterDeclaration::Out; + sym(1).qualifier = ParameterDeclarationAST::Out; } break; ./ parameter_qualifier ::= INOUT ; /. case $rule_number: { - sym(1).qualifier = ParameterDeclaration::InOut; + sym(1).qualifier = ParameterDeclarationAST::InOut; } break; ./ @@ -1392,7 +1392,7 @@ case $rule_number: { init_declarator_list ::= single_declaration ; /. case $rule_number: { - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration); } break; ./ @@ -1400,9 +1400,9 @@ case $rule_number: { init_declarator_list ::= init_declarator_list COMMA IDENTIFIER ; /. case $rule_number: { - Type *type = VariableDeclaration::declarationType(sym(1).declaration_list); - Declaration *decl = makeAstNode(type, string(3)); - sym(1).declaration_list = makeAstNode< List > + TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list); + DeclarationAST *decl = makeAstNode(type, string(3)); + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, decl); } break; ./ @@ -1410,10 +1410,10 @@ case $rule_number: { init_declarator_list ::= init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET ; /. case $rule_number: { - Type *type = VariableDeclaration::declarationType(sym(1).declaration_list); - type = makeAstNode(type); - Declaration *decl = makeAstNode(type, string(3)); - sym(1).declaration_list = makeAstNode< List > + TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list); + type = makeAstNode(type); + DeclarationAST *decl = makeAstNode(type, string(3)); + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, decl); } break; ./ @@ -1421,10 +1421,10 @@ case $rule_number: { init_declarator_list ::= init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET ; /. case $rule_number: { - Type *type = VariableDeclaration::declarationType(sym(1).declaration_list); - type = makeAstNode(type, expression(5)); - Declaration *decl = makeAstNode(type, string(3)); - sym(1).declaration_list = makeAstNode< List > + TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list); + type = makeAstNode(type, expression(5)); + DeclarationAST *decl = makeAstNode(type, string(3)); + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, decl); } break; ./ @@ -1432,11 +1432,11 @@ case $rule_number: { init_declarator_list ::= init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET EQUAL initializer ; /. case $rule_number: { - Type *type = VariableDeclaration::declarationType(sym(1).declaration_list); - type = makeAstNode(type); - Declaration *decl = makeAstNode + TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list); + type = makeAstNode(type); + DeclarationAST *decl = makeAstNode (type, string(3), expression(7)); - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, decl); } break; ./ @@ -1444,11 +1444,11 @@ case $rule_number: { init_declarator_list ::= init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET EQUAL initializer ; /. case $rule_number: { - Type *type = VariableDeclaration::declarationType(sym(1).declaration_list); - type = makeAstNode(type, expression(5)); - Declaration *decl = makeAstNode + TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list); + type = makeAstNode(type, expression(5)); + DeclarationAST *decl = makeAstNode (type, string(3), expression(8)); - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, decl); } break; ./ @@ -1456,10 +1456,10 @@ case $rule_number: { init_declarator_list ::= init_declarator_list COMMA IDENTIFIER EQUAL initializer ; /. case $rule_number: { - Type *type = VariableDeclaration::declarationType(sym(1).declaration_list); - Declaration *decl = makeAstNode + TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list); + DeclarationAST *decl = makeAstNode (type, string(3), expression(5)); - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, decl); } break; ./ @@ -1467,46 +1467,46 @@ case $rule_number: { single_declaration ::= fully_specified_type ; /. case $rule_number: { - ast(1) = makeAstNode(type(1)); + ast(1) = makeAstNode(type(1)); } break; ./ single_declaration ::= fully_specified_type IDENTIFIER ; /. case $rule_number: { - ast(1) = makeAstNode(type(1), string(2)); + ast(1) = makeAstNode(type(1), string(2)); } break; ./ single_declaration ::= fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET ; /. case $rule_number: { - ast(1) = makeAstNode - (makeAstNode(type(1)), string(2)); + ast(1) = makeAstNode + (makeAstNode(type(1)), string(2)); } break; ./ single_declaration ::= fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET ; /. case $rule_number: { - ast(1) = makeAstNode - (makeAstNode(type(1), expression(4)), string(2)); + ast(1) = makeAstNode + (makeAstNode(type(1), expression(4)), string(2)); } break; ./ single_declaration ::= fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET EQUAL initializer ; /. case $rule_number: { - ast(1) = makeAstNode - (makeAstNode(type(1)), string(2), expression(6)); + ast(1) = makeAstNode + (makeAstNode(type(1)), string(2), expression(6)); } break; ./ single_declaration ::= fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET EQUAL initializer ; /. case $rule_number: { - ast(1) = makeAstNode - (makeAstNode(type(1), expression(4)), + ast(1) = makeAstNode + (makeAstNode(type(1), expression(4)), string(2), expression(7)); } break; ./ @@ -1514,7 +1514,7 @@ case $rule_number: { single_declaration ::= fully_specified_type IDENTIFIER EQUAL initializer ; /. case $rule_number: { - ast(1) = makeAstNode + ast(1) = makeAstNode (type(1), string(2), expression(4)); } break; ./ @@ -1522,21 +1522,21 @@ case $rule_number: { single_declaration ::= INVARIANT IDENTIFIER ; /. case $rule_number: { - ast(1) = makeAstNode(string(2)); + ast(1) = makeAstNode(string(2)); } break; ./ fully_specified_type ::= type_specifier ; /. case $rule_number: { - ast(1) = makeAstNode(0, type(1), (List *)0); + ast(1) = makeAstNode(0, type(1), (List *)0); } break; ./ fully_specified_type ::= type_qualifier type_specifier ; /. case $rule_number: { - ast(1) = makeAstNode + ast(1) = makeAstNode (sym(1).type_qualifier.qualifier, type(2), sym(1).type_qualifier.layout_list); } break; @@ -1545,28 +1545,28 @@ case $rule_number: { invariant_qualifier ::= INVARIANT ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::Invariant; + sym(1).qualifier = QualifiedTypeAST::Invariant; } break; ./ interpolation_qualifier ::= SMOOTH ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::Smooth; + sym(1).qualifier = QualifiedTypeAST::Smooth; } break; ./ interpolation_qualifier ::= FLAT ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::Flat; + sym(1).qualifier = QualifiedTypeAST::Flat; } break; ./ interpolation_qualifier ::= NOPERSPECTIVE ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::NoPerspective; + sym(1).qualifier = QualifiedTypeAST::NoPerspective; } break; ./ @@ -1608,7 +1608,7 @@ case $rule_number: { parameter_type_qualifier ::= CONST ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::Const; + sym(1).qualifier = QualifiedTypeAST::Const; } break; ./ @@ -1671,7 +1671,7 @@ case $rule_number: { type_qualifier ::= INVARIANT ; /. case $rule_number: { - sym(1).type_qualifier.qualifier = QualifiedType::Invariant; + sym(1).type_qualifier.qualifier = QualifiedTypeAST::Invariant; sym(1).type_qualifier.layout_list = 0; } break; ./ @@ -1679,91 +1679,91 @@ case $rule_number: { storage_qualifier ::= CONST ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::Const; + sym(1).qualifier = QualifiedTypeAST::Const; } break; ./ storage_qualifier ::= ATTRIBUTE ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::Attribute; + sym(1).qualifier = QualifiedTypeAST::Attribute; } break; ./ storage_qualifier ::= VARYING ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::Varying; + sym(1).qualifier = QualifiedTypeAST::Varying; } break; ./ storage_qualifier ::= CENTROID VARYING ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::CentroidVarying; + sym(1).qualifier = QualifiedTypeAST::CentroidVarying; } break; ./ storage_qualifier ::= IN ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::In; + sym(1).qualifier = QualifiedTypeAST::In; } break; ./ storage_qualifier ::= OUT ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::Out; + sym(1).qualifier = QualifiedTypeAST::Out; } break; ./ storage_qualifier ::= CENTROID IN ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::CentroidIn; + sym(1).qualifier = QualifiedTypeAST::CentroidIn; } break; ./ storage_qualifier ::= CENTROID OUT ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::CentroidOut; + sym(1).qualifier = QualifiedTypeAST::CentroidOut; } break; ./ storage_qualifier ::= PATCH IN ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::PatchIn; + sym(1).qualifier = QualifiedTypeAST::PatchIn; } break; ./ storage_qualifier ::= PATCH OUT ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::PatchOut; + sym(1).qualifier = QualifiedTypeAST::PatchOut; } break; ./ storage_qualifier ::= SAMPLE IN ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::SampleIn; + sym(1).qualifier = QualifiedTypeAST::SampleIn; } break; ./ storage_qualifier ::= SAMPLE OUT ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::SampleOut; + sym(1).qualifier = QualifiedTypeAST::SampleOut; } break; ./ storage_qualifier ::= UNIFORM ; /. case $rule_number: { - sym(1).qualifier = QualifiedType::Uniform; + sym(1).qualifier = QualifiedTypeAST::Uniform; } break; ./ @@ -1794,609 +1794,609 @@ case $rule_number: { type_specifier_no_prec ::= type_specifier_nonarray LEFT_BRACKET RIGHT_BRACKET ; /. case $rule_number: { - ast(1) = makeAstNode(type(1)); + ast(1) = makeAstNode(type(1)); } break; ./ type_specifier_no_prec ::= type_specifier_nonarray LEFT_BRACKET constant_expression RIGHT_BRACKET ; /. case $rule_number: { - ast(1) = makeAstNode(type(1), expression(3)); + ast(1) = makeAstNode(type(1), expression(3)); } break; ./ type_specifier_nonarray ::= VOID ; /. case $rule_number: { - ast(1) = makeBasicType(T_VOID, Type::Void); + ast(1) = makeBasicType(T_VOID, TypeAST::Void); } break; ./ type_specifier_nonarray ::= FLOAT ; /. case $rule_number: { - ast(1) = makeBasicType(T_FLOAT, Type::Primitive); + ast(1) = makeBasicType(T_FLOAT, TypeAST::Primitive); } break; ./ type_specifier_nonarray ::= DOUBLE ; /. case $rule_number: { - ast(1) = makeBasicType(T_DOUBLE, Type::Primitive); + ast(1) = makeBasicType(T_DOUBLE, TypeAST::Primitive); } break; ./ type_specifier_nonarray ::= INT ; /. case $rule_number: { - ast(1) = makeBasicType(T_INT, Type::Primitive); + ast(1) = makeBasicType(T_INT, TypeAST::Primitive); } break; ./ type_specifier_nonarray ::= UINT ; /. case $rule_number: { - ast(1) = makeBasicType(T_UINT, Type::Primitive); + ast(1) = makeBasicType(T_UINT, TypeAST::Primitive); } break; ./ type_specifier_nonarray ::= BOOL ; /. case $rule_number: { - ast(1) = makeBasicType(T_BOOL, Type::Primitive); + ast(1) = makeBasicType(T_BOOL, TypeAST::Primitive); } break; ./ type_specifier_nonarray ::= VEC2 ; /. case $rule_number: { - ast(1) = makeBasicType(T_VEC2, Type::Vector2); + ast(1) = makeBasicType(T_VEC2, TypeAST::Vector2); } break; ./ type_specifier_nonarray ::= VEC3 ; /. case $rule_number: { - ast(1) = makeBasicType(T_VEC3, Type::Vector3); + ast(1) = makeBasicType(T_VEC3, TypeAST::Vector3); } break; ./ type_specifier_nonarray ::= VEC4 ; /. case $rule_number: { - ast(1) = makeBasicType(T_VEC4, Type::Vector4); + ast(1) = makeBasicType(T_VEC4, TypeAST::Vector4); } break; ./ type_specifier_nonarray ::= DVEC2 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DVEC2, Type::Vector2); + ast(1) = makeBasicType(T_DVEC2, TypeAST::Vector2); } break; ./ type_specifier_nonarray ::= DVEC3 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DVEC3, Type::Vector3); + ast(1) = makeBasicType(T_DVEC3, TypeAST::Vector3); } break; ./ type_specifier_nonarray ::= DVEC4 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DVEC4, Type::Vector4); + ast(1) = makeBasicType(T_DVEC4, TypeAST::Vector4); } break; ./ type_specifier_nonarray ::= BVEC2 ; /. case $rule_number: { - ast(1) = makeBasicType(T_BVEC2, Type::Vector2); + ast(1) = makeBasicType(T_BVEC2, TypeAST::Vector2); } break; ./ type_specifier_nonarray ::= BVEC3 ; /. case $rule_number: { - ast(1) = makeBasicType(T_BVEC3, Type::Vector3); + ast(1) = makeBasicType(T_BVEC3, TypeAST::Vector3); } break; ./ type_specifier_nonarray ::= BVEC4 ; /. case $rule_number: { - ast(1) = makeBasicType(T_BVEC4, Type::Vector4); + ast(1) = makeBasicType(T_BVEC4, TypeAST::Vector4); } break; ./ type_specifier_nonarray ::= IVEC2 ; /. case $rule_number: { - ast(1) = makeBasicType(T_IVEC2, Type::Vector2); + ast(1) = makeBasicType(T_IVEC2, TypeAST::Vector2); } break; ./ type_specifier_nonarray ::= IVEC3 ; /. case $rule_number: { - ast(1) = makeBasicType(T_IVEC3, Type::Vector3); + ast(1) = makeBasicType(T_IVEC3, TypeAST::Vector3); } break; ./ type_specifier_nonarray ::= IVEC4 ; /. case $rule_number: { - ast(1) = makeBasicType(T_IVEC4, Type::Vector4); + ast(1) = makeBasicType(T_IVEC4, TypeAST::Vector4); } break; ./ type_specifier_nonarray ::= UVEC2 ; /. case $rule_number: { - ast(1) = makeBasicType(T_UVEC2, Type::Vector2); + ast(1) = makeBasicType(T_UVEC2, TypeAST::Vector2); } break; ./ type_specifier_nonarray ::= UVEC3 ; /. case $rule_number: { - ast(1) = makeBasicType(T_UVEC3, Type::Vector3); + ast(1) = makeBasicType(T_UVEC3, TypeAST::Vector3); } break; ./ type_specifier_nonarray ::= UVEC4 ; /. case $rule_number: { - ast(1) = makeBasicType(T_UVEC4, Type::Vector4); + ast(1) = makeBasicType(T_UVEC4, TypeAST::Vector4); } break; ./ type_specifier_nonarray ::= MAT2 ; /. case $rule_number: { - ast(1) = makeBasicType(T_MAT2, Type::Matrix); + ast(1) = makeBasicType(T_MAT2, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= MAT3 ; /. case $rule_number: { - ast(1) = makeBasicType(T_MAT3, Type::Matrix); + ast(1) = makeBasicType(T_MAT3, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= MAT4 ; /. case $rule_number: { - ast(1) = makeBasicType(T_MAT4, Type::Matrix); + ast(1) = makeBasicType(T_MAT4, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= MAT2X2 ; /. case $rule_number: { - ast(1) = makeBasicType(T_MAT2, Type::Matrix); + ast(1) = makeBasicType(T_MAT2, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= MAT2X3 ; /. case $rule_number: { - ast(1) = makeBasicType(T_MAT2X3, Type::Matrix); + ast(1) = makeBasicType(T_MAT2X3, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= MAT2X4 ; /. case $rule_number: { - ast(1) = makeBasicType(T_MAT2X4, Type::Matrix); + ast(1) = makeBasicType(T_MAT2X4, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= MAT3X2 ; /. case $rule_number: { - ast(1) = makeBasicType(T_MAT3X2, Type::Matrix); + ast(1) = makeBasicType(T_MAT3X2, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= MAT3X3 ; /. case $rule_number: { - ast(1) = makeBasicType(T_MAT3, Type::Matrix); + ast(1) = makeBasicType(T_MAT3, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= MAT3X4 ; /. case $rule_number: { - ast(1) = makeBasicType(T_MAT3X4, Type::Matrix); + ast(1) = makeBasicType(T_MAT3X4, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= MAT4X2 ; /. case $rule_number: { - ast(1) = makeBasicType(T_MAT4X2, Type::Matrix); + ast(1) = makeBasicType(T_MAT4X2, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= MAT4X3 ; /. case $rule_number: { - ast(1) = makeBasicType(T_MAT4X3, Type::Matrix); + ast(1) = makeBasicType(T_MAT4X3, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= MAT4X4 ; /. case $rule_number: { - ast(1) = makeBasicType(T_MAT4, Type::Matrix); + ast(1) = makeBasicType(T_MAT4, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= DMAT2 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DMAT2, Type::Matrix); + ast(1) = makeBasicType(T_DMAT2, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= DMAT3 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DMAT3, Type::Matrix); + ast(1) = makeBasicType(T_DMAT3, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= DMAT4 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DMAT4, Type::Matrix); + ast(1) = makeBasicType(T_DMAT4, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= DMAT2X2 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DMAT2, Type::Matrix); + ast(1) = makeBasicType(T_DMAT2, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= DMAT2X3 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DMAT2X3, Type::Matrix); + ast(1) = makeBasicType(T_DMAT2X3, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= DMAT2X4 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DMAT2X4, Type::Matrix); + ast(1) = makeBasicType(T_DMAT2X4, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= DMAT3X2 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DMAT3X2, Type::Matrix); + ast(1) = makeBasicType(T_DMAT3X2, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= DMAT3X3 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DMAT3, Type::Matrix); + ast(1) = makeBasicType(T_DMAT3, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= DMAT3X4 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DMAT3X4, Type::Matrix); + ast(1) = makeBasicType(T_DMAT3X4, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= DMAT4X2 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DMAT4X2, Type::Matrix); + ast(1) = makeBasicType(T_DMAT4X2, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= DMAT4X3 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DMAT4X3, Type::Matrix); + ast(1) = makeBasicType(T_DMAT4X3, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= DMAT4X4 ; /. case $rule_number: { - ast(1) = makeBasicType(T_DMAT4, Type::Matrix); + ast(1) = makeBasicType(T_DMAT4, TypeAST::Matrix); } break; ./ type_specifier_nonarray ::= SAMPLER1D ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLER1D, Type::Sampler1D); + ast(1) = makeBasicType(T_SAMPLER1D, TypeAST::Sampler1D); } break; ./ type_specifier_nonarray ::= SAMPLER2D ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLER2D, Type::Sampler2D); + ast(1) = makeBasicType(T_SAMPLER2D, TypeAST::Sampler2D); } break; ./ type_specifier_nonarray ::= SAMPLER3D ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLER3D, Type::Sampler3D); + ast(1) = makeBasicType(T_SAMPLER3D, TypeAST::Sampler3D); } break; ./ type_specifier_nonarray ::= SAMPLERCUBE ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLERCUBE, Type::SamplerCube); + ast(1) = makeBasicType(T_SAMPLERCUBE, TypeAST::SamplerCube); } break; ./ type_specifier_nonarray ::= SAMPLER1DSHADOW ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLER1DSHADOW, Type::Sampler1DShadow); + ast(1) = makeBasicType(T_SAMPLER1DSHADOW, TypeAST::Sampler1DShadow); } break; ./ type_specifier_nonarray ::= SAMPLER2DSHADOW ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLER2DSHADOW, Type::Sampler2DShadow); + ast(1) = makeBasicType(T_SAMPLER2DSHADOW, TypeAST::Sampler2DShadow); } break; ./ type_specifier_nonarray ::= SAMPLERCUBESHADOW ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLERCUBESHADOW, Type::SamplerCubeShadow); + ast(1) = makeBasicType(T_SAMPLERCUBESHADOW, TypeAST::SamplerCubeShadow); } break; ./ type_specifier_nonarray ::= SAMPLER1DARRAY ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLER1DARRAY, Type::Sampler1DArray); + ast(1) = makeBasicType(T_SAMPLER1DARRAY, TypeAST::Sampler1DArray); } break; ./ type_specifier_nonarray ::= SAMPLER2DARRAY ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLER2DARRAY, Type::Sampler2DArray); + ast(1) = makeBasicType(T_SAMPLER2DARRAY, TypeAST::Sampler2DArray); } break; ./ type_specifier_nonarray ::= SAMPLER1DARRAYSHADOW ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLER1DARRAYSHADOW, Type::Sampler1DArrayShadow); + ast(1) = makeBasicType(T_SAMPLER1DARRAYSHADOW, TypeAST::Sampler1DArrayShadow); } break; ./ type_specifier_nonarray ::= SAMPLER2DARRAYSHADOW ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLER2DARRAYSHADOW, Type::Sampler2DArrayShadow); + ast(1) = makeBasicType(T_SAMPLER2DARRAYSHADOW, TypeAST::Sampler2DArrayShadow); } break; ./ type_specifier_nonarray ::= SAMPLERCUBEARRAY ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLERCUBEARRAY, Type::SamplerCubeShadow); + ast(1) = makeBasicType(T_SAMPLERCUBEARRAY, TypeAST::SamplerCubeShadow); } break; ./ type_specifier_nonarray ::= SAMPLERCUBEARRAYSHADOW ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLERCUBEARRAYSHADOW, Type::SamplerCubeArrayShadow); + ast(1) = makeBasicType(T_SAMPLERCUBEARRAYSHADOW, TypeAST::SamplerCubeArrayShadow); } break; ./ type_specifier_nonarray ::= ISAMPLER1D ; /. case $rule_number: { - ast(1) = makeBasicType(T_ISAMPLER1D, Type::Sampler1D); + ast(1) = makeBasicType(T_ISAMPLER1D, TypeAST::Sampler1D); } break; ./ type_specifier_nonarray ::= ISAMPLER2D ; /. case $rule_number: { - ast(1) = makeBasicType(T_ISAMPLER2D, Type::Sampler2D); + ast(1) = makeBasicType(T_ISAMPLER2D, TypeAST::Sampler2D); } break; ./ type_specifier_nonarray ::= ISAMPLER3D ; /. case $rule_number: { - ast(1) = makeBasicType(T_ISAMPLER3D, Type::Sampler3D); + ast(1) = makeBasicType(T_ISAMPLER3D, TypeAST::Sampler3D); } break; ./ type_specifier_nonarray ::= ISAMPLERCUBE ; /. case $rule_number: { - ast(1) = makeBasicType(T_ISAMPLERCUBE, Type::SamplerCube); + ast(1) = makeBasicType(T_ISAMPLERCUBE, TypeAST::SamplerCube); } break; ./ type_specifier_nonarray ::= ISAMPLER1DARRAY ; /. case $rule_number: { - ast(1) = makeBasicType(T_ISAMPLER1DARRAY, Type::Sampler1DArray); + ast(1) = makeBasicType(T_ISAMPLER1DARRAY, TypeAST::Sampler1DArray); } break; ./ type_specifier_nonarray ::= ISAMPLER2DARRAY ; /. case $rule_number: { - ast(1) = makeBasicType(T_ISAMPLER2DARRAY, Type::Sampler2DArray); + ast(1) = makeBasicType(T_ISAMPLER2DARRAY, TypeAST::Sampler2DArray); } break; ./ type_specifier_nonarray ::= ISAMPLERCUBEARRAY ; /. case $rule_number: { - ast(1) = makeBasicType(T_ISAMPLERCUBEARRAY, Type::SamplerCubeArray); + ast(1) = makeBasicType(T_ISAMPLERCUBEARRAY, TypeAST::SamplerCubeArray); } break; ./ type_specifier_nonarray ::= USAMPLER1D ; /. case $rule_number: { - ast(1) = makeBasicType(T_USAMPLER1D, Type::Sampler1D); + ast(1) = makeBasicType(T_USAMPLER1D, TypeAST::Sampler1D); } break; ./ type_specifier_nonarray ::= USAMPLER2D ; /. case $rule_number: { - ast(1) = makeBasicType(T_USAMPLER2D, Type::Sampler2D); + ast(1) = makeBasicType(T_USAMPLER2D, TypeAST::Sampler2D); } break; ./ type_specifier_nonarray ::= USAMPLER3D ; /. case $rule_number: { - ast(1) = makeBasicType(T_USAMPLER3D, Type::Sampler3D); + ast(1) = makeBasicType(T_USAMPLER3D, TypeAST::Sampler3D); } break; ./ type_specifier_nonarray ::= USAMPLERCUBE ; /. case $rule_number: { - ast(1) = makeBasicType(T_USAMPLERCUBE, Type::SamplerCube); + ast(1) = makeBasicType(T_USAMPLERCUBE, TypeAST::SamplerCube); } break; ./ type_specifier_nonarray ::= USAMPLER1DARRAY ; /. case $rule_number: { - ast(1) = makeBasicType(T_USAMPLER1DARRAY, Type::Sampler1DArray); + ast(1) = makeBasicType(T_USAMPLER1DARRAY, TypeAST::Sampler1DArray); } break; ./ type_specifier_nonarray ::= USAMPLER2DARRAY ; /. case $rule_number: { - ast(1) = makeBasicType(T_USAMPLER2DARRAY, Type::Sampler2DArray); + ast(1) = makeBasicType(T_USAMPLER2DARRAY, TypeAST::Sampler2DArray); } break; ./ type_specifier_nonarray ::= USAMPLERCUBEARRAY ; /. case $rule_number: { - ast(1) = makeBasicType(T_USAMPLERCUBEARRAY, Type::SamplerCubeArray); + ast(1) = makeBasicType(T_USAMPLERCUBEARRAY, TypeAST::SamplerCubeArray); } break; ./ type_specifier_nonarray ::= SAMPLER2DRECT ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLER2DRECT, Type::Sampler2DRect); + ast(1) = makeBasicType(T_SAMPLER2DRECT, TypeAST::Sampler2DRect); } break; ./ type_specifier_nonarray ::= SAMPLER2DRECTSHADOW ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLER2DRECTSHADOW, Type::Sampler2DRectShadow); + ast(1) = makeBasicType(T_SAMPLER2DRECTSHADOW, TypeAST::Sampler2DRectShadow); } break; ./ type_specifier_nonarray ::= ISAMPLER2DRECT ; /. case $rule_number: { - ast(1) = makeBasicType(T_ISAMPLER2DRECT, Type::Sampler2DRect); + ast(1) = makeBasicType(T_ISAMPLER2DRECT, TypeAST::Sampler2DRect); } break; ./ type_specifier_nonarray ::= USAMPLER2DRECT ; /. case $rule_number: { - ast(1) = makeBasicType(T_USAMPLER2DRECT, Type::Sampler2DRect); + ast(1) = makeBasicType(T_USAMPLER2DRECT, TypeAST::Sampler2DRect); } break; ./ type_specifier_nonarray ::= SAMPLERBUFFER ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLERBUFFER, Type::SamplerBuffer); + ast(1) = makeBasicType(T_SAMPLERBUFFER, TypeAST::SamplerBuffer); } break; ./ type_specifier_nonarray ::= ISAMPLERBUFFER ; /. case $rule_number: { - ast(1) = makeBasicType(T_ISAMPLERBUFFER, Type::SamplerBuffer); + ast(1) = makeBasicType(T_ISAMPLERBUFFER, TypeAST::SamplerBuffer); } break; ./ type_specifier_nonarray ::= USAMPLERBUFFER ; /. case $rule_number: { - ast(1) = makeBasicType(T_USAMPLERBUFFER, Type::SamplerBuffer); + ast(1) = makeBasicType(T_USAMPLERBUFFER, TypeAST::SamplerBuffer); } break; ./ type_specifier_nonarray ::= SAMPLER2DMS ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLER2DMS, Type::Sampler2DMS); + ast(1) = makeBasicType(T_SAMPLER2DMS, TypeAST::Sampler2DMS); } break; ./ type_specifier_nonarray ::= ISAMPLER2DMS ; /. case $rule_number: { - ast(1) = makeBasicType(T_ISAMPLER2DMS, Type::Sampler2DMS); + ast(1) = makeBasicType(T_ISAMPLER2DMS, TypeAST::Sampler2DMS); } break; ./ type_specifier_nonarray ::= USAMPLER2DMS ; /. case $rule_number: { - ast(1) = makeBasicType(T_USAMPLER2DMS, Type::Sampler2DMS); + ast(1) = makeBasicType(T_USAMPLER2DMS, TypeAST::Sampler2DMS); } break; ./ type_specifier_nonarray ::= SAMPLER2DMSARRAY ; /. case $rule_number: { - ast(1) = makeBasicType(T_SAMPLER2DMSARRAY, Type::Sampler2DMSArray); + ast(1) = makeBasicType(T_SAMPLER2DMSARRAY, TypeAST::Sampler2DMSArray); } break; ./ type_specifier_nonarray ::= ISAMPLER2DMSARRAY ; /. case $rule_number: { - ast(1) = makeBasicType(T_ISAMPLER2DMSARRAY, Type::Sampler2DMSArray); + ast(1) = makeBasicType(T_ISAMPLER2DMSARRAY, TypeAST::Sampler2DMSArray); } break; ./ type_specifier_nonarray ::= USAMPLER2DMSARRAY ; /. case $rule_number: { - ast(1) = makeBasicType(T_USAMPLER2DMSARRAY, Type::Sampler2DMSArray); + ast(1) = makeBasicType(T_USAMPLER2DMSARRAY, TypeAST::Sampler2DMSArray); } break; ./ @@ -2410,42 +2410,42 @@ case $rule_number: { type_specifier_nonarray ::= TYPE_NAME ; /. case $rule_number: { - ast(1) = makeAstNode(string(1)); + ast(1) = makeAstNode(string(1)); } break; ./ precision_qualifier ::= HIGHP ; /. case $rule_number: { - sym(1).precision = Type::Highp; + sym(1).precision = TypeAST::Highp; } break; ./ precision_qualifier ::= MEDIUMP ; /. case $rule_number: { - sym(1).precision = Type::Mediump; + sym(1).precision = TypeAST::Mediump; } break; ./ precision_qualifier ::= LOWP ; /. case $rule_number: { - sym(1).precision = Type::Lowp; + sym(1).precision = TypeAST::Lowp; } break; ./ struct_specifier ::= STRUCT IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE ; /. case $rule_number: { - ast(1) = makeAstNode(string(2), sym(4).field_list); + ast(1) = makeAstNode(string(2), sym(4).field_list); } break; ./ struct_specifier ::= STRUCT LEFT_BRACE struct_declaration_list RIGHT_BRACE ; /. case $rule_number: { - ast(1) = makeAstNode(sym(3).field_list); + ast(1) = makeAstNode(sym(3).field_list); } break; ./ @@ -2466,15 +2466,15 @@ case $rule_number: { struct_declaration ::= type_specifier struct_declarator_list SEMICOLON ; /. case $rule_number: { - sym(1).field_list = StructType::fixInnerTypes(type(1), sym(2).field_list); + sym(1).field_list = StructTypeAST::fixInnerTypes(type(1), sym(2).field_list); } break; ./ struct_declaration ::= type_qualifier type_specifier struct_declarator_list SEMICOLON ; /. case $rule_number: { - sym(1).field_list = StructType::fixInnerTypes - (makeAstNode + sym(1).field_list = StructTypeAST::fixInnerTypes + (makeAstNode (sym(1).type_qualifier.qualifier, type(2), sym(1).type_qualifier.layout_list), sym(3).field_list); } break; @@ -2484,37 +2484,37 @@ struct_declarator_list ::= struct_declarator ; /. case $rule_number: { // nothing to do. - sym(1).field_list = makeAstNode< List >(sym(1).field); + sym(1).field_list = makeAstNode< List >(sym(1).field); } break; ./ struct_declarator_list ::= struct_declarator_list COMMA struct_declarator ; /. case $rule_number: { - sym(1).field_list = makeAstNode< List >(sym(1).field_list, sym(3).field); + sym(1).field_list = makeAstNode< List >(sym(1).field_list, sym(3).field); } break; ./ struct_declarator ::= IDENTIFIER ; /. case $rule_number: { - sym(1).field = makeAstNode(string(1)); + sym(1).field = makeAstNode(string(1)); } break; ./ struct_declarator ::= IDENTIFIER LEFT_BRACKET RIGHT_BRACKET ; /. case $rule_number: { - sym(1).field = makeAstNode - (string(1), makeAstNode((Type *)0)); + sym(1).field = makeAstNode + (string(1), makeAstNode((TypeAST *)0)); } break; ./ struct_declarator ::= IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET ; /. case $rule_number: { - sym(1).field = makeAstNode - (string(1), makeAstNode((Type *)0, expression(3))); + sym(1).field = makeAstNode + (string(1), makeAstNode((TypeAST *)0, expression(3))); } break; ./ @@ -2528,7 +2528,7 @@ case $rule_number: { declaration_statement ::= declaration ; /. case $rule_number: { - ast(1) = makeAstNode(sym(1).declaration_list); + ast(1) = makeAstNode(sym(1).declaration_list); } break; ./ @@ -2598,14 +2598,14 @@ case $rule_number: { compound_statement ::= LEFT_BRACE RIGHT_BRACE ; /. case $rule_number: { - ast(1) = makeAstNode(); + ast(1) = makeAstNode(); } break; ./ compound_statement ::= LEFT_BRACE statement_list RIGHT_BRACE ; /. case $rule_number: { - ast(1) = makeAstNode(sym(2).statement_list); + ast(1) = makeAstNode(sym(2).statement_list); } break; ./ @@ -2626,49 +2626,49 @@ case $rule_number: { compound_statement_no_new_scope ::= LEFT_BRACE RIGHT_BRACE ; /. case $rule_number: { - ast(1) = makeAstNode(); + ast(1) = makeAstNode(); } break; ./ compound_statement_no_new_scope ::= LEFT_BRACE statement_list RIGHT_BRACE ; /. case $rule_number: { - ast(1) = makeAstNode(sym(2).statement_list); + ast(1) = makeAstNode(sym(2).statement_list); } break; ./ statement_list ::= statement ; /. case $rule_number: { - sym(1).statement_list = makeAstNode< List >(sym(1).statement); + sym(1).statement_list = makeAstNode< List >(sym(1).statement); } break; ./ statement_list ::= statement_list statement ; /. case $rule_number: { - sym(1).statement_list = makeAstNode< List >(sym(1).statement_list, sym(2).statement); + sym(1).statement_list = makeAstNode< List >(sym(1).statement_list, sym(2).statement); } break; ./ expression_statement ::= SEMICOLON ; /. case $rule_number: { - ast(1) = makeAstNode(); // Empty statement + ast(1) = makeAstNode(); // Empty statement } break; ./ expression_statement ::= expression SEMICOLON ; /. case $rule_number: { - ast(1) = makeAstNode(expression(1)); + ast(1) = makeAstNode(expression(1)); } break; ./ selection_statement ::= IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement ; /. case $rule_number: { - ast(1) = makeAstNode(expression(3), sym(5).ifstmt.thenClause, sym(5).ifstmt.elseClause); + ast(1) = makeAstNode(expression(3), sym(5).ifstmt.thenClause, sym(5).ifstmt.elseClause); } break; ./ @@ -2698,7 +2698,7 @@ case $rule_number: { condition ::= fully_specified_type IDENTIFIER EQUAL initializer ; /. case $rule_number: { - ast(1) = makeAstNode + ast(1) = makeAstNode (type(1), string(2), expression(4)); } break; ./ @@ -2706,56 +2706,56 @@ case $rule_number: { switch_statement ::= SWITCH LEFT_PAREN expression RIGHT_PAREN LEFT_BRACE switch_statement_list RIGHT_BRACE ; /. case $rule_number: { - ast(1) = makeAstNode(expression(3), statement(6)); + ast(1) = makeAstNode(expression(3), statement(6)); } break; ./ switch_statement_list ::= empty ; /. case $rule_number: { - ast(1) = makeAstNode(); + ast(1) = makeAstNode(); } break; ./ switch_statement_list ::= statement_list ; /. case $rule_number: { - ast(1) = makeAstNode(sym(1).statement_list); + ast(1) = makeAstNode(sym(1).statement_list); } break; ./ case_label ::= CASE expression COLON ; /. case $rule_number: { - ast(1) = makeAstNode(expression(2)); + ast(1) = makeAstNode(expression(2)); } break; ./ case_label ::= DEFAULT COLON ; /. case $rule_number: { - ast(1) = makeAstNode(); + ast(1) = makeAstNode(); } break; ./ iteration_statement ::= WHILE LEFT_PAREN condition RIGHT_PAREN statement_no_new_scope ; /. case $rule_number: { - ast(1) = makeAstNode(expression(3), statement(5)); + ast(1) = makeAstNode(expression(3), statement(5)); } break; ./ iteration_statement ::= DO statement WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON ; /. case $rule_number: { - ast(1) = makeAstNode(statement(2), expression(5)); + ast(1) = makeAstNode(statement(2), expression(5)); } break; ./ iteration_statement ::= FOR LEFT_PAREN for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope ; /. case $rule_number: { - ast(1) = makeAstNode(statement(3), sym(4).forstmt.condition, sym(4).forstmt.increment, statement(6)); + ast(1) = makeAstNode(statement(3), sym(4).forstmt.condition, sym(4).forstmt.increment, statement(6)); } break; ./ @@ -2806,42 +2806,42 @@ case $rule_number: { jump_statement ::= CONTINUE SEMICOLON ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_Continue); + ast(1) = makeAstNode(AST::Kind_Continue); } break; ./ jump_statement ::= BREAK SEMICOLON ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_Break); + ast(1) = makeAstNode(AST::Kind_Break); } break; ./ jump_statement ::= RETURN SEMICOLON ; /. case $rule_number: { - ast(1) = makeAstNode(); + ast(1) = makeAstNode(); } break; ./ jump_statement ::= RETURN expression SEMICOLON ; /. case $rule_number: { - ast(1) = makeAstNode(expression(2)); + ast(1) = makeAstNode(expression(2)); } break; ./ jump_statement ::= DISCARD SEMICOLON ; /. case $rule_number: { - ast(1) = makeAstNode(AST::Kind_Discard); + ast(1) = makeAstNode(AST::Kind_Discard); } break; ./ translation_unit ::= external_declaration_list ; /. case $rule_number: { - ast(1) = makeAstNode(sym(1).declaration_list); + ast(1) = makeAstNode(sym(1).declaration_list); } break; ./ @@ -2849,7 +2849,7 @@ external_declaration_list ::= external_declaration ; /. case $rule_number: { if (sym(1).declaration) { - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration); } else { sym(1).declaration_list = 0; @@ -2861,11 +2861,11 @@ external_declaration_list ::= external_declaration_list external_declaration ; /. case $rule_number: { if (sym(1).declaration_list && sym(2).declaration) { - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, sym(2).declaration); } else if (!sym(1).declaration_list) { if (sym(2).declaration) { - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(2).declaration); } else { sym(1).declaration_list = 0; diff --git a/src/libs/glsl/glsl.h b/src/libs/glsl/glsl.h index 09cb97dfc7..016a270bb4 100644 --- a/src/libs/glsl/glsl.h +++ b/src/libs/glsl/glsl.h @@ -47,6 +47,20 @@ class Engine; class Lexer; class Parser; class MemoryPool; + +// types +class Type; +class UndefinedType; +class VoidType; +class BoolType; +class IntType; +class UIntType; +class FloatType; +class DoubleType; +class OpaqueType; +class VectorType; +class MatrixType; + class AST; template class List; } diff --git a/src/libs/glsl/glslast.cpp b/src/libs/glsl/glslast.cpp index 7f81e59f28..2c1f906cfc 100644 --- a/src/libs/glsl/glslast.cpp +++ b/src/libs/glsl/glslast.cpp @@ -45,7 +45,7 @@ void AST::accept(AST *ast, Visitor *visitor) ast->accept(visitor); } -void TranslationUnit::accept0(Visitor *visitor) +void TranslationUnitAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(declarations, visitor); @@ -53,19 +53,19 @@ void TranslationUnit::accept0(Visitor *visitor) visitor->endVisit(this); } -void IdentifierExpression::accept0(Visitor *visitor) +void IdentifierExpressionAST::accept0(Visitor *visitor) { visitor->visit(this); visitor->endVisit(this); } -void LiteralExpression::accept0(Visitor *visitor) +void LiteralExpressionAST::accept0(Visitor *visitor) { visitor->visit(this); visitor->endVisit(this); } -void BinaryExpression::accept0(Visitor *visitor) +void BinaryExpressionAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(left, visitor); @@ -74,14 +74,14 @@ void BinaryExpression::accept0(Visitor *visitor) visitor->endVisit(this); } -void UnaryExpression::accept0(Visitor *visitor) +void UnaryExpressionAST::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(expr, visitor); visitor->endVisit(this); } -void TernaryExpression::accept0(Visitor *visitor) +void TernaryExpressionAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(first, visitor); @@ -91,7 +91,7 @@ void TernaryExpression::accept0(Visitor *visitor) visitor->endVisit(this); } -void AssignmentExpression::accept0(Visitor *visitor) +void AssignmentExpressionAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(variable, visitor); @@ -100,14 +100,14 @@ void AssignmentExpression::accept0(Visitor *visitor) visitor->endVisit(this); } -void MemberAccessExpression::accept0(Visitor *visitor) +void MemberAccessExpressionAST::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(expr, visitor); visitor->endVisit(this); } -void FunctionCallExpression::accept0(Visitor *visitor) +void FunctionCallExpressionAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(expr, visitor); @@ -117,14 +117,14 @@ void FunctionCallExpression::accept0(Visitor *visitor) visitor->endVisit(this); } -void FunctionIdentifier::accept0(Visitor *visitor) +void FunctionIdentifierAST::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(type, visitor); visitor->endVisit(this); } -void DeclarationExpression::accept0(Visitor *visitor) +void DeclarationExpressionAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(type, visitor); @@ -133,21 +133,21 @@ void DeclarationExpression::accept0(Visitor *visitor) visitor->endVisit(this); } -void ExpressionStatement::accept0(Visitor *visitor) +void ExpressionStatementAST::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(expr, visitor); visitor->endVisit(this); } -void CompoundStatement::accept0(Visitor *visitor) +void CompoundStatementAST::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(statements, visitor); visitor->endVisit(this); } -void IfStatement::accept0(Visitor *visitor) +void IfStatementAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(condition, visitor); @@ -157,7 +157,7 @@ void IfStatement::accept0(Visitor *visitor) visitor->endVisit(this); } -void WhileStatement::accept0(Visitor *visitor) +void WhileStatementAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(condition, visitor); @@ -166,7 +166,7 @@ void WhileStatement::accept0(Visitor *visitor) visitor->endVisit(this); } -void DoStatement::accept0(Visitor *visitor) +void DoStatementAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(body, visitor); @@ -175,7 +175,7 @@ void DoStatement::accept0(Visitor *visitor) visitor->endVisit(this); } -void ForStatement::accept0(Visitor *visitor) +void ForStatementAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(init, visitor); @@ -186,20 +186,20 @@ void ForStatement::accept0(Visitor *visitor) visitor->endVisit(this); } -void JumpStatement::accept0(Visitor *visitor) +void JumpStatementAST::accept0(Visitor *visitor) { visitor->visit(this); visitor->endVisit(this); } -void ReturnStatement::accept0(Visitor *visitor) +void ReturnStatementAST::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(expr, visitor); visitor->endVisit(this); } -void SwitchStatement::accept0(Visitor *visitor) +void SwitchStatementAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(expr, visitor); @@ -208,22 +208,22 @@ void SwitchStatement::accept0(Visitor *visitor) visitor->endVisit(this); } -void CaseLabelStatement::accept0(Visitor *visitor) +void CaseLabelStatementAST::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(expr, visitor); visitor->endVisit(this); } -void DeclarationStatement::accept0(Visitor *visitor) +void DeclarationStatementAST::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(decls, visitor); visitor->endVisit(this); } -BasicType::BasicType(int _token, const char *_name, Category _category) - : Type(Kind_BasicType), token(_token), name(_name), categ(_category) +BasicTypeAST::BasicTypeAST(int _token, const char *_name, Category _category) + : TypeAST(Kind_BasicType), token(_token), name(_name), categ(_category) { switch (token) { case GLSLParserTable::T_VOID: @@ -239,18 +239,18 @@ BasicType::BasicType(int _token, const char *_name, Category _category) } } -void BasicType::accept0(Visitor *visitor) +void BasicTypeAST::accept0(Visitor *visitor) { visitor->visit(this); visitor->endVisit(this); } -Type::Precision BasicType::precision() const +TypeAST::Precision BasicTypeAST::precision() const { return prec; } -bool BasicType::setPrecision(Precision precision) +bool BasicTypeAST::setPrecision(Precision precision) { if (prec == PrecNotValid) return false; @@ -258,24 +258,24 @@ bool BasicType::setPrecision(Precision precision) return true; } -void NamedType::accept0(Visitor *visitor) +void NamedTypeAST::accept0(Visitor *visitor) { visitor->visit(this); visitor->endVisit(this); } -Type::Precision NamedType::precision() const +TypeAST::Precision NamedTypeAST::precision() const { // Named types are typically structs, which cannot have their precision set. return PrecNotValid; } -bool NamedType::setPrecision(Precision) +bool NamedTypeAST::setPrecision(Precision) { return false; } -void ArrayType::accept0(Visitor *visitor) +void ArrayTypeAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(elementType, visitor); @@ -284,12 +284,12 @@ void ArrayType::accept0(Visitor *visitor) visitor->endVisit(this); } -Type::Precision ArrayType::precision() const +TypeAST::Precision ArrayTypeAST::precision() const { return elementType ? elementType->precision() : PrecNotValid; } -bool ArrayType::setPrecision(Precision precision) +bool ArrayTypeAST::setPrecision(Precision precision) { if (elementType) return elementType->setPrecision(precision); @@ -297,39 +297,39 @@ bool ArrayType::setPrecision(Precision precision) return false; } -void StructType::accept0(Visitor *visitor) +void StructTypeAST::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(fields, visitor); visitor->endVisit(this); } -Type::Precision StructType::precision() const +TypeAST::Precision StructTypeAST::precision() const { return PrecNotValid; } -bool StructType::setPrecision(Precision) +bool StructTypeAST::setPrecision(Precision) { // Structs cannot have a precision set. return false; } -void StructType::Field::accept0(Visitor *visitor) +void StructTypeAST::Field::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(type, visitor); visitor->endVisit(this); } -void StructType::Field::setInnerType(Type *innerType) +void StructTypeAST::Field::setInnerType(TypeAST *innerType) { if (!innerType) return; - Type **parent = &type; - Type *inner = type; + TypeAST **parent = &type; + TypeAST *inner = type; while (inner != 0) { - ArrayType *array = inner->asArrayType(); + ArrayTypeAST *array = inner->asArrayType(); if (!array) break; parent = &(array->elementType); @@ -338,7 +338,7 @@ void StructType::Field::setInnerType(Type *innerType) *parent = innerType; } -List *StructType::fixInnerTypes(Type *innerType, List *fields) +List *StructTypeAST::fixInnerTypes(TypeAST *innerType, List *fields) { if (!fields) return fields; @@ -351,28 +351,28 @@ List *StructType::fixInnerTypes(Type *innerType, Listvisit(this)) accept(type, visitor); visitor->endVisit(this); } -void PrecisionDeclaration::accept0(Visitor *visitor) +void PrecisionDeclarationAST::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(type, visitor); visitor->endVisit(this); } -void ParameterDeclaration::accept0(Visitor *visitor) +void ParameterDeclarationAST::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(type, visitor); visitor->endVisit(this); } -void VariableDeclaration::accept0(Visitor *visitor) +void VariableDeclarationAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(type, visitor); @@ -381,20 +381,20 @@ void VariableDeclaration::accept0(Visitor *visitor) visitor->endVisit(this); } -Type *VariableDeclaration::declarationType(List *decls) +TypeAST *VariableDeclarationAST::declarationType(List *decls) { - VariableDeclaration *var = decls->value->asVariableDeclaration(); + VariableDeclarationAST *var = decls->value->asVariableDeclaration(); return var ? var->type : 0; } -void TypeDeclaration::accept0(Visitor *visitor) +void TypeDeclarationAST::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(type, visitor); visitor->endVisit(this); } -void TypeAndVariableDeclaration::accept0(Visitor *visitor) +void TypeAndVariableDeclarationAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(typeDecl, visitor); @@ -403,20 +403,20 @@ void TypeAndVariableDeclaration::accept0(Visitor *visitor) visitor->endVisit(this); } -void InvariantDeclaration::accept0(Visitor *visitor) +void InvariantDeclarationAST::accept0(Visitor *visitor) { visitor->visit(this); visitor->endVisit(this); } -void InitDeclaration::accept0(Visitor *visitor) +void InitDeclarationAST::accept0(Visitor *visitor) { if (visitor->visit(this)) accept(decls, visitor); visitor->endVisit(this); } -void FunctionDeclaration::accept0(Visitor *visitor) +void FunctionDeclarationAST::accept0(Visitor *visitor) { if (visitor->visit(this)) { accept(returnType, visitor); diff --git a/src/libs/glsl/glslast.h b/src/libs/glsl/glslast.h index dcea195f9b..0fecb9b380 100644 --- a/src/libs/glsl/glslast.h +++ b/src/libs/glsl/glslast.h @@ -36,45 +36,45 @@ namespace GLSL { class AST; -class TranslationUnit; -class Expression; -class IdentifierExpression; -class LiteralExpression; -class BinaryExpression; -class UnaryExpression; -class TernaryExpression; -class AssignmentExpression; -class MemberAccessExpression; -class FunctionCallExpression; -class FunctionIdentifier; -class DeclarationExpression; -class Statement; -class ExpressionStatement; -class CompoundStatement; -class IfStatement; -class WhileStatement; -class DoStatement; -class ForStatement; -class JumpStatement; -class ReturnStatement; -class SwitchStatement; -class CaseLabelStatement; -class DeclarationStatement; -class Type; -class BasicType; -class NamedType; -class ArrayType; -class StructType; -class QualifiedType; -class Declaration; -class PrecisionDeclaration; -class ParameterDeclaration; -class VariableDeclaration; -class TypeDeclaration; -class TypeAndVariableDeclaration; -class InvariantDeclaration; -class InitDeclaration; -class FunctionDeclaration; +class TranslationUnitAST; +class ExpressionAST; +class IdentifierExpressionAST; +class LiteralExpressionAST; +class BinaryExpressionAST; +class UnaryExpressionAST; +class TernaryExpressionAST; +class AssignmentExpressionAST; +class MemberAccessExpressionAST; +class FunctionCallExpressionAST; +class FunctionIdentifierAST; +class DeclarationExpressionAST; +class StatementAST; +class ExpressionStatementAST; +class CompoundStatementAST; +class IfStatementAST; +class WhileStatementAST; +class DoStatementAST; +class ForStatementAST; +class JumpStatementAST; +class ReturnStatementAST; +class SwitchStatementAST; +class CaseLabelStatementAST; +class DeclarationStatementAST; +class TypeAST; +class BasicTypeAST; +class NamedTypeAST; +class ArrayTypeAST; +class StructTypeAST; +class QualifiedTypeAST; +class DeclarationAST; +class PrecisionDeclarationAST; +class ParameterDeclarationAST; +class VariableDeclarationAST; +class TypeDeclarationAST; +class TypeAndVariableDeclarationAST; +class InvariantDeclarationAST; +class InitDeclarationAST; +class FunctionDeclarationAST; class Visitor; template @@ -223,49 +223,49 @@ public: Kind_FunctionDeclaration }; - virtual TranslationUnit *asTranslationUnit() { return 0; } - - virtual Expression *asExpression() { return 0; } - virtual IdentifierExpression *asIdentifierExpression() { return 0; } - virtual LiteralExpression *asLiteralExpression() { return 0; } - virtual BinaryExpression *asBinaryExpression() { return 0; } - virtual UnaryExpression *asUnaryExpression() { return 0; } - virtual TernaryExpression *asTernaryExpression() { return 0; } - virtual AssignmentExpression *asAssignmentExpression() { return 0; } - virtual MemberAccessExpression *asMemberAccessExpression() { return 0; } - virtual FunctionCallExpression *asFunctionCallExpression() { return 0; } - virtual FunctionIdentifier *asFunctionIdentifier() { return 0; } - virtual DeclarationExpression *asDeclarationExpression() { return 0; } - - virtual Statement *asStatement() { return 0; } - virtual ExpressionStatement *asExpressionStatement() { return 0; } - virtual CompoundStatement *asCompoundStatement() { return 0; } - virtual IfStatement *asIfStatement() { return 0; } - virtual WhileStatement *asWhileStatement() { return 0; } - virtual DoStatement *asDoStatement() { return 0; } - virtual ForStatement *asForStatement() { return 0; } - virtual JumpStatement *asJumpStatement() { return 0; } - virtual ReturnStatement *asReturnStatement() { return 0; } - virtual SwitchStatement *asSwitchStatement() { return 0; } - virtual CaseLabelStatement *asCaseLabelStatement() { return 0; } - virtual DeclarationStatement *asDeclarationStatement() { return 0; } - - virtual Type *asType() { return 0; } - virtual BasicType *asBasicType() { return 0; } - virtual NamedType *asNamedType() { return 0; } - virtual ArrayType *asArrayType() { return 0; } - virtual StructType *asStructType() { return 0; } - virtual QualifiedType *asQualifiedType() { return 0; } - - virtual Declaration *asDeclaration() { return 0; } - virtual PrecisionDeclaration *asPrecisionDeclaration() { return 0; } - virtual ParameterDeclaration *asParameterDeclaration() { return 0; } - virtual VariableDeclaration *asVariableDeclaration() { return 0; } - virtual TypeDeclaration *asTypeDeclaration() { return 0; } - virtual TypeAndVariableDeclaration *asTypeAndVariableDeclaration() { return 0; } - virtual InvariantDeclaration *asInvariantDeclaration() { return 0; } - virtual InitDeclaration *asInitDeclaration() { return 0; } - virtual FunctionDeclaration *asFunctionDeclaration() { return 0; } + virtual TranslationUnitAST *asTranslationUnit() { return 0; } + + virtual ExpressionAST *asExpression() { return 0; } + virtual IdentifierExpressionAST *asIdentifierExpression() { return 0; } + virtual LiteralExpressionAST *asLiteralExpression() { return 0; } + virtual BinaryExpressionAST *asBinaryExpression() { return 0; } + virtual UnaryExpressionAST *asUnaryExpression() { return 0; } + virtual TernaryExpressionAST *asTernaryExpression() { return 0; } + virtual AssignmentExpressionAST *asAssignmentExpression() { return 0; } + virtual MemberAccessExpressionAST *asMemberAccessExpression() { return 0; } + virtual FunctionCallExpressionAST *asFunctionCallExpression() { return 0; } + virtual FunctionIdentifierAST *asFunctionIdentifier() { return 0; } + virtual DeclarationExpressionAST *asDeclarationExpression() { return 0; } + + virtual StatementAST *asStatement() { return 0; } + virtual ExpressionStatementAST *asExpressionStatement() { return 0; } + virtual CompoundStatementAST *asCompoundStatement() { return 0; } + virtual IfStatementAST *asIfStatement() { return 0; } + virtual WhileStatementAST *asWhileStatement() { return 0; } + virtual DoStatementAST *asDoStatement() { return 0; } + virtual ForStatementAST *asForStatement() { return 0; } + virtual JumpStatementAST *asJumpStatement() { return 0; } + virtual ReturnStatementAST *asReturnStatement() { return 0; } + virtual SwitchStatementAST *asSwitchStatement() { return 0; } + virtual CaseLabelStatementAST *asCaseLabelStatement() { return 0; } + virtual DeclarationStatementAST *asDeclarationStatement() { return 0; } + + virtual TypeAST *asType() { return 0; } + virtual BasicTypeAST *asBasicType() { return 0; } + virtual NamedTypeAST *asNamedType() { return 0; } + virtual ArrayTypeAST *asArrayType() { return 0; } + virtual StructTypeAST *asStructType() { return 0; } + virtual QualifiedTypeAST *asQualifiedType() { return 0; } + + virtual DeclarationAST *asDeclaration() { return 0; } + virtual PrecisionDeclarationAST *asPrecisionDeclaration() { return 0; } + virtual ParameterDeclarationAST *asParameterDeclaration() { return 0; } + virtual VariableDeclarationAST *asVariableDeclaration() { return 0; } + virtual TypeDeclarationAST *asTypeDeclaration() { return 0; } + virtual TypeAndVariableDeclarationAST *asTypeAndVariableDeclaration() { return 0; } + virtual InvariantDeclarationAST *asInvariantDeclaration() { return 0; } + virtual InitDeclarationAST *asInitDeclaration() { return 0; } + virtual FunctionDeclarationAST *asFunctionDeclaration() { return 0; } void accept(Visitor *visitor); static void accept(AST *ast, Visitor *visitor); @@ -298,36 +298,36 @@ protected: ~AST() {} // Managed types cannot be deleted. }; -class GLSL_EXPORT TranslationUnit: public AST +class GLSL_EXPORT TranslationUnitAST: public AST { public: - TranslationUnit(List *declarations) + TranslationUnitAST(List *declarations) : AST(Kind_TranslationUnit), declarations(finish(declarations)) {} - virtual TranslationUnit *asTranslationUnit() { return this; } + virtual TranslationUnitAST *asTranslationUnit() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - List *declarations; + List *declarations; }; -class GLSL_EXPORT Expression: public AST +class GLSL_EXPORT ExpressionAST: public AST { protected: - Expression(Kind _kind) : AST(_kind) {} + ExpressionAST(Kind _kind) : AST(_kind) {} public: - virtual Expression *asExpression() { return this; } + virtual ExpressionAST *asExpression() { return this; } }; -class GLSL_EXPORT IdentifierExpression: public Expression +class GLSL_EXPORT IdentifierExpressionAST: public ExpressionAST { public: - IdentifierExpression(const QString *_name) - : Expression(Kind_Identifier), name(_name) {} + IdentifierExpressionAST(const QString *_name) + : ExpressionAST(Kind_Identifier), name(_name) {} - virtual IdentifierExpression *asIdentifierExpression() { return this; } + virtual IdentifierExpressionAST *asIdentifierExpression() { return this; } virtual void accept0(Visitor *visitor); @@ -335,13 +335,13 @@ public: // attributes const QString *name; }; -class GLSL_EXPORT LiteralExpression: public Expression +class GLSL_EXPORT LiteralExpressionAST: public ExpressionAST { public: - LiteralExpression(const QString *_value) - : Expression(Kind_Literal), value(_value) {} + LiteralExpressionAST(const QString *_value) + : ExpressionAST(Kind_Literal), value(_value) {} - virtual LiteralExpression *asLiteralExpression() { return this; } + virtual LiteralExpressionAST *asLiteralExpression() { return this; } virtual void accept0(Visitor *visitor); @@ -349,314 +349,314 @@ public: // attributes const QString *value; }; -class GLSL_EXPORT BinaryExpression: public Expression +class GLSL_EXPORT BinaryExpressionAST: public ExpressionAST { public: - BinaryExpression(Kind _kind, Expression *_left, Expression *_right) - : Expression(_kind), left(_left), right(_right) {} + BinaryExpressionAST(Kind _kind, ExpressionAST *_left, ExpressionAST *_right) + : ExpressionAST(_kind), left(_left), right(_right) {} - virtual BinaryExpression *asBinaryExpression() { return this; } + virtual BinaryExpressionAST *asBinaryExpression() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Expression *left; - Expression *right; + ExpressionAST *left; + ExpressionAST *right; }; -class GLSL_EXPORT UnaryExpression: public Expression +class GLSL_EXPORT UnaryExpressionAST: public ExpressionAST { public: - UnaryExpression(Kind _kind, Expression *_expr) - : Expression(_kind), expr(_expr) {} + UnaryExpressionAST(Kind _kind, ExpressionAST *_expr) + : ExpressionAST(_kind), expr(_expr) {} - virtual UnaryExpression *asUnaryExpression() { return this; } + virtual UnaryExpressionAST *asUnaryExpression() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Expression *expr; + ExpressionAST *expr; }; -class GLSL_EXPORT TernaryExpression: public Expression +class GLSL_EXPORT TernaryExpressionAST: public ExpressionAST { public: - TernaryExpression(Kind _kind, Expression *_first, Expression *_second, Expression *_third) - : Expression(_kind), first(_first), second(_second), third(_third) {} + TernaryExpressionAST(Kind _kind, ExpressionAST *_first, ExpressionAST *_second, ExpressionAST *_third) + : ExpressionAST(_kind), first(_first), second(_second), third(_third) {} - virtual TernaryExpression *asTernaryExpression() { return this; } + virtual TernaryExpressionAST *asTernaryExpression() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Expression *first; - Expression *second; - Expression *third; + ExpressionAST *first; + ExpressionAST *second; + ExpressionAST *third; }; -class GLSL_EXPORT AssignmentExpression: public Expression +class GLSL_EXPORT AssignmentExpressionAST: public ExpressionAST { public: - AssignmentExpression(Kind _kind, Expression *_variable, Expression *_value) - : Expression(_kind), variable(_variable), value(_value) {} + AssignmentExpressionAST(Kind _kind, ExpressionAST *_variable, ExpressionAST *_value) + : ExpressionAST(_kind), variable(_variable), value(_value) {} - virtual AssignmentExpression *asAssignmentExpression() { return this; } + virtual AssignmentExpressionAST *asAssignmentExpression() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Expression *variable; - Expression *value; + ExpressionAST *variable; + ExpressionAST *value; }; -class GLSL_EXPORT MemberAccessExpression: public Expression +class GLSL_EXPORT MemberAccessExpressionAST: public ExpressionAST { public: - MemberAccessExpression(Expression *_expr, const QString *_field) - : Expression(Kind_MemberAccess), expr(_expr), field(_field) {} + MemberAccessExpressionAST(ExpressionAST *_expr, const QString *_field) + : ExpressionAST(Kind_MemberAccess), expr(_expr), field(_field) {} - virtual MemberAccessExpression *asMemberAccessExpression() { return this; } + virtual MemberAccessExpressionAST *asMemberAccessExpression() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Expression *expr; + ExpressionAST *expr; const QString *field; }; -class GLSL_EXPORT FunctionCallExpression: public Expression +class GLSL_EXPORT FunctionCallExpressionAST: public ExpressionAST { public: - FunctionCallExpression(FunctionIdentifier *_id, - List *_arguments) - : Expression(Kind_FunctionCall), expr(0), id(_id) + FunctionCallExpressionAST(FunctionIdentifierAST *_id, + List *_arguments) + : ExpressionAST(Kind_FunctionCall), expr(0), id(_id) , arguments(finish(_arguments)) {} - FunctionCallExpression(Expression *_expr, FunctionIdentifier *_id, - List *_arguments) - : Expression(Kind_MemberFunctionCall), expr(_expr), id(_id) + FunctionCallExpressionAST(ExpressionAST *_expr, FunctionIdentifierAST *_id, + List *_arguments) + : ExpressionAST(Kind_MemberFunctionCall), expr(_expr), id(_id) , arguments(finish(_arguments)) {} - virtual FunctionCallExpression *asFunctionCallExpression() { return this; } + virtual FunctionCallExpressionAST *asFunctionCallExpression() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Expression *expr; - FunctionIdentifier *id; - List *arguments; + ExpressionAST *expr; + FunctionIdentifierAST *id; + List *arguments; }; -class GLSL_EXPORT FunctionIdentifier: public AST +class GLSL_EXPORT FunctionIdentifierAST: public AST { public: - FunctionIdentifier(const QString *_name) + FunctionIdentifierAST(const QString *_name) : AST(Kind_FunctionIdentifier), name(_name), type(0) {} - FunctionIdentifier(Type *_type) + FunctionIdentifierAST(TypeAST *_type) : AST(Kind_FunctionIdentifier), name(0), type(_type) {} - virtual FunctionIdentifier *asFunctionIdentifier() { return this; } + virtual FunctionIdentifierAST *asFunctionIdentifier() { return this; } virtual void accept0(Visitor *visitor); public: // attributes const QString *name; - Type *type; + TypeAST *type; }; -class GLSL_EXPORT DeclarationExpression: public Expression +class GLSL_EXPORT DeclarationExpressionAST: public ExpressionAST { public: - DeclarationExpression(Type *_type, const QString *_name, - Expression *_initializer) - : Expression(Kind_DeclarationExpression), type(_type) + DeclarationExpressionAST(TypeAST *_type, const QString *_name, + ExpressionAST *_initializer) + : ExpressionAST(Kind_DeclarationExpression), type(_type) , name(_name), initializer(_initializer) {} - virtual DeclarationExpression *asDeclarationExpression() { return this; } + virtual DeclarationExpressionAST *asDeclarationExpression() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Type *type; + TypeAST *type; const QString *name; - Expression *initializer; + ExpressionAST *initializer; }; -class GLSL_EXPORT Statement: public AST +class GLSL_EXPORT StatementAST: public AST { protected: - Statement(Kind _kind) : AST(_kind) {} + StatementAST(Kind _kind) : AST(_kind) {} public: - virtual Statement *asStatement() { return this; } + virtual StatementAST *asStatement() { return this; } }; -class GLSL_EXPORT ExpressionStatement: public Statement +class GLSL_EXPORT ExpressionStatementAST: public StatementAST { public: - ExpressionStatement(Expression *_expr) - : Statement(Kind_ExpressionStatement), expr(_expr) {} + ExpressionStatementAST(ExpressionAST *_expr) + : StatementAST(Kind_ExpressionStatement), expr(_expr) {} - virtual ExpressionStatement *asExpressionStatement() { return this; } + virtual ExpressionStatementAST *asExpressionStatement() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Expression *expr; + ExpressionAST *expr; }; -class GLSL_EXPORT CompoundStatement: public Statement +class GLSL_EXPORT CompoundStatementAST: public StatementAST { public: - CompoundStatement() - : Statement(Kind_CompoundStatement), statements(0) {} - CompoundStatement(List *_statements) - : Statement(Kind_CompoundStatement), statements(finish(_statements)) {} + CompoundStatementAST() + : StatementAST(Kind_CompoundStatement), statements(0) {} + CompoundStatementAST(List *_statements) + : StatementAST(Kind_CompoundStatement), statements(finish(_statements)) {} - virtual CompoundStatement *asCompoundStatement() { return this; } + virtual CompoundStatementAST *asCompoundStatement() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - List *statements; + List *statements; }; -class GLSL_EXPORT IfStatement: public Statement +class GLSL_EXPORT IfStatementAST: public StatementAST { public: - IfStatement(Expression *_condition, Statement *_thenClause, Statement *_elseClause) - : Statement(Kind_If), condition(_condition) + IfStatementAST(ExpressionAST *_condition, StatementAST *_thenClause, StatementAST *_elseClause) + : StatementAST(Kind_If), condition(_condition) , thenClause(_thenClause), elseClause(_elseClause) {} - virtual IfStatement *asIfStatement() { return this; } + virtual IfStatementAST *asIfStatement() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Expression *condition; - Statement *thenClause; - Statement *elseClause; + ExpressionAST *condition; + StatementAST *thenClause; + StatementAST *elseClause; }; -class GLSL_EXPORT WhileStatement: public Statement +class GLSL_EXPORT WhileStatementAST: public StatementAST { public: - WhileStatement(Expression *_condition, Statement *_body) - : Statement(Kind_While), condition(_condition), body(_body) {} + WhileStatementAST(ExpressionAST *_condition, StatementAST *_body) + : StatementAST(Kind_While), condition(_condition), body(_body) {} - virtual WhileStatement *asWhileStatement() { return this; } + virtual WhileStatementAST *asWhileStatement() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Expression *condition; - Statement *body; + ExpressionAST *condition; + StatementAST *body; }; -class GLSL_EXPORT DoStatement: public Statement +class GLSL_EXPORT DoStatementAST: public StatementAST { public: - DoStatement(Statement *_body, Expression *_condition) - : Statement(Kind_Do), body(_body), condition(_condition) {} + DoStatementAST(StatementAST *_body, ExpressionAST *_condition) + : StatementAST(Kind_Do), body(_body), condition(_condition) {} - virtual DoStatement *asDoStatement() { return this; } + virtual DoStatementAST *asDoStatement() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Statement *body; - Expression *condition; + StatementAST *body; + ExpressionAST *condition; }; -class GLSL_EXPORT ForStatement: public Statement +class GLSL_EXPORT ForStatementAST: public StatementAST { public: - ForStatement(Statement *_init, Expression *_condition, Expression *_increment, Statement *_body) - : Statement(Kind_For), init(_init), condition(_condition), increment(_increment), body(_body) {} + ForStatementAST(StatementAST *_init, ExpressionAST *_condition, ExpressionAST *_increment, StatementAST *_body) + : StatementAST(Kind_For), init(_init), condition(_condition), increment(_increment), body(_body) {} - virtual ForStatement *asForStatement() { return this; } + virtual ForStatementAST *asForStatement() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Statement *init; - Expression *condition; - Expression *increment; - Statement *body; + StatementAST *init; + ExpressionAST *condition; + ExpressionAST *increment; + StatementAST *body; }; -class GLSL_EXPORT JumpStatement: public Statement +class GLSL_EXPORT JumpStatementAST: public StatementAST { public: - JumpStatement(Kind _kind) : Statement(_kind) {} + JumpStatementAST(Kind _kind) : StatementAST(_kind) {} - virtual JumpStatement *asJumpStatement() { return this; } + virtual JumpStatementAST *asJumpStatement() { return this; } virtual void accept0(Visitor *visitor); }; -class GLSL_EXPORT ReturnStatement: public Statement +class GLSL_EXPORT ReturnStatementAST: public StatementAST { public: - ReturnStatement() : Statement(Kind_Return), expr(0) {} - ReturnStatement(Expression *_expr) - : Statement(Kind_ReturnExpression), expr(_expr) {} + ReturnStatementAST() : StatementAST(Kind_Return), expr(0) {} + ReturnStatementAST(ExpressionAST *_expr) + : StatementAST(Kind_ReturnExpression), expr(_expr) {} - virtual ReturnStatement *asReturnStatement() { return this; } + virtual ReturnStatementAST *asReturnStatement() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Expression *expr; + ExpressionAST *expr; }; -class GLSL_EXPORT SwitchStatement: public Statement +class GLSL_EXPORT SwitchStatementAST: public StatementAST { public: - SwitchStatement(Expression *_expr, Statement *_body) - : Statement(Kind_Switch), expr(_expr), body(_body) {} + SwitchStatementAST(ExpressionAST *_expr, StatementAST *_body) + : StatementAST(Kind_Switch), expr(_expr), body(_body) {} - virtual SwitchStatement *asSwitchStatement() { return this; } + virtual SwitchStatementAST *asSwitchStatement() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Expression *expr; - Statement *body; + ExpressionAST *expr; + StatementAST *body; }; -class GLSL_EXPORT CaseLabelStatement: public Statement +class GLSL_EXPORT CaseLabelStatementAST: public StatementAST { public: - CaseLabelStatement() : Statement(Kind_DefaultLabel), expr(0) {} - CaseLabelStatement(Expression *_expr) - : Statement(Kind_CaseLabel), expr(_expr) {} + CaseLabelStatementAST() : StatementAST(Kind_DefaultLabel), expr(0) {} + CaseLabelStatementAST(ExpressionAST *_expr) + : StatementAST(Kind_CaseLabel), expr(_expr) {} - virtual CaseLabelStatement *asCaseLabelStatement() { return this; } + virtual CaseLabelStatementAST *asCaseLabelStatement() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Expression *expr; + ExpressionAST *expr; }; -class GLSL_EXPORT DeclarationStatement: public Statement +class GLSL_EXPORT DeclarationStatementAST: public StatementAST { public: - DeclarationStatement(List *_decls) - : Statement(Kind_DeclarationStatement), decls(finish(_decls)) {} + DeclarationStatementAST(List *_decls) + : StatementAST(Kind_DeclarationStatement), decls(finish(_decls)) {} - virtual DeclarationStatement *asDeclarationStatement() { return this; } + virtual DeclarationStatementAST *asDeclarationStatement() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - List *decls; + List *decls; }; -class GLSL_EXPORT Type: public AST +class GLSL_EXPORT TypeAST: public AST { protected: - Type(Kind _kind) : AST(_kind) {} + TypeAST(Kind _kind) : AST(_kind) {} public: enum Precision @@ -698,7 +698,7 @@ public: Struct }; - virtual Type *asType() { return this; } + virtual TypeAST *asType() { return this; } virtual Precision precision() const = 0; @@ -709,13 +709,13 @@ public: virtual Category category() const = 0; }; -class GLSL_EXPORT BasicType: public Type +class GLSL_EXPORT BasicTypeAST: public TypeAST { public: // Pass the parser's token code: T_VOID, T_VEC4, etc. - BasicType(int _token, const char *_name, Category _category); + BasicTypeAST(int _token, const char *_name, Category _category); - virtual BasicType *asBasicType() { return this; } + virtual BasicTypeAST *asBasicType() { return this; } virtual void accept0(Visitor *visitor); @@ -731,12 +731,12 @@ public: // attributes Category categ; }; -class GLSL_EXPORT NamedType: public Type +class GLSL_EXPORT NamedTypeAST: public TypeAST { public: - NamedType(const QString *_name) : Type(Kind_NamedType), name(_name) {} + NamedTypeAST(const QString *_name) : TypeAST(Kind_NamedType), name(_name) {} - virtual NamedType *asNamedType() { return this; } + virtual NamedTypeAST *asNamedType() { return this; } virtual void accept0(Visitor *visitor); @@ -749,15 +749,15 @@ public: // attributes const QString *name; }; -class GLSL_EXPORT ArrayType: public Type +class GLSL_EXPORT ArrayTypeAST: public TypeAST { public: - ArrayType(Type *_elementType) - : Type(Kind_OpenArrayType), elementType(_elementType), size(0) {} - ArrayType(Type *_elementType, Expression *_size) - : Type(Kind_ArrayType), elementType(_elementType), size(_size) {} + ArrayTypeAST(TypeAST *_elementType) + : TypeAST(Kind_OpenArrayType), elementType(_elementType), size(0) {} + ArrayTypeAST(TypeAST *_elementType, ExpressionAST *_size) + : TypeAST(Kind_ArrayType), elementType(_elementType), size(_size) {} - virtual ArrayType *asArrayType() { return this; } + virtual ArrayTypeAST *asArrayType() { return this; } virtual void accept0(Visitor *visitor); @@ -767,11 +767,11 @@ public: virtual Category category() const { return Array; } public: // attributes - Type *elementType; - Expression *size; + TypeAST *elementType; + ExpressionAST *size; }; -class GLSL_EXPORT StructType: public Type +class GLSL_EXPORT StructTypeAST: public TypeAST { public: class Field: public AST @@ -783,23 +783,23 @@ public: // Takes the outer shell of an array type with the innermost // element type set to null. The fixInnerTypes() method will // set the innermost element type to a meaningful value. - Field(const QString *_name, Type *_type) + Field(const QString *_name, TypeAST *_type) : AST(Kind_StructField), name(_name), type(_type) {} virtual void accept0(Visitor *visitor); - void setInnerType(Type *innerType); + void setInnerType(TypeAST *innerType); const QString *name; - Type *type; + TypeAST *type; }; - StructType(List *_fields) - : Type(Kind_AnonymousStructType), fields(finish(_fields)) {} - StructType(const QString *_name, List *_fields) - : Type(Kind_StructType), name(_name), fields(finish(_fields)) {} + StructTypeAST(List *_fields) + : TypeAST(Kind_AnonymousStructType), fields(finish(_fields)) {} + StructTypeAST(const QString *_name, List *_fields) + : TypeAST(Kind_StructType), name(_name), fields(finish(_fields)) {} - virtual StructType *asStructType() { return this; } + virtual StructTypeAST *asStructType() { return this; } virtual void accept0(Visitor *visitor); @@ -808,7 +808,7 @@ public: // Fix the inner types of a field list. The "innerType" will // be copied into the "array holes" of all fields. - static List *fixInnerTypes(Type *innerType, List *fields); + static List *fixInnerTypes(TypeAST *innerType, List *fields); virtual Category category() const { return Struct; } @@ -829,11 +829,11 @@ public: // attributes int lineno; }; -class GLSL_EXPORT QualifiedType: public Type +class GLSL_EXPORT QualifiedTypeAST: public TypeAST { public: - QualifiedType(int _qualifiers, Type *_type, List *_layout_list) - : Type(Kind_QualifiedType), qualifiers(_qualifiers), type(_type) + QualifiedTypeAST(int _qualifiers, TypeAST *_type, List *_layout_list) + : TypeAST(Kind_QualifiedType), qualifiers(_qualifiers), type(_type) , layout_list(finish(_layout_list)) {} enum @@ -861,7 +861,7 @@ public: Invariant = 0x00010000 }; - virtual QualifiedType *asQualifiedType() { return this; } + virtual QualifiedTypeAST *asQualifiedType() { return this; } virtual void accept0(Visitor *visitor); @@ -872,36 +872,36 @@ public: public: // attributes int qualifiers; - Type *type; + TypeAST *type; List *layout_list; }; -class GLSL_EXPORT Declaration: public AST +class GLSL_EXPORT DeclarationAST: public AST { protected: - Declaration(Kind _kind) : AST(_kind) {} + DeclarationAST(Kind _kind) : AST(_kind) {} public: - virtual Declaration *asDeclaration() { return this; } + virtual DeclarationAST *asDeclaration() { return this; } }; -class GLSL_EXPORT PrecisionDeclaration: public Declaration +class GLSL_EXPORT PrecisionDeclarationAST: public DeclarationAST { public: - PrecisionDeclaration(Type::Precision _precision, Type *_type) - : Declaration(Kind_PrecisionDeclaration) + PrecisionDeclarationAST(TypeAST::Precision _precision, TypeAST *_type) + : DeclarationAST(Kind_PrecisionDeclaration) , precision(_precision), type(_type) {} - virtual PrecisionDeclaration *asPrecisionDeclaration() { return this; } + virtual PrecisionDeclarationAST *asPrecisionDeclaration() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Type::Precision precision; - Type *type; + TypeAST::Precision precision; + TypeAST *type; }; -class GLSL_EXPORT ParameterDeclaration: public Declaration +class GLSL_EXPORT ParameterDeclarationAST: public DeclarationAST { public: enum Qualifier @@ -910,79 +910,79 @@ public: Out, InOut }; - ParameterDeclaration(Type *_type, Qualifier _qualifier, + ParameterDeclarationAST(TypeAST *_type, Qualifier _qualifier, const QString *_name) - : Declaration(Kind_ParameterDeclaration), type(_type) + : DeclarationAST(Kind_ParameterDeclaration), type(_type) , qualifier(_qualifier), name(_name) {} - virtual ParameterDeclaration *asParameterDeclaration() { return this; } + virtual ParameterDeclarationAST *asParameterDeclaration() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Type *type; + TypeAST *type; Qualifier qualifier; const QString *name; }; -class GLSL_EXPORT VariableDeclaration: public Declaration +class GLSL_EXPORT VariableDeclarationAST: public DeclarationAST { public: - VariableDeclaration(Type *_type, const QString *_name, - Expression *_initializer = 0) - : Declaration(Kind_VariableDeclaration), type(_type) + VariableDeclarationAST(TypeAST *_type, const QString *_name, + ExpressionAST *_initializer = 0) + : DeclarationAST(Kind_VariableDeclaration), type(_type) , name(_name), initializer(_initializer) {} - virtual VariableDeclaration *asVariableDeclaration() { return this; } + virtual VariableDeclarationAST *asVariableDeclaration() { return this; } virtual void accept0(Visitor *visitor); - static Type *declarationType(List *decls); + static TypeAST *declarationType(List *decls); public: // attributes - Type *type; + TypeAST *type; const QString *name; - Expression *initializer; + ExpressionAST *initializer; }; -class GLSL_EXPORT TypeDeclaration: public Declaration +class GLSL_EXPORT TypeDeclarationAST: public DeclarationAST { public: - TypeDeclaration(Type *_type) - : Declaration(Kind_TypeDeclaration), type(_type) {} + TypeDeclarationAST(TypeAST *_type) + : DeclarationAST(Kind_TypeDeclaration), type(_type) {} - virtual TypeDeclaration *asTypeDeclaration() { return this; } + virtual TypeDeclarationAST *asTypeDeclaration() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - Type *type; + TypeAST *type; }; -class GLSL_EXPORT TypeAndVariableDeclaration: public Declaration +class GLSL_EXPORT TypeAndVariableDeclarationAST: public DeclarationAST { public: - TypeAndVariableDeclaration(TypeDeclaration *_typeDecl, - VariableDeclaration *_varDecl) - : Declaration(Kind_TypeAndVariableDeclaration) + TypeAndVariableDeclarationAST(TypeDeclarationAST *_typeDecl, + VariableDeclarationAST *_varDecl) + : DeclarationAST(Kind_TypeAndVariableDeclaration) , typeDecl(_typeDecl), varDecl(_varDecl) {} - virtual TypeAndVariableDeclaration *asTypeAndVariableDeclaration() { return this; } + virtual TypeAndVariableDeclarationAST *asTypeAndVariableDeclaration() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - TypeDeclaration *typeDecl; - VariableDeclaration *varDecl; + TypeDeclarationAST *typeDecl; + VariableDeclarationAST *varDecl; }; -class GLSL_EXPORT InvariantDeclaration: public Declaration +class GLSL_EXPORT InvariantDeclarationAST: public DeclarationAST { public: - InvariantDeclaration(const QString *_name) - : Declaration(Kind_InvariantDeclaration), name(_name) {} + InvariantDeclarationAST(const QString *_name) + : DeclarationAST(Kind_InvariantDeclaration), name(_name) {} - virtual InvariantDeclaration *asInvariantDeclaration() { return this; } + virtual InvariantDeclarationAST *asInvariantDeclaration() { return this; } virtual void accept0(Visitor *visitor); @@ -990,28 +990,28 @@ public: // attributes const QString *name; }; -class GLSL_EXPORT InitDeclaration: public Declaration +class GLSL_EXPORT InitDeclarationAST: public DeclarationAST { public: - InitDeclaration(List *_decls) - : Declaration(Kind_InitDeclaration), decls(finish(_decls)) {} + InitDeclarationAST(List *_decls) + : DeclarationAST(Kind_InitDeclaration), decls(finish(_decls)) {} - virtual InitDeclaration *asInitDeclaration() { return this; } + virtual InitDeclarationAST *asInitDeclaration() { return this; } virtual void accept0(Visitor *visitor); public: // attributes - List *decls; + List *decls; }; -class GLSL_EXPORT FunctionDeclaration : public Declaration +class GLSL_EXPORT FunctionDeclarationAST : public DeclarationAST { public: - FunctionDeclaration(Type *_returnType, const QString *_name) - : Declaration(Kind_FunctionDeclaration), returnType(_returnType) + FunctionDeclarationAST(TypeAST *_returnType, const QString *_name) + : DeclarationAST(Kind_FunctionDeclaration), returnType(_returnType) , name(_name), params(0), body(0) {} - virtual FunctionDeclaration *asFunctionDeclaration() { return this; } + virtual FunctionDeclarationAST *asFunctionDeclaration() { return this; } virtual void accept0(Visitor *visitor); @@ -1020,10 +1020,10 @@ public: bool isPrototype() const { return body == 0; } public: // attributes - Type *returnType; + TypeAST *returnType; const QString *name; - List *params; - Statement *body; + List *params; + StatementAST *body; }; } // namespace GLSL diff --git a/src/libs/glsl/glslastvisitor.h b/src/libs/glsl/glslastvisitor.h index 2f4b74875e..9c96376433 100644 --- a/src/libs/glsl/glslastvisitor.h +++ b/src/libs/glsl/glslastvisitor.h @@ -44,113 +44,113 @@ public: virtual bool preVisit(AST *) { return true; } virtual void postVisit(AST *) {} - virtual bool visit(TranslationUnit *) { return true; } - virtual void endVisit(TranslationUnit *) {} + virtual bool visit(TranslationUnitAST *) { return true; } + virtual void endVisit(TranslationUnitAST *) {} - virtual bool visit(IdentifierExpression *) { return true; } - virtual void endVisit(IdentifierExpression *) {} + virtual bool visit(IdentifierExpressionAST *) { return true; } + virtual void endVisit(IdentifierExpressionAST *) {} - virtual bool visit(LiteralExpression *) { return true; } - virtual void endVisit(LiteralExpression *) {} + virtual bool visit(LiteralExpressionAST *) { return true; } + virtual void endVisit(LiteralExpressionAST *) {} - virtual bool visit(BinaryExpression *) { return true; } - virtual void endVisit(BinaryExpression *) {} + virtual bool visit(BinaryExpressionAST *) { return true; } + virtual void endVisit(BinaryExpressionAST *) {} - virtual bool visit(UnaryExpression *) { return true; } - virtual void endVisit(UnaryExpression *) {} + virtual bool visit(UnaryExpressionAST *) { return true; } + virtual void endVisit(UnaryExpressionAST *) {} - virtual bool visit(TernaryExpression *) { return true; } - virtual void endVisit(TernaryExpression *) {} + virtual bool visit(TernaryExpressionAST *) { return true; } + virtual void endVisit(TernaryExpressionAST *) {} - virtual bool visit(AssignmentExpression *) { return true; } - virtual void endVisit(AssignmentExpression *) {} + virtual bool visit(AssignmentExpressionAST *) { return true; } + virtual void endVisit(AssignmentExpressionAST *) {} - virtual bool visit(MemberAccessExpression *) { return true; } - virtual void endVisit(MemberAccessExpression *) {} + virtual bool visit(MemberAccessExpressionAST *) { return true; } + virtual void endVisit(MemberAccessExpressionAST *) {} - virtual bool visit(FunctionCallExpression *) { return true; } - virtual void endVisit(FunctionCallExpression *) {} + virtual bool visit(FunctionCallExpressionAST *) { return true; } + virtual void endVisit(FunctionCallExpressionAST *) {} - virtual bool visit(FunctionIdentifier *) { return true; } - virtual void endVisit(FunctionIdentifier *) {} + virtual bool visit(FunctionIdentifierAST *) { return true; } + virtual void endVisit(FunctionIdentifierAST *) {} - virtual bool visit(DeclarationExpression *) { return true; } - virtual void endVisit(DeclarationExpression *) {} + virtual bool visit(DeclarationExpressionAST *) { return true; } + virtual void endVisit(DeclarationExpressionAST *) {} - virtual bool visit(ExpressionStatement *) { return true; } - virtual void endVisit(ExpressionStatement *) {} + virtual bool visit(ExpressionStatementAST *) { return true; } + virtual void endVisit(ExpressionStatementAST *) {} - virtual bool visit(CompoundStatement *) { return true; } - virtual void endVisit(CompoundStatement *) {} + virtual bool visit(CompoundStatementAST *) { return true; } + virtual void endVisit(CompoundStatementAST *) {} - virtual bool visit(IfStatement *) { return true; } - virtual void endVisit(IfStatement *) {} + virtual bool visit(IfStatementAST *) { return true; } + virtual void endVisit(IfStatementAST *) {} - virtual bool visit(WhileStatement *) { return true; } - virtual void endVisit(WhileStatement *) {} + virtual bool visit(WhileStatementAST *) { return true; } + virtual void endVisit(WhileStatementAST *) {} - virtual bool visit(DoStatement *) { return true; } - virtual void endVisit(DoStatement *) {} + virtual bool visit(DoStatementAST *) { return true; } + virtual void endVisit(DoStatementAST *) {} - virtual bool visit(ForStatement *) { return true; } - virtual void endVisit(ForStatement *) {} + virtual bool visit(ForStatementAST *) { return true; } + virtual void endVisit(ForStatementAST *) {} - virtual bool visit(JumpStatement *) { return true; } - virtual void endVisit(JumpStatement *) {} + virtual bool visit(JumpStatementAST *) { return true; } + virtual void endVisit(JumpStatementAST *) {} - virtual bool visit(ReturnStatement *) { return true; } - virtual void endVisit(ReturnStatement *) {} + virtual bool visit(ReturnStatementAST *) { return true; } + virtual void endVisit(ReturnStatementAST *) {} - virtual bool visit(SwitchStatement *) { return true; } - virtual void endVisit(SwitchStatement *) {} + virtual bool visit(SwitchStatementAST *) { return true; } + virtual void endVisit(SwitchStatementAST *) {} - virtual bool visit(CaseLabelStatement *) { return true; } - virtual void endVisit(CaseLabelStatement *) {} + virtual bool visit(CaseLabelStatementAST *) { return true; } + virtual void endVisit(CaseLabelStatementAST *) {} - virtual bool visit(DeclarationStatement *) { return true; } - virtual void endVisit(DeclarationStatement *) {} + virtual bool visit(DeclarationStatementAST *) { return true; } + virtual void endVisit(DeclarationStatementAST *) {} - virtual bool visit(BasicType *) { return true; } - virtual void endVisit(BasicType *) {} + virtual bool visit(BasicTypeAST *) { return true; } + virtual void endVisit(BasicTypeAST *) {} - virtual bool visit(NamedType *) { return true; } - virtual void endVisit(NamedType *) {} + virtual bool visit(NamedTypeAST *) { return true; } + virtual void endVisit(NamedTypeAST *) {} - virtual bool visit(ArrayType *) { return true; } - virtual void endVisit(ArrayType *) {} + virtual bool visit(ArrayTypeAST *) { return true; } + virtual void endVisit(ArrayTypeAST *) {} - virtual bool visit(StructType *) { return true; } - virtual void endVisit(StructType *) {} + virtual bool visit(StructTypeAST *) { return true; } + virtual void endVisit(StructTypeAST *) {} - virtual bool visit(StructType::Field *) { return true; } - virtual void endVisit(StructType::Field *) {} + virtual bool visit(StructTypeAST::Field *) { return true; } + virtual void endVisit(StructTypeAST::Field *) {} - virtual bool visit(QualifiedType *) { return true; } - virtual void endVisit(QualifiedType *) {} + virtual bool visit(QualifiedTypeAST *) { return true; } + virtual void endVisit(QualifiedTypeAST *) {} - virtual bool visit(PrecisionDeclaration *) { return true; } - virtual void endVisit(PrecisionDeclaration *) {} + virtual bool visit(PrecisionDeclarationAST *) { return true; } + virtual void endVisit(PrecisionDeclarationAST *) {} - virtual bool visit(ParameterDeclaration *) { return true; } - virtual void endVisit(ParameterDeclaration *) {} + virtual bool visit(ParameterDeclarationAST *) { return true; } + virtual void endVisit(ParameterDeclarationAST *) {} - virtual bool visit(VariableDeclaration *) { return true; } - virtual void endVisit(VariableDeclaration *) {} + virtual bool visit(VariableDeclarationAST *) { return true; } + virtual void endVisit(VariableDeclarationAST *) {} - virtual bool visit(TypeDeclaration *) { return true; } - virtual void endVisit(TypeDeclaration *) {} + virtual bool visit(TypeDeclarationAST *) { return true; } + virtual void endVisit(TypeDeclarationAST *) {} - virtual bool visit(TypeAndVariableDeclaration *) { return true; } - virtual void endVisit(TypeAndVariableDeclaration *) {} + virtual bool visit(TypeAndVariableDeclarationAST *) { return true; } + virtual void endVisit(TypeAndVariableDeclarationAST *) {} - virtual bool visit(InvariantDeclaration *) { return true; } - virtual void endVisit(InvariantDeclaration *) {} + virtual bool visit(InvariantDeclarationAST *) { return true; } + virtual void endVisit(InvariantDeclarationAST *) {} - virtual bool visit(InitDeclaration *) { return true; } - virtual void endVisit(InitDeclaration *) {} + virtual bool visit(InitDeclarationAST *) { return true; } + virtual void endVisit(InitDeclarationAST *) {} - virtual bool visit(FunctionDeclaration *) { return true; } - virtual void endVisit(FunctionDeclaration *) {} + virtual bool visit(FunctionDeclarationAST *) { return true; } + virtual void endVisit(FunctionDeclarationAST *) {} }; } // namespace GLSL diff --git a/src/libs/glsl/glslengine.cpp b/src/libs/glsl/glslengine.cpp index 8588718572..0c19ec9e78 100644 --- a/src/libs/glsl/glslengine.cpp +++ b/src/libs/glsl/glslengine.cpp @@ -99,6 +99,59 @@ MemoryPool *Engine::pool() return &_pool; } +const UndefinedType *Engine::undefinedType() +{ + static UndefinedType t; + return &t; +} + +const VoidType *Engine::voidType() +{ + static VoidType t; + return &t; +} + +const BoolType *Engine::boolType() +{ + static BoolType t; + return &t; +} + +const IntType *Engine::intType() +{ + static IntType t; + return &t; +} + +const UIntType *Engine::uintType() +{ + static UIntType t; + return &t; +} + +const FloatType *Engine::floatType() +{ + static FloatType t; + return &t; +} + +const DoubleType *Engine::doubleType() +{ + static DoubleType t; + return &t; +} + + +const VectorType *Engine::vectorType(const Type *elementType, int dimension) +{ + return _vectorTypes.intern(VectorType(elementType, dimension)); +} + +const MatrixType *Engine::matrixType(const Type *elementType, int columns, int rows) +{ + return _matrixTypes.intern(MatrixType(elementType, columns, rows)); +} + QList Engine::diagnosticMessages() const { return _diagnosticMessages; diff --git a/src/libs/glsl/glslengine.h b/src/libs/glsl/glslengine.h index 8a83423f54..9ad8f464a2 100644 --- a/src/libs/glsl/glslengine.h +++ b/src/libs/glsl/glslengine.h @@ -32,8 +32,11 @@ #include "glsl.h" #include "glslmemorypool.h" +#include "glsltypes.h" #include #include +#include +#include namespace GLSL { @@ -69,6 +72,21 @@ private: int _line; }; +template +class TypeTable +{ +public: + struct Compare: std::binary_function<_Type, _Type, bool> { + bool operator()(const _Type &value, const _Type &other) const { + return value.isLessThan(&other); + } + }; + + const _Type *intern(const _Type &ty) { return &*_entries.insert(ty).first; } + +private: + std::set<_Type, Compare> _entries; +}; class GLSL_EXPORT Engine { @@ -80,6 +98,16 @@ public: const QString *identifier(const char *s, int n); QSet identifiers() const; + const UndefinedType *undefinedType(); + const VoidType *voidType(); + const BoolType *boolType(); + const IntType *intType(); + const UIntType *uintType(); + const FloatType *floatType(); + const DoubleType *doubleType(); + const VectorType *vectorType(const Type *elementType, int dimension); + const MatrixType *matrixType(const Type *elementType, int columns, int rows); + MemoryPool *pool(); QList diagnosticMessages() const; @@ -88,6 +116,8 @@ public: private: QSet _identifiers; + TypeTable _vectorTypes; + TypeTable _matrixTypes; MemoryPool _pool; QList _diagnosticMessages; }; diff --git a/src/libs/glsl/glslparser.cpp b/src/libs/glsl/glslparser.cpp index a1a73aad58..594d400bdc 100644 --- a/src/libs/glsl/glslparser.cpp +++ b/src/libs/glsl/glslparser.cpp @@ -102,7 +102,7 @@ Parser::~Parser() { } -TranslationUnit *Parser::parse() +TranslationUnitAST *Parser::parse() { int action = 0; int yytoken = -1; @@ -177,25 +177,25 @@ switch(ruleno) { #line 580 "./glsl.g" case 0: { - ast(1) = makeAstNode(string(1)); + ast(1) = makeAstNode(string(1)); } break; #line 587 "./glsl.g" case 1: { - ast(1) = makeAstNode(string(1)); + ast(1) = makeAstNode(string(1)); } break; #line 594 "./glsl.g" case 2: { - ast(1) = makeAstNode(_engine->identifier("true", 4)); + ast(1) = makeAstNode(_engine->identifier("true", 4)); } break; #line 601 "./glsl.g" case 3: { - ast(1) = makeAstNode(_engine->identifier("false", 5)); + ast(1) = makeAstNode(_engine->identifier("false", 5)); } break; #line 608 "./glsl.g" @@ -219,7 +219,7 @@ case 6: { #line 629 "./glsl.g" case 7: { - ast(1) = makeAstNode(AST::Kind_ArrayAccess, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_ArrayAccess, expression(1), expression(3)); } break; #line 636 "./glsl.g" @@ -231,19 +231,19 @@ case 8: { #line 643 "./glsl.g" case 9: { - ast(1) = makeAstNode(expression(1), string(3)); + ast(1) = makeAstNode(expression(1), string(3)); } break; #line 650 "./glsl.g" case 10: { - ast(1) = makeAstNode(AST::Kind_PostIncrement, expression(1)); + ast(1) = makeAstNode(AST::Kind_PostIncrement, expression(1)); } break; #line 657 "./glsl.g" case 11: { - ast(1) = makeAstNode(AST::Kind_PostDecrement, expression(1)); + ast(1) = makeAstNode(AST::Kind_PostDecrement, expression(1)); } break; #line 664 "./glsl.g" @@ -261,14 +261,14 @@ case 13: { #line 678 "./glsl.g" case 14: { - ast(1) = makeAstNode + ast(1) = makeAstNode (sym(1).function.id, sym(1).function.arguments); } break; #line 686 "./glsl.g" case 15: { - ast(1) = makeAstNode + ast(1) = makeAstNode (expression(1), sym(3).function.id, sym(3).function.arguments); } break; @@ -303,14 +303,14 @@ case 19: { case 20: { sym(1).function.id = sym(1).function_identifier; sym(1).function.arguments = - makeAstNode< List >(expression(2)); + makeAstNode< List >(expression(2)); } break; #line 733 "./glsl.g" case 21: { sym(1).function.arguments = - makeAstNode< List > + makeAstNode< List > (sym(1).function.arguments, expression(3)); } break; @@ -323,13 +323,13 @@ case 22: { #line 749 "./glsl.g" case 23: { - ast(1) = makeAstNode(type(1)); + ast(1) = makeAstNode(type(1)); } break; #line 756 "./glsl.g" case 24: { - ast(1) = makeAstNode(string(1)); + ast(1) = makeAstNode(string(1)); } break; #line 763 "./glsl.g" @@ -341,19 +341,19 @@ case 25: { #line 770 "./glsl.g" case 26: { - ast(1) = makeAstNode(AST::Kind_PreIncrement, expression(2)); + ast(1) = makeAstNode(AST::Kind_PreIncrement, expression(2)); } break; #line 777 "./glsl.g" case 27: { - ast(1) = makeAstNode(AST::Kind_PreDecrement, expression(2)); + ast(1) = makeAstNode(AST::Kind_PreDecrement, expression(2)); } break; #line 784 "./glsl.g" case 28: { - ast(1) = makeAstNode(sym(1).kind, expression(2)); + ast(1) = makeAstNode(sym(1).kind, expression(2)); } break; #line 791 "./glsl.g" @@ -389,19 +389,19 @@ case 33: { #line 826 "./glsl.g" case 34: { - ast(1) = makeAstNode(AST::Kind_Multiply, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Multiply, expression(1), expression(3)); } break; #line 833 "./glsl.g" case 35: { - ast(1) = makeAstNode(AST::Kind_Divide, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Divide, expression(1), expression(3)); } break; #line 840 "./glsl.g" case 36: { - ast(1) = makeAstNode(AST::Kind_Modulus, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Modulus, expression(1), expression(3)); } break; #line 847 "./glsl.g" @@ -413,13 +413,13 @@ case 37: { #line 854 "./glsl.g" case 38: { - ast(1) = makeAstNode(AST::Kind_Plus, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Plus, expression(1), expression(3)); } break; #line 861 "./glsl.g" case 39: { - ast(1) = makeAstNode(AST::Kind_Minus, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Minus, expression(1), expression(3)); } break; #line 868 "./glsl.g" @@ -431,13 +431,13 @@ case 40: { #line 875 "./glsl.g" case 41: { - ast(1) = makeAstNode(AST::Kind_ShiftLeft, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_ShiftLeft, expression(1), expression(3)); } break; #line 882 "./glsl.g" case 42: { - ast(1) = makeAstNode(AST::Kind_ShiftRight, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_ShiftRight, expression(1), expression(3)); } break; #line 889 "./glsl.g" @@ -449,25 +449,25 @@ case 43: { #line 896 "./glsl.g" case 44: { - ast(1) = makeAstNode(AST::Kind_LessThan, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_LessThan, expression(1), expression(3)); } break; #line 903 "./glsl.g" case 45: { - ast(1) = makeAstNode(AST::Kind_GreaterThan, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_GreaterThan, expression(1), expression(3)); } break; #line 910 "./glsl.g" case 46: { - ast(1) = makeAstNode(AST::Kind_LessEqual, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_LessEqual, expression(1), expression(3)); } break; #line 917 "./glsl.g" case 47: { - ast(1) = makeAstNode(AST::Kind_GreaterEqual, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_GreaterEqual, expression(1), expression(3)); } break; #line 924 "./glsl.g" @@ -479,13 +479,13 @@ case 48: { #line 931 "./glsl.g" case 49: { - ast(1) = makeAstNode(AST::Kind_Equal, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Equal, expression(1), expression(3)); } break; #line 938 "./glsl.g" case 50: { - ast(1) = makeAstNode(AST::Kind_NotEqual, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_NotEqual, expression(1), expression(3)); } break; #line 945 "./glsl.g" @@ -497,7 +497,7 @@ case 51: { #line 952 "./glsl.g" case 52: { - ast(1) = makeAstNode(AST::Kind_BitwiseAnd, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_BitwiseAnd, expression(1), expression(3)); } break; #line 959 "./glsl.g" @@ -509,7 +509,7 @@ case 53: { #line 966 "./glsl.g" case 54: { - ast(1) = makeAstNode(AST::Kind_BitwiseXor, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_BitwiseXor, expression(1), expression(3)); } break; #line 973 "./glsl.g" @@ -521,7 +521,7 @@ case 55: { #line 980 "./glsl.g" case 56: { - ast(1) = makeAstNode(AST::Kind_BitwiseOr, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_BitwiseOr, expression(1), expression(3)); } break; #line 987 "./glsl.g" @@ -533,7 +533,7 @@ case 57: { #line 994 "./glsl.g" case 58: { - ast(1) = makeAstNode(AST::Kind_LogicalAnd, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_LogicalAnd, expression(1), expression(3)); } break; #line 1001 "./glsl.g" @@ -545,7 +545,7 @@ case 59: { #line 1008 "./glsl.g" case 60: { - ast(1) = makeAstNode(AST::Kind_LogicalXor, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_LogicalXor, expression(1), expression(3)); } break; #line 1015 "./glsl.g" @@ -557,7 +557,7 @@ case 61: { #line 1022 "./glsl.g" case 62: { - ast(1) = makeAstNode(AST::Kind_LogicalOr, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_LogicalOr, expression(1), expression(3)); } break; #line 1029 "./glsl.g" @@ -569,7 +569,7 @@ case 63: { #line 1036 "./glsl.g" case 64: { - ast(1) = makeAstNode(AST::Kind_Conditional, expression(1), expression(3), expression(5)); + ast(1) = makeAstNode(AST::Kind_Conditional, expression(1), expression(3), expression(5)); } break; #line 1043 "./glsl.g" @@ -581,7 +581,7 @@ case 65: { #line 1050 "./glsl.g" case 66: { - ast(1) = makeAstNode(sym(2).kind, expression(1), expression(3)); + ast(1) = makeAstNode(sym(2).kind, expression(1), expression(3)); } break; #line 1057 "./glsl.g" @@ -659,7 +659,7 @@ case 78: { #line 1141 "./glsl.g" case 79: { - ast(1) = makeAstNode(AST::Kind_Comma, expression(1), expression(3)); + ast(1) = makeAstNode(AST::Kind_Comma, expression(1), expression(3)); } break; #line 1148 "./glsl.g" @@ -677,88 +677,88 @@ case 81: { #line 1162 "./glsl.g" case 82: { - ast(1) = makeAstNode(sym(1).declaration_list); + ast(1) = makeAstNode(sym(1).declaration_list); } break; #line 1169 "./glsl.g" case 83: { - ast(1) = makeAstNode(sym(2).precision, type(3)); + ast(1) = makeAstNode(sym(2).precision, type(3)); } break; #line 1176 "./glsl.g" case 84: { - if (sym(1).type_qualifier.qualifier != QualifiedType::Struct) { + if (sym(1).type_qualifier.qualifier != QualifiedTypeAST::Struct) { // TODO: issue an error if the qualifier is not "struct". } - Type *type = makeAstNode(string(2), sym(4).field_list); - ast(1) = makeAstNode(type); + TypeAST *type = makeAstNode(string(2), sym(4).field_list); + ast(1) = makeAstNode(type); } break; #line 1187 "./glsl.g" case 85: { - if ((sym(1).type_qualifier.qualifier & QualifiedType::Struct) == 0) { + if ((sym(1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) { // TODO: issue an error if the qualifier does not contain "struct". } - Type *type = makeAstNode(string(2), sym(4).field_list); - Type *qualtype = type; - if (sym(1).type_qualifier.qualifier != QualifiedType::Struct) { - qualtype = makeAstNode - (sym(1).type_qualifier.qualifier & ~QualifiedType::Struct, qualtype, + TypeAST *type = makeAstNode(string(2), sym(4).field_list); + TypeAST *qualtype = type; + if (sym(1).type_qualifier.qualifier != QualifiedTypeAST::Struct) { + qualtype = makeAstNode + (sym(1).type_qualifier.qualifier & ~QualifiedTypeAST::Struct, qualtype, sym(1).type_qualifier.layout_list); } - ast(1) = makeAstNode - (makeAstNode(type), - makeAstNode(qualtype, string(6))); + ast(1) = makeAstNode + (makeAstNode(type), + makeAstNode(qualtype, string(6))); } break; #line 1206 "./glsl.g" case 86: { - if ((sym(1).type_qualifier.qualifier & QualifiedType::Struct) == 0) { + if ((sym(1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) { // TODO: issue an error if the qualifier does not contain "struct". } - Type *type = makeAstNode(string(2), sym(4).field_list); - Type *qualtype = type; - if (sym(1).type_qualifier.qualifier != QualifiedType::Struct) { - qualtype = makeAstNode - (sym(1).type_qualifier.qualifier & ~QualifiedType::Struct, qualtype, + TypeAST *type = makeAstNode(string(2), sym(4).field_list); + TypeAST *qualtype = type; + if (sym(1).type_qualifier.qualifier != QualifiedTypeAST::Struct) { + qualtype = makeAstNode + (sym(1).type_qualifier.qualifier & ~QualifiedTypeAST::Struct, qualtype, sym(1).type_qualifier.layout_list); } - ast(1) = makeAstNode - (makeAstNode(type), - makeAstNode - (makeAstNode(qualtype), string(6))); + ast(1) = makeAstNode + (makeAstNode(type), + makeAstNode + (makeAstNode(qualtype), string(6))); } break; #line 1226 "./glsl.g" case 87: { - if ((sym(1).type_qualifier.qualifier & QualifiedType::Struct) == 0) { + if ((sym(1).type_qualifier.qualifier & QualifiedTypeAST::Struct) == 0) { // TODO: issue an error if the qualifier does not contain "struct". } - Type *type = makeAstNode(string(2), sym(4).field_list); - Type *qualtype = type; - if (sym(1).type_qualifier.qualifier != QualifiedType::Struct) { - qualtype = makeAstNode - (sym(1).type_qualifier.qualifier & ~QualifiedType::Struct, qualtype, + TypeAST *type = makeAstNode(string(2), sym(4).field_list); + TypeAST *qualtype = type; + if (sym(1).type_qualifier.qualifier != QualifiedTypeAST::Struct) { + qualtype = makeAstNode + (sym(1).type_qualifier.qualifier & ~QualifiedTypeAST::Struct, qualtype, sym(1).type_qualifier.layout_list); } - ast(1) = makeAstNode - (makeAstNode(type), - makeAstNode - (makeAstNode(qualtype, expression(8)), string(6))); + ast(1) = makeAstNode + (makeAstNode(type), + makeAstNode + (makeAstNode(qualtype, expression(8)), string(6))); } break; #line 1246 "./glsl.g" case 88: { - Type *type = makeAstNode - (sym(1).type_qualifier.qualifier, (Type *)0, + TypeAST *type = makeAstNode + (sym(1).type_qualifier.qualifier, (TypeAST *)0, sym(1).type_qualifier.layout_list); - ast(1) = makeAstNode(type); + ast(1) = makeAstNode(type); } break; #line 1256 "./glsl.g" @@ -782,21 +782,21 @@ case 91: { #line 1277 "./glsl.g" case 92: { - function(1)->params = makeAstNode< List > + function(1)->params = makeAstNode< List > (sym(2).param_declaration); } break; #line 1285 "./glsl.g" case 93: { - function(1)->params = makeAstNode< List > + function(1)->params = makeAstNode< List > (function(1)->params, sym(3).param_declaration); } break; #line 1293 "./glsl.g" case 94: { - function(1) = makeAstNode(type(1), string(2)); + function(1) = makeAstNode(type(1), string(2)); } break; #line 1300 "./glsl.g" @@ -809,70 +809,70 @@ case 95: { #line 1308 "./glsl.g" case 96: { - sym(1).param_declarator.type = makeAstNode(type(1), expression(4)); + sym(1).param_declarator.type = makeAstNode(type(1), expression(4)); sym(1).param_declarator.name = string(2); } break; #line 1316 "./glsl.g" case 97: { - ast(1) = makeAstNode - (makeAstNode + ast(1) = makeAstNode + (makeAstNode (sym(1).qualifier, sym(3).param_declarator.type, (List *)0), - ParameterDeclaration::Qualifier(sym(2).qualifier), + ParameterDeclarationAST::Qualifier(sym(2).qualifier), sym(3).param_declarator.name); } break; #line 1328 "./glsl.g" case 98: { - ast(1) = makeAstNode + ast(1) = makeAstNode (sym(2).param_declarator.type, - ParameterDeclaration::Qualifier(sym(1).qualifier), + ParameterDeclarationAST::Qualifier(sym(1).qualifier), sym(2).param_declarator.name); } break; #line 1338 "./glsl.g" case 99: { - ast(1) = makeAstNode - (makeAstNode + ast(1) = makeAstNode + (makeAstNode (sym(1).qualifier, type(3), (List *)0), - ParameterDeclaration::Qualifier(sym(2).qualifier), + ParameterDeclarationAST::Qualifier(sym(2).qualifier), (const QString *)0); } break; #line 1349 "./glsl.g" case 100: { - ast(1) = makeAstNode - (type(2), ParameterDeclaration::Qualifier(sym(1).qualifier), + ast(1) = makeAstNode + (type(2), ParameterDeclarationAST::Qualifier(sym(1).qualifier), (const QString *)0); } break; #line 1358 "./glsl.g" case 101: { - sym(1).qualifier = ParameterDeclaration::In; + sym(1).qualifier = ParameterDeclarationAST::In; } break; #line 1365 "./glsl.g" case 102: { - sym(1).qualifier = ParameterDeclaration::In; + sym(1).qualifier = ParameterDeclarationAST::In; } break; #line 1372 "./glsl.g" case 103: { - sym(1).qualifier = ParameterDeclaration::Out; + sym(1).qualifier = ParameterDeclarationAST::Out; } break; #line 1379 "./glsl.g" case 104: { - sym(1).qualifier = ParameterDeclaration::InOut; + sym(1).qualifier = ParameterDeclarationAST::InOut; } break; #line 1386 "./glsl.g" @@ -884,135 +884,135 @@ case 105: { #line 1393 "./glsl.g" case 106: { - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration); } break; #line 1401 "./glsl.g" case 107: { - Type *type = VariableDeclaration::declarationType(sym(1).declaration_list); - Declaration *decl = makeAstNode(type, string(3)); - sym(1).declaration_list = makeAstNode< List > + TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list); + DeclarationAST *decl = makeAstNode(type, string(3)); + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, decl); } break; #line 1411 "./glsl.g" case 108: { - Type *type = VariableDeclaration::declarationType(sym(1).declaration_list); - type = makeAstNode(type); - Declaration *decl = makeAstNode(type, string(3)); - sym(1).declaration_list = makeAstNode< List > + TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list); + type = makeAstNode(type); + DeclarationAST *decl = makeAstNode(type, string(3)); + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, decl); } break; #line 1422 "./glsl.g" case 109: { - Type *type = VariableDeclaration::declarationType(sym(1).declaration_list); - type = makeAstNode(type, expression(5)); - Declaration *decl = makeAstNode(type, string(3)); - sym(1).declaration_list = makeAstNode< List > + TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list); + type = makeAstNode(type, expression(5)); + DeclarationAST *decl = makeAstNode(type, string(3)); + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, decl); } break; #line 1433 "./glsl.g" case 110: { - Type *type = VariableDeclaration::declarationType(sym(1).declaration_list); - type = makeAstNode(type); - Declaration *decl = makeAstNode + TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list); + type = makeAstNode(type); + DeclarationAST *decl = makeAstNode (type, string(3), expression(7)); - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, decl); } break; #line 1445 "./glsl.g" case 111: { - Type *type = VariableDeclaration::declarationType(sym(1).declaration_list); - type = makeAstNode(type, expression(5)); - Declaration *decl = makeAstNode + TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list); + type = makeAstNode(type, expression(5)); + DeclarationAST *decl = makeAstNode (type, string(3), expression(8)); - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, decl); } break; #line 1457 "./glsl.g" case 112: { - Type *type = VariableDeclaration::declarationType(sym(1).declaration_list); - Declaration *decl = makeAstNode + TypeAST *type = VariableDeclarationAST::declarationType(sym(1).declaration_list); + DeclarationAST *decl = makeAstNode (type, string(3), expression(5)); - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, decl); } break; #line 1468 "./glsl.g" case 113: { - ast(1) = makeAstNode(type(1)); + ast(1) = makeAstNode(type(1)); } break; #line 1475 "./glsl.g" case 114: { - ast(1) = makeAstNode(type(1), string(2)); + ast(1) = makeAstNode(type(1), string(2)); } break; #line 1482 "./glsl.g" case 115: { - ast(1) = makeAstNode - (makeAstNode(type(1)), string(2)); + ast(1) = makeAstNode + (makeAstNode(type(1)), string(2)); } break; #line 1490 "./glsl.g" case 116: { - ast(1) = makeAstNode - (makeAstNode(type(1), expression(4)), string(2)); + ast(1) = makeAstNode + (makeAstNode(type(1), expression(4)), string(2)); } break; #line 1498 "./glsl.g" case 117: { - ast(1) = makeAstNode - (makeAstNode(type(1)), string(2), expression(6)); + ast(1) = makeAstNode + (makeAstNode(type(1)), string(2), expression(6)); } break; #line 1506 "./glsl.g" case 118: { - ast(1) = makeAstNode - (makeAstNode(type(1), expression(4)), + ast(1) = makeAstNode + (makeAstNode(type(1), expression(4)), string(2), expression(7)); } break; #line 1515 "./glsl.g" case 119: { - ast(1) = makeAstNode + ast(1) = makeAstNode (type(1), string(2), expression(4)); } break; #line 1523 "./glsl.g" case 120: { - ast(1) = makeAstNode(string(2)); + ast(1) = makeAstNode(string(2)); } break; #line 1530 "./glsl.g" case 121: { - ast(1) = makeAstNode(0, type(1), (List *)0); + ast(1) = makeAstNode(0, type(1), (List *)0); } break; #line 1537 "./glsl.g" case 122: { - ast(1) = makeAstNode + ast(1) = makeAstNode (sym(1).type_qualifier.qualifier, type(2), sym(1).type_qualifier.layout_list); } break; @@ -1020,25 +1020,25 @@ case 122: { #line 1546 "./glsl.g" case 123: { - sym(1).qualifier = QualifiedType::Invariant; + sym(1).qualifier = QualifiedTypeAST::Invariant; } break; #line 1553 "./glsl.g" case 124: { - sym(1).qualifier = QualifiedType::Smooth; + sym(1).qualifier = QualifiedTypeAST::Smooth; } break; #line 1560 "./glsl.g" case 125: { - sym(1).qualifier = QualifiedType::Flat; + sym(1).qualifier = QualifiedTypeAST::Flat; } break; #line 1567 "./glsl.g" case 126: { - sym(1).qualifier = QualifiedType::NoPerspective; + sym(1).qualifier = QualifiedTypeAST::NoPerspective; } break; #line 1574 "./glsl.g" @@ -1074,7 +1074,7 @@ case 131: { #line 1609 "./glsl.g" case 132: { - sym(1).qualifier = QualifiedType::Const; + sym(1).qualifier = QualifiedTypeAST::Const; } break; #line 1616 "./glsl.g" @@ -1129,86 +1129,86 @@ case 139: { #line 1672 "./glsl.g" case 140: { - sym(1).type_qualifier.qualifier = QualifiedType::Invariant; + sym(1).type_qualifier.qualifier = QualifiedTypeAST::Invariant; sym(1).type_qualifier.layout_list = 0; } break; #line 1680 "./glsl.g" case 141: { - sym(1).qualifier = QualifiedType::Const; + sym(1).qualifier = QualifiedTypeAST::Const; } break; #line 1687 "./glsl.g" case 142: { - sym(1).qualifier = QualifiedType::Attribute; + sym(1).qualifier = QualifiedTypeAST::Attribute; } break; #line 1694 "./glsl.g" case 143: { - sym(1).qualifier = QualifiedType::Varying; + sym(1).qualifier = QualifiedTypeAST::Varying; } break; #line 1701 "./glsl.g" case 144: { - sym(1).qualifier = QualifiedType::CentroidVarying; + sym(1).qualifier = QualifiedTypeAST::CentroidVarying; } break; #line 1708 "./glsl.g" case 145: { - sym(1).qualifier = QualifiedType::In; + sym(1).qualifier = QualifiedTypeAST::In; } break; #line 1715 "./glsl.g" case 146: { - sym(1).qualifier = QualifiedType::Out; + sym(1).qualifier = QualifiedTypeAST::Out; } break; #line 1722 "./glsl.g" case 147: { - sym(1).qualifier = QualifiedType::CentroidIn; + sym(1).qualifier = QualifiedTypeAST::CentroidIn; } break; #line 1729 "./glsl.g" case 148: { - sym(1).qualifier = QualifiedType::CentroidOut; + sym(1).qualifier = QualifiedTypeAST::CentroidOut; } break; #line 1736 "./glsl.g" case 149: { - sym(1).qualifier = QualifiedType::PatchIn; + sym(1).qualifier = QualifiedTypeAST::PatchIn; } break; #line 1743 "./glsl.g" case 150: { - sym(1).qualifier = QualifiedType::PatchOut; + sym(1).qualifier = QualifiedTypeAST::PatchOut; } break; #line 1750 "./glsl.g" case 151: { - sym(1).qualifier = QualifiedType::SampleIn; + sym(1).qualifier = QualifiedTypeAST::SampleIn; } break; #line 1757 "./glsl.g" case 152: { - sym(1).qualifier = QualifiedType::SampleOut; + sym(1).qualifier = QualifiedTypeAST::SampleOut; } break; #line 1764 "./glsl.g" case 153: { - sym(1).qualifier = QualifiedType::Uniform; + sym(1).qualifier = QualifiedTypeAST::Uniform; } break; #line 1771 "./glsl.g" @@ -1235,523 +1235,523 @@ case 156: { #line 1795 "./glsl.g" case 157: { - ast(1) = makeAstNode(type(1)); + ast(1) = makeAstNode(type(1)); } break; #line 1802 "./glsl.g" case 158: { - ast(1) = makeAstNode(type(1), expression(3)); + ast(1) = makeAstNode(type(1), expression(3)); } break; #line 1809 "./glsl.g" case 159: { - ast(1) = makeBasicType(T_VOID, Type::Void); + ast(1) = makeBasicType(T_VOID, TypeAST::Void); } break; #line 1816 "./glsl.g" case 160: { - ast(1) = makeBasicType(T_FLOAT, Type::Primitive); + ast(1) = makeBasicType(T_FLOAT, TypeAST::Primitive); } break; #line 1823 "./glsl.g" case 161: { - ast(1) = makeBasicType(T_DOUBLE, Type::Primitive); + ast(1) = makeBasicType(T_DOUBLE, TypeAST::Primitive); } break; #line 1830 "./glsl.g" case 162: { - ast(1) = makeBasicType(T_INT, Type::Primitive); + ast(1) = makeBasicType(T_INT, TypeAST::Primitive); } break; #line 1837 "./glsl.g" case 163: { - ast(1) = makeBasicType(T_UINT, Type::Primitive); + ast(1) = makeBasicType(T_UINT, TypeAST::Primitive); } break; #line 1844 "./glsl.g" case 164: { - ast(1) = makeBasicType(T_BOOL, Type::Primitive); + ast(1) = makeBasicType(T_BOOL, TypeAST::Primitive); } break; #line 1851 "./glsl.g" case 165: { - ast(1) = makeBasicType(T_VEC2, Type::Vector2); + ast(1) = makeBasicType(T_VEC2, TypeAST::Vector2); } break; #line 1858 "./glsl.g" case 166: { - ast(1) = makeBasicType(T_VEC3, Type::Vector3); + ast(1) = makeBasicType(T_VEC3, TypeAST::Vector3); } break; #line 1865 "./glsl.g" case 167: { - ast(1) = makeBasicType(T_VEC4, Type::Vector4); + ast(1) = makeBasicType(T_VEC4, TypeAST::Vector4); } break; #line 1872 "./glsl.g" case 168: { - ast(1) = makeBasicType(T_DVEC2, Type::Vector2); + ast(1) = makeBasicType(T_DVEC2, TypeAST::Vector2); } break; #line 1879 "./glsl.g" case 169: { - ast(1) = makeBasicType(T_DVEC3, Type::Vector3); + ast(1) = makeBasicType(T_DVEC3, TypeAST::Vector3); } break; #line 1886 "./glsl.g" case 170: { - ast(1) = makeBasicType(T_DVEC4, Type::Vector4); + ast(1) = makeBasicType(T_DVEC4, TypeAST::Vector4); } break; #line 1893 "./glsl.g" case 171: { - ast(1) = makeBasicType(T_BVEC2, Type::Vector2); + ast(1) = makeBasicType(T_BVEC2, TypeAST::Vector2); } break; #line 1900 "./glsl.g" case 172: { - ast(1) = makeBasicType(T_BVEC3, Type::Vector3); + ast(1) = makeBasicType(T_BVEC3, TypeAST::Vector3); } break; #line 1907 "./glsl.g" case 173: { - ast(1) = makeBasicType(T_BVEC4, Type::Vector4); + ast(1) = makeBasicType(T_BVEC4, TypeAST::Vector4); } break; #line 1914 "./glsl.g" case 174: { - ast(1) = makeBasicType(T_IVEC2, Type::Vector2); + ast(1) = makeBasicType(T_IVEC2, TypeAST::Vector2); } break; #line 1921 "./glsl.g" case 175: { - ast(1) = makeBasicType(T_IVEC3, Type::Vector3); + ast(1) = makeBasicType(T_IVEC3, TypeAST::Vector3); } break; #line 1928 "./glsl.g" case 176: { - ast(1) = makeBasicType(T_IVEC4, Type::Vector4); + ast(1) = makeBasicType(T_IVEC4, TypeAST::Vector4); } break; #line 1935 "./glsl.g" case 177: { - ast(1) = makeBasicType(T_UVEC2, Type::Vector2); + ast(1) = makeBasicType(T_UVEC2, TypeAST::Vector2); } break; #line 1942 "./glsl.g" case 178: { - ast(1) = makeBasicType(T_UVEC3, Type::Vector3); + ast(1) = makeBasicType(T_UVEC3, TypeAST::Vector3); } break; #line 1949 "./glsl.g" case 179: { - ast(1) = makeBasicType(T_UVEC4, Type::Vector4); + ast(1) = makeBasicType(T_UVEC4, TypeAST::Vector4); } break; #line 1956 "./glsl.g" case 180: { - ast(1) = makeBasicType(T_MAT2, Type::Matrix); + ast(1) = makeBasicType(T_MAT2, TypeAST::Matrix); } break; #line 1963 "./glsl.g" case 181: { - ast(1) = makeBasicType(T_MAT3, Type::Matrix); + ast(1) = makeBasicType(T_MAT3, TypeAST::Matrix); } break; #line 1970 "./glsl.g" case 182: { - ast(1) = makeBasicType(T_MAT4, Type::Matrix); + ast(1) = makeBasicType(T_MAT4, TypeAST::Matrix); } break; #line 1977 "./glsl.g" case 183: { - ast(1) = makeBasicType(T_MAT2, Type::Matrix); + ast(1) = makeBasicType(T_MAT2, TypeAST::Matrix); } break; #line 1984 "./glsl.g" case 184: { - ast(1) = makeBasicType(T_MAT2X3, Type::Matrix); + ast(1) = makeBasicType(T_MAT2X3, TypeAST::Matrix); } break; #line 1991 "./glsl.g" case 185: { - ast(1) = makeBasicType(T_MAT2X4, Type::Matrix); + ast(1) = makeBasicType(T_MAT2X4, TypeAST::Matrix); } break; #line 1998 "./glsl.g" case 186: { - ast(1) = makeBasicType(T_MAT3X2, Type::Matrix); + ast(1) = makeBasicType(T_MAT3X2, TypeAST::Matrix); } break; #line 2005 "./glsl.g" case 187: { - ast(1) = makeBasicType(T_MAT3, Type::Matrix); + ast(1) = makeBasicType(T_MAT3, TypeAST::Matrix); } break; #line 2012 "./glsl.g" case 188: { - ast(1) = makeBasicType(T_MAT3X4, Type::Matrix); + ast(1) = makeBasicType(T_MAT3X4, TypeAST::Matrix); } break; #line 2019 "./glsl.g" case 189: { - ast(1) = makeBasicType(T_MAT4X2, Type::Matrix); + ast(1) = makeBasicType(T_MAT4X2, TypeAST::Matrix); } break; #line 2026 "./glsl.g" case 190: { - ast(1) = makeBasicType(T_MAT4X3, Type::Matrix); + ast(1) = makeBasicType(T_MAT4X3, TypeAST::Matrix); } break; #line 2033 "./glsl.g" case 191: { - ast(1) = makeBasicType(T_MAT4, Type::Matrix); + ast(1) = makeBasicType(T_MAT4, TypeAST::Matrix); } break; #line 2040 "./glsl.g" case 192: { - ast(1) = makeBasicType(T_DMAT2, Type::Matrix); + ast(1) = makeBasicType(T_DMAT2, TypeAST::Matrix); } break; #line 2047 "./glsl.g" case 193: { - ast(1) = makeBasicType(T_DMAT3, Type::Matrix); + ast(1) = makeBasicType(T_DMAT3, TypeAST::Matrix); } break; #line 2054 "./glsl.g" case 194: { - ast(1) = makeBasicType(T_DMAT4, Type::Matrix); + ast(1) = makeBasicType(T_DMAT4, TypeAST::Matrix); } break; #line 2061 "./glsl.g" case 195: { - ast(1) = makeBasicType(T_DMAT2, Type::Matrix); + ast(1) = makeBasicType(T_DMAT2, TypeAST::Matrix); } break; #line 2068 "./glsl.g" case 196: { - ast(1) = makeBasicType(T_DMAT2X3, Type::Matrix); + ast(1) = makeBasicType(T_DMAT2X3, TypeAST::Matrix); } break; #line 2075 "./glsl.g" case 197: { - ast(1) = makeBasicType(T_DMAT2X4, Type::Matrix); + ast(1) = makeBasicType(T_DMAT2X4, TypeAST::Matrix); } break; #line 2082 "./glsl.g" case 198: { - ast(1) = makeBasicType(T_DMAT3X2, Type::Matrix); + ast(1) = makeBasicType(T_DMAT3X2, TypeAST::Matrix); } break; #line 2089 "./glsl.g" case 199: { - ast(1) = makeBasicType(T_DMAT3, Type::Matrix); + ast(1) = makeBasicType(T_DMAT3, TypeAST::Matrix); } break; #line 2096 "./glsl.g" case 200: { - ast(1) = makeBasicType(T_DMAT3X4, Type::Matrix); + ast(1) = makeBasicType(T_DMAT3X4, TypeAST::Matrix); } break; #line 2103 "./glsl.g" case 201: { - ast(1) = makeBasicType(T_DMAT4X2, Type::Matrix); + ast(1) = makeBasicType(T_DMAT4X2, TypeAST::Matrix); } break; #line 2110 "./glsl.g" case 202: { - ast(1) = makeBasicType(T_DMAT4X3, Type::Matrix); + ast(1) = makeBasicType(T_DMAT4X3, TypeAST::Matrix); } break; #line 2117 "./glsl.g" case 203: { - ast(1) = makeBasicType(T_DMAT4, Type::Matrix); + ast(1) = makeBasicType(T_DMAT4, TypeAST::Matrix); } break; #line 2124 "./glsl.g" case 204: { - ast(1) = makeBasicType(T_SAMPLER1D, Type::Sampler1D); + ast(1) = makeBasicType(T_SAMPLER1D, TypeAST::Sampler1D); } break; #line 2131 "./glsl.g" case 205: { - ast(1) = makeBasicType(T_SAMPLER2D, Type::Sampler2D); + ast(1) = makeBasicType(T_SAMPLER2D, TypeAST::Sampler2D); } break; #line 2138 "./glsl.g" case 206: { - ast(1) = makeBasicType(T_SAMPLER3D, Type::Sampler3D); + ast(1) = makeBasicType(T_SAMPLER3D, TypeAST::Sampler3D); } break; #line 2145 "./glsl.g" case 207: { - ast(1) = makeBasicType(T_SAMPLERCUBE, Type::SamplerCube); + ast(1) = makeBasicType(T_SAMPLERCUBE, TypeAST::SamplerCube); } break; #line 2152 "./glsl.g" case 208: { - ast(1) = makeBasicType(T_SAMPLER1DSHADOW, Type::Sampler1DShadow); + ast(1) = makeBasicType(T_SAMPLER1DSHADOW, TypeAST::Sampler1DShadow); } break; #line 2159 "./glsl.g" case 209: { - ast(1) = makeBasicType(T_SAMPLER2DSHADOW, Type::Sampler2DShadow); + ast(1) = makeBasicType(T_SAMPLER2DSHADOW, TypeAST::Sampler2DShadow); } break; #line 2166 "./glsl.g" case 210: { - ast(1) = makeBasicType(T_SAMPLERCUBESHADOW, Type::SamplerCubeShadow); + ast(1) = makeBasicType(T_SAMPLERCUBESHADOW, TypeAST::SamplerCubeShadow); } break; #line 2173 "./glsl.g" case 211: { - ast(1) = makeBasicType(T_SAMPLER1DARRAY, Type::Sampler1DArray); + ast(1) = makeBasicType(T_SAMPLER1DARRAY, TypeAST::Sampler1DArray); } break; #line 2180 "./glsl.g" case 212: { - ast(1) = makeBasicType(T_SAMPLER2DARRAY, Type::Sampler2DArray); + ast(1) = makeBasicType(T_SAMPLER2DARRAY, TypeAST::Sampler2DArray); } break; #line 2187 "./glsl.g" case 213: { - ast(1) = makeBasicType(T_SAMPLER1DARRAYSHADOW, Type::Sampler1DArrayShadow); + ast(1) = makeBasicType(T_SAMPLER1DARRAYSHADOW, TypeAST::Sampler1DArrayShadow); } break; #line 2194 "./glsl.g" case 214: { - ast(1) = makeBasicType(T_SAMPLER2DARRAYSHADOW, Type::Sampler2DArrayShadow); + ast(1) = makeBasicType(T_SAMPLER2DARRAYSHADOW, TypeAST::Sampler2DArrayShadow); } break; #line 2201 "./glsl.g" case 215: { - ast(1) = makeBasicType(T_SAMPLERCUBEARRAY, Type::SamplerCubeShadow); + ast(1) = makeBasicType(T_SAMPLERCUBEARRAY, TypeAST::SamplerCubeShadow); } break; #line 2208 "./glsl.g" case 216: { - ast(1) = makeBasicType(T_SAMPLERCUBEARRAYSHADOW, Type::SamplerCubeArrayShadow); + ast(1) = makeBasicType(T_SAMPLERCUBEARRAYSHADOW, TypeAST::SamplerCubeArrayShadow); } break; #line 2215 "./glsl.g" case 217: { - ast(1) = makeBasicType(T_ISAMPLER1D, Type::Sampler1D); + ast(1) = makeBasicType(T_ISAMPLER1D, TypeAST::Sampler1D); } break; #line 2222 "./glsl.g" case 218: { - ast(1) = makeBasicType(T_ISAMPLER2D, Type::Sampler2D); + ast(1) = makeBasicType(T_ISAMPLER2D, TypeAST::Sampler2D); } break; #line 2229 "./glsl.g" case 219: { - ast(1) = makeBasicType(T_ISAMPLER3D, Type::Sampler3D); + ast(1) = makeBasicType(T_ISAMPLER3D, TypeAST::Sampler3D); } break; #line 2236 "./glsl.g" case 220: { - ast(1) = makeBasicType(T_ISAMPLERCUBE, Type::SamplerCube); + ast(1) = makeBasicType(T_ISAMPLERCUBE, TypeAST::SamplerCube); } break; #line 2243 "./glsl.g" case 221: { - ast(1) = makeBasicType(T_ISAMPLER1DARRAY, Type::Sampler1DArray); + ast(1) = makeBasicType(T_ISAMPLER1DARRAY, TypeAST::Sampler1DArray); } break; #line 2250 "./glsl.g" case 222: { - ast(1) = makeBasicType(T_ISAMPLER2DARRAY, Type::Sampler2DArray); + ast(1) = makeBasicType(T_ISAMPLER2DARRAY, TypeAST::Sampler2DArray); } break; #line 2257 "./glsl.g" case 223: { - ast(1) = makeBasicType(T_ISAMPLERCUBEARRAY, Type::SamplerCubeArray); + ast(1) = makeBasicType(T_ISAMPLERCUBEARRAY, TypeAST::SamplerCubeArray); } break; #line 2264 "./glsl.g" case 224: { - ast(1) = makeBasicType(T_USAMPLER1D, Type::Sampler1D); + ast(1) = makeBasicType(T_USAMPLER1D, TypeAST::Sampler1D); } break; #line 2271 "./glsl.g" case 225: { - ast(1) = makeBasicType(T_USAMPLER2D, Type::Sampler2D); + ast(1) = makeBasicType(T_USAMPLER2D, TypeAST::Sampler2D); } break; #line 2278 "./glsl.g" case 226: { - ast(1) = makeBasicType(T_USAMPLER3D, Type::Sampler3D); + ast(1) = makeBasicType(T_USAMPLER3D, TypeAST::Sampler3D); } break; #line 2285 "./glsl.g" case 227: { - ast(1) = makeBasicType(T_USAMPLERCUBE, Type::SamplerCube); + ast(1) = makeBasicType(T_USAMPLERCUBE, TypeAST::SamplerCube); } break; #line 2292 "./glsl.g" case 228: { - ast(1) = makeBasicType(T_USAMPLER1DARRAY, Type::Sampler1DArray); + ast(1) = makeBasicType(T_USAMPLER1DARRAY, TypeAST::Sampler1DArray); } break; #line 2299 "./glsl.g" case 229: { - ast(1) = makeBasicType(T_USAMPLER2DARRAY, Type::Sampler2DArray); + ast(1) = makeBasicType(T_USAMPLER2DARRAY, TypeAST::Sampler2DArray); } break; #line 2306 "./glsl.g" case 230: { - ast(1) = makeBasicType(T_USAMPLERCUBEARRAY, Type::SamplerCubeArray); + ast(1) = makeBasicType(T_USAMPLERCUBEARRAY, TypeAST::SamplerCubeArray); } break; #line 2313 "./glsl.g" case 231: { - ast(1) = makeBasicType(T_SAMPLER2DRECT, Type::Sampler2DRect); + ast(1) = makeBasicType(T_SAMPLER2DRECT, TypeAST::Sampler2DRect); } break; #line 2320 "./glsl.g" case 232: { - ast(1) = makeBasicType(T_SAMPLER2DRECTSHADOW, Type::Sampler2DRectShadow); + ast(1) = makeBasicType(T_SAMPLER2DRECTSHADOW, TypeAST::Sampler2DRectShadow); } break; #line 2327 "./glsl.g" case 233: { - ast(1) = makeBasicType(T_ISAMPLER2DRECT, Type::Sampler2DRect); + ast(1) = makeBasicType(T_ISAMPLER2DRECT, TypeAST::Sampler2DRect); } break; #line 2334 "./glsl.g" case 234: { - ast(1) = makeBasicType(T_USAMPLER2DRECT, Type::Sampler2DRect); + ast(1) = makeBasicType(T_USAMPLER2DRECT, TypeAST::Sampler2DRect); } break; #line 2341 "./glsl.g" case 235: { - ast(1) = makeBasicType(T_SAMPLERBUFFER, Type::SamplerBuffer); + ast(1) = makeBasicType(T_SAMPLERBUFFER, TypeAST::SamplerBuffer); } break; #line 2348 "./glsl.g" case 236: { - ast(1) = makeBasicType(T_ISAMPLERBUFFER, Type::SamplerBuffer); + ast(1) = makeBasicType(T_ISAMPLERBUFFER, TypeAST::SamplerBuffer); } break; #line 2355 "./glsl.g" case 237: { - ast(1) = makeBasicType(T_USAMPLERBUFFER, Type::SamplerBuffer); + ast(1) = makeBasicType(T_USAMPLERBUFFER, TypeAST::SamplerBuffer); } break; #line 2362 "./glsl.g" case 238: { - ast(1) = makeBasicType(T_SAMPLER2DMS, Type::Sampler2DMS); + ast(1) = makeBasicType(T_SAMPLER2DMS, TypeAST::Sampler2DMS); } break; #line 2369 "./glsl.g" case 239: { - ast(1) = makeBasicType(T_ISAMPLER2DMS, Type::Sampler2DMS); + ast(1) = makeBasicType(T_ISAMPLER2DMS, TypeAST::Sampler2DMS); } break; #line 2376 "./glsl.g" case 240: { - ast(1) = makeBasicType(T_USAMPLER2DMS, Type::Sampler2DMS); + ast(1) = makeBasicType(T_USAMPLER2DMS, TypeAST::Sampler2DMS); } break; #line 2383 "./glsl.g" case 241: { - ast(1) = makeBasicType(T_SAMPLER2DMSARRAY, Type::Sampler2DMSArray); + ast(1) = makeBasicType(T_SAMPLER2DMSARRAY, TypeAST::Sampler2DMSArray); } break; #line 2390 "./glsl.g" case 242: { - ast(1) = makeBasicType(T_ISAMPLER2DMSARRAY, Type::Sampler2DMSArray); + ast(1) = makeBasicType(T_ISAMPLER2DMSARRAY, TypeAST::Sampler2DMSArray); } break; #line 2397 "./glsl.g" case 243: { - ast(1) = makeBasicType(T_USAMPLER2DMSARRAY, Type::Sampler2DMSArray); + ast(1) = makeBasicType(T_USAMPLER2DMSARRAY, TypeAST::Sampler2DMSArray); } break; #line 2404 "./glsl.g" @@ -1763,37 +1763,37 @@ case 244: { #line 2411 "./glsl.g" case 245: { - ast(1) = makeAstNode(string(1)); + ast(1) = makeAstNode(string(1)); } break; #line 2418 "./glsl.g" case 246: { - sym(1).precision = Type::Highp; + sym(1).precision = TypeAST::Highp; } break; #line 2425 "./glsl.g" case 247: { - sym(1).precision = Type::Mediump; + sym(1).precision = TypeAST::Mediump; } break; #line 2432 "./glsl.g" case 248: { - sym(1).precision = Type::Lowp; + sym(1).precision = TypeAST::Lowp; } break; #line 2439 "./glsl.g" case 249: { - ast(1) = makeAstNode(string(2), sym(4).field_list); + ast(1) = makeAstNode(string(2), sym(4).field_list); } break; #line 2446 "./glsl.g" case 250: { - ast(1) = makeAstNode(sym(3).field_list); + ast(1) = makeAstNode(sym(3).field_list); } break; #line 2453 "./glsl.g" @@ -1811,14 +1811,14 @@ case 252: { #line 2467 "./glsl.g" case 253: { - sym(1).field_list = StructType::fixInnerTypes(type(1), sym(2).field_list); + sym(1).field_list = StructTypeAST::fixInnerTypes(type(1), sym(2).field_list); } break; #line 2474 "./glsl.g" case 254: { - sym(1).field_list = StructType::fixInnerTypes - (makeAstNode + sym(1).field_list = StructTypeAST::fixInnerTypes + (makeAstNode (sym(1).type_qualifier.qualifier, type(2), sym(1).type_qualifier.layout_list), sym(3).field_list); } break; @@ -1827,33 +1827,33 @@ case 254: { case 255: { // nothing to do. - sym(1).field_list = makeAstNode< List >(sym(1).field); + sym(1).field_list = makeAstNode< List >(sym(1).field); } break; #line 2492 "./glsl.g" case 256: { - sym(1).field_list = makeAstNode< List >(sym(1).field_list, sym(3).field); + sym(1).field_list = makeAstNode< List >(sym(1).field_list, sym(3).field); } break; #line 2499 "./glsl.g" case 257: { - sym(1).field = makeAstNode(string(1)); + sym(1).field = makeAstNode(string(1)); } break; #line 2506 "./glsl.g" case 258: { - sym(1).field = makeAstNode - (string(1), makeAstNode((Type *)0)); + sym(1).field = makeAstNode + (string(1), makeAstNode((TypeAST *)0)); } break; #line 2514 "./glsl.g" case 259: { - sym(1).field = makeAstNode - (string(1), makeAstNode((Type *)0, expression(3))); + sym(1).field = makeAstNode + (string(1), makeAstNode((TypeAST *)0, expression(3))); } break; #line 2522 "./glsl.g" @@ -1865,7 +1865,7 @@ case 260: { #line 2529 "./glsl.g" case 261: { - ast(1) = makeAstNode(sym(1).declaration_list); + ast(1) = makeAstNode(sym(1).declaration_list); } break; #line 2536 "./glsl.g" @@ -1925,13 +1925,13 @@ case 270: { #line 2599 "./glsl.g" case 271: { - ast(1) = makeAstNode(); + ast(1) = makeAstNode(); } break; #line 2606 "./glsl.g" case 272: { - ast(1) = makeAstNode(sym(2).statement_list); + ast(1) = makeAstNode(sym(2).statement_list); } break; #line 2613 "./glsl.g" @@ -1949,43 +1949,43 @@ case 274: { #line 2627 "./glsl.g" case 275: { - ast(1) = makeAstNode(); + ast(1) = makeAstNode(); } break; #line 2634 "./glsl.g" case 276: { - ast(1) = makeAstNode(sym(2).statement_list); + ast(1) = makeAstNode(sym(2).statement_list); } break; #line 2641 "./glsl.g" case 277: { - sym(1).statement_list = makeAstNode< List >(sym(1).statement); + sym(1).statement_list = makeAstNode< List >(sym(1).statement); } break; #line 2648 "./glsl.g" case 278: { - sym(1).statement_list = makeAstNode< List >(sym(1).statement_list, sym(2).statement); + sym(1).statement_list = makeAstNode< List >(sym(1).statement_list, sym(2).statement); } break; #line 2655 "./glsl.g" case 279: { - ast(1) = makeAstNode(); // Empty statement + ast(1) = makeAstNode(); // Empty statement } break; #line 2662 "./glsl.g" case 280: { - ast(1) = makeAstNode(expression(1)); + ast(1) = makeAstNode(expression(1)); } break; #line 2669 "./glsl.g" case 281: { - ast(1) = makeAstNode(expression(3), sym(5).ifstmt.thenClause, sym(5).ifstmt.elseClause); + ast(1) = makeAstNode(expression(3), sym(5).ifstmt.thenClause, sym(5).ifstmt.elseClause); } break; #line 2676 "./glsl.g" @@ -2011,56 +2011,56 @@ case 284: { #line 2699 "./glsl.g" case 285: { - ast(1) = makeAstNode + ast(1) = makeAstNode (type(1), string(2), expression(4)); } break; #line 2707 "./glsl.g" case 286: { - ast(1) = makeAstNode(expression(3), statement(6)); + ast(1) = makeAstNode(expression(3), statement(6)); } break; #line 2714 "./glsl.g" case 287: { - ast(1) = makeAstNode(); + ast(1) = makeAstNode(); } break; #line 2721 "./glsl.g" case 288: { - ast(1) = makeAstNode(sym(1).statement_list); + ast(1) = makeAstNode(sym(1).statement_list); } break; #line 2728 "./glsl.g" case 289: { - ast(1) = makeAstNode(expression(2)); + ast(1) = makeAstNode(expression(2)); } break; #line 2735 "./glsl.g" case 290: { - ast(1) = makeAstNode(); + ast(1) = makeAstNode(); } break; #line 2742 "./glsl.g" case 291: { - ast(1) = makeAstNode(expression(3), statement(5)); + ast(1) = makeAstNode(expression(3), statement(5)); } break; #line 2749 "./glsl.g" case 292: { - ast(1) = makeAstNode(statement(2), expression(5)); + ast(1) = makeAstNode(statement(2), expression(5)); } break; #line 2756 "./glsl.g" case 293: { - ast(1) = makeAstNode(statement(3), sym(4).forstmt.condition, sym(4).forstmt.increment, statement(6)); + ast(1) = makeAstNode(statement(3), sym(4).forstmt.condition, sym(4).forstmt.increment, statement(6)); } break; #line 2763 "./glsl.g" @@ -2104,44 +2104,44 @@ case 299: { #line 2807 "./glsl.g" case 300: { - ast(1) = makeAstNode(AST::Kind_Continue); + ast(1) = makeAstNode(AST::Kind_Continue); } break; #line 2814 "./glsl.g" case 301: { - ast(1) = makeAstNode(AST::Kind_Break); + ast(1) = makeAstNode(AST::Kind_Break); } break; #line 2821 "./glsl.g" case 302: { - ast(1) = makeAstNode(); + ast(1) = makeAstNode(); } break; #line 2828 "./glsl.g" case 303: { - ast(1) = makeAstNode(expression(2)); + ast(1) = makeAstNode(expression(2)); } break; #line 2835 "./glsl.g" case 304: { - ast(1) = makeAstNode(AST::Kind_Discard); + ast(1) = makeAstNode(AST::Kind_Discard); } break; #line 2842 "./glsl.g" case 305: { - ast(1) = makeAstNode(sym(1).declaration_list); + ast(1) = makeAstNode(sym(1).declaration_list); } break; #line 2849 "./glsl.g" case 306: { if (sym(1).declaration) { - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration); } else { sym(1).declaration_list = 0; @@ -2152,11 +2152,11 @@ case 306: { case 307: { if (sym(1).declaration_list && sym(2).declaration) { - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(1).declaration_list, sym(2).declaration); } else if (!sym(1).declaration_list) { if (sym(2).declaration) { - sym(1).declaration_list = makeAstNode< List > + sym(1).declaration_list = makeAstNode< List > (sym(2).declaration); } else { sym(1).declaration_list = 0; diff --git a/src/libs/glsl/glslparser.h b/src/libs/glsl/glslparser.h index 0902465fa0..bdfc14e478 100644 --- a/src/libs/glsl/glslparser.h +++ b/src/libs/glsl/glslparser.h @@ -47,30 +47,30 @@ public: const QString *string; AST *ast; List *ast_list; - Declaration *declaration; - List *declaration_list; - Expression *expression; - List *expression_list; - Statement *statement; - List *statement_list; - Type *type; - StructType::Field *field; - List *field_list; - TranslationUnit *translation_unit; - FunctionIdentifier *function_identifier; + DeclarationAST *declaration; + List *declaration_list; + ExpressionAST *expression; + List *expression_list; + StatementAST *statement; + List *statement_list; + TypeAST *type; + StructTypeAST::Field *field; + List *field_list; + TranslationUnitAST *translation_unit; + FunctionIdentifierAST *function_identifier; AST::Kind kind; - Type::Precision precision; + TypeAST::Precision precision; struct { - Statement *thenClause; - Statement *elseClause; + StatementAST *thenClause; + StatementAST *elseClause; } ifstmt; struct { - Expression *condition; - Expression *increment; + ExpressionAST *condition; + ExpressionAST *increment; } forstmt; struct { - FunctionIdentifier *id; - List *arguments; + FunctionIdentifierAST *id; + List *arguments; } function; int qualifier; LayoutQualifier *layout; @@ -80,27 +80,27 @@ public: List *layout_list; } type_qualifier; struct { - Type *type; + TypeAST *type; const QString *name; } param_declarator; - ParameterDeclaration *param_declaration; - FunctionDeclaration *function_declaration; + ParameterDeclarationAST *param_declaration; + FunctionDeclarationAST *function_declaration; }; Parser(Engine *engine, const char *source, unsigned size, int variant); ~Parser(); - TranslationUnit *parse(); + TranslationUnitAST *parse(); private: // 1-based Value &sym(int n) { return _symStack[_tos + n - 1]; } AST *&ast(int n) { return _symStack[_tos + n - 1].ast; } const QString *&string(int n) { return _symStack[_tos + n - 1].string; } - Expression *&expression(int n) { return _symStack[_tos + n - 1].expression; } - Statement *&statement(int n) { return _symStack[_tos + n - 1].statement; } - Type *&type(int n) { return _symStack[_tos + n - 1].type; } - FunctionDeclaration *&function(int n) { return _symStack[_tos + n - 1].function_declaration; } + ExpressionAST *&expression(int n) { return _symStack[_tos + n - 1].expression; } + StatementAST *&statement(int n) { return _symStack[_tos + n - 1].statement; } + TypeAST *&type(int n) { return _symStack[_tos + n - 1].type; } + FunctionDeclarationAST *&function(int n) { return _symStack[_tos + n - 1].function_declaration; } inline int consumeToken() { return _index++; } inline const Token &tokenAt(int index) const { return _tokens.at(index); } @@ -165,9 +165,9 @@ private: return node; } - Type *makeBasicType(int token, BasicType::Category category) + TypeAST *makeBasicType(int token, BasicTypeAST::Category category) { - Type *type = new (_engine->pool()) BasicType(token, spell[token], category); + TypeAST *type = new (_engine->pool()) BasicTypeAST(token, spell[token], category); type->lineno = yyloc >= 0 ? (_tokens[yyloc].line + 1) : 0; return type; } diff --git a/src/libs/glsl/glslsemantic.cpp b/src/libs/glsl/glslsemantic.cpp index 8b7e01966d..f550d642e3 100644 --- a/src/libs/glsl/glslsemantic.cpp +++ b/src/libs/glsl/glslsemantic.cpp @@ -39,58 +39,58 @@ Semantic::~Semantic() { } -void Semantic::expression(Expression *ast) +void Semantic::expression(ExpressionAST *ast) { accept(ast); } -void Semantic::statement(Statement *ast) +void Semantic::statement(StatementAST *ast) { accept(ast); } -void Semantic::type(Type *ast) +void Semantic::type(TypeAST *ast) { accept(ast); } -void Semantic::declaration(Declaration *ast) +void Semantic::declaration(DeclarationAST *ast) { accept(ast); } -void Semantic::translationUnit(TranslationUnit *ast) +void Semantic::translationUnit(TranslationUnitAST *ast) { accept(ast); } -void Semantic::functionIdentifier(FunctionIdentifier *ast) +void Semantic::functionIdentifier(FunctionIdentifierAST *ast) { accept(ast); } -void Semantic::field(StructType::Field *ast) +void Semantic::field(StructTypeAST::Field *ast) { accept(ast); } -bool Semantic::visit(TranslationUnit *ast) +bool Semantic::visit(TranslationUnitAST *ast) { - for (List *it = ast->declarations; it; it = it->next) { - Declaration *decl = it->value; + for (List *it = ast->declarations; it; it = it->next) { + DeclarationAST *decl = it->value; declaration(decl); } return false; } -bool Semantic::visit(FunctionIdentifier *ast) +bool Semantic::visit(FunctionIdentifierAST *ast) { // ast->name type(ast->type); return false; } -bool Semantic::visit(StructType::Field *ast) +bool Semantic::visit(StructTypeAST::Field *ast) { // ast->name type(ast->type); @@ -99,32 +99,32 @@ bool Semantic::visit(StructType::Field *ast) // expressions -bool Semantic::visit(IdentifierExpression *ast) +bool Semantic::visit(IdentifierExpressionAST *ast) { Q_UNUSED(ast); return false; } -bool Semantic::visit(LiteralExpression *ast) +bool Semantic::visit(LiteralExpressionAST *ast) { Q_UNUSED(ast); return false; } -bool Semantic::visit(BinaryExpression *ast) +bool Semantic::visit(BinaryExpressionAST *ast) { expression(ast->left); expression(ast->right); return false; } -bool Semantic::visit(UnaryExpression *ast) +bool Semantic::visit(UnaryExpressionAST *ast) { expression(ast->expr); return false; } -bool Semantic::visit(TernaryExpression *ast) +bool Semantic::visit(TernaryExpressionAST *ast) { expression(ast->first); expression(ast->second); @@ -132,33 +132,33 @@ bool Semantic::visit(TernaryExpression *ast) return false; } -bool Semantic::visit(AssignmentExpression *ast) +bool Semantic::visit(AssignmentExpressionAST *ast) { expression(ast->variable); expression(ast->value); return false; } -bool Semantic::visit(MemberAccessExpression *ast) +bool Semantic::visit(MemberAccessExpressionAST *ast) { expression(ast->expr); // ast->field return false; } -bool Semantic::visit(FunctionCallExpression *ast) +bool Semantic::visit(FunctionCallExpressionAST *ast) { expression(ast->expr); functionIdentifier(ast->id); - for (List *it = ast->arguments; it; it = it->next) { - Expression *arg = it->value; + for (List *it = ast->arguments; it; it = it->next) { + ExpressionAST *arg = it->value; expression(arg); } return false; } -bool Semantic::visit(DeclarationExpression *ast) +bool Semantic::visit(DeclarationExpressionAST *ast) { type(ast->type); // ast->name @@ -168,22 +168,22 @@ bool Semantic::visit(DeclarationExpression *ast) // statements -bool Semantic::visit(ExpressionStatement *ast) +bool Semantic::visit(ExpressionStatementAST *ast) { expression(ast->expr); return false; } -bool Semantic::visit(CompoundStatement *ast) +bool Semantic::visit(CompoundStatementAST *ast) { - for (List *it = ast->statements; it; it = it->next) { - Statement *stmt = it->value; + for (List *it = ast->statements; it; it = it->next) { + StatementAST *stmt = it->value; statement(stmt); } return false; } -bool Semantic::visit(IfStatement *ast) +bool Semantic::visit(IfStatementAST *ast) { expression(ast->condition); statement(ast->thenClause); @@ -191,21 +191,21 @@ bool Semantic::visit(IfStatement *ast) return false; } -bool Semantic::visit(WhileStatement *ast) +bool Semantic::visit(WhileStatementAST *ast) { expression(ast->condition); statement(ast->body); return false; } -bool Semantic::visit(DoStatement *ast) +bool Semantic::visit(DoStatementAST *ast) { statement(ast->body); expression(ast->condition); return false; } -bool Semantic::visit(ForStatement *ast) +bool Semantic::visit(ForStatementAST *ast) { statement(ast->init); expression(ast->condition); @@ -214,35 +214,35 @@ bool Semantic::visit(ForStatement *ast) return false; } -bool Semantic::visit(JumpStatement *ast) +bool Semantic::visit(JumpStatementAST *ast) { Q_UNUSED(ast); return false; } -bool Semantic::visit(ReturnStatement *ast) +bool Semantic::visit(ReturnStatementAST *ast) { expression(ast->expr); return false; } -bool Semantic::visit(SwitchStatement *ast) +bool Semantic::visit(SwitchStatementAST *ast) { expression(ast->expr); statement(ast->body); return false; } -bool Semantic::visit(CaseLabelStatement *ast) +bool Semantic::visit(CaseLabelStatementAST *ast) { expression(ast->expr); return false; } -bool Semantic::visit(DeclarationStatement *ast) +bool Semantic::visit(DeclarationStatementAST *ast) { - for (List *it = ast->decls; it; it = it->next) { - Declaration *decl = it->value; + for (List *it = ast->decls; it; it = it->next) { + DeclarationAST *decl = it->value; declaration(decl); } return false; @@ -250,36 +250,36 @@ bool Semantic::visit(DeclarationStatement *ast) // types -bool Semantic::visit(BasicType *ast) +bool Semantic::visit(BasicTypeAST *ast) { Q_UNUSED(ast); return false; } -bool Semantic::visit(NamedType *ast) +bool Semantic::visit(NamedTypeAST *ast) { Q_UNUSED(ast); return false; } -bool Semantic::visit(ArrayType *ast) +bool Semantic::visit(ArrayTypeAST *ast) { type(ast->elementType); expression(ast->size); return false; } -bool Semantic::visit(StructType *ast) +bool Semantic::visit(StructTypeAST *ast) { // ast->name - for (List *it = ast->fields; it; it = it->next) { - StructType::Field *f = it->value; + for (List *it = ast->fields; it; it = it->next) { + StructTypeAST::Field *f = it->value; field(f); } return false; } -bool Semantic::visit(QualifiedType *ast) +bool Semantic::visit(QualifiedTypeAST *ast) { accept(ast->type); for (List *it = ast->layout_list; it; it = it->next) { @@ -293,58 +293,58 @@ bool Semantic::visit(QualifiedType *ast) // declarations -bool Semantic::visit(PrecisionDeclaration *ast) +bool Semantic::visit(PrecisionDeclarationAST *ast) { type(ast->type); return false; } -bool Semantic::visit(ParameterDeclaration *ast) +bool Semantic::visit(ParameterDeclarationAST *ast) { type(ast->type); return false; } -bool Semantic::visit(VariableDeclaration *ast) +bool Semantic::visit(VariableDeclarationAST *ast) { type(ast->type); expression(ast->initializer); return false; } -bool Semantic::visit(TypeDeclaration *ast) +bool Semantic::visit(TypeDeclarationAST *ast) { type(ast->type); return false; } -bool Semantic::visit(TypeAndVariableDeclaration *ast) +bool Semantic::visit(TypeAndVariableDeclarationAST *ast) { declaration(ast->typeDecl); declaration(ast->varDecl); return false; } -bool Semantic::visit(InvariantDeclaration *ast) +bool Semantic::visit(InvariantDeclarationAST *ast) { Q_UNUSED(ast); return false; } -bool Semantic::visit(InitDeclaration *ast) +bool Semantic::visit(InitDeclarationAST *ast) { - for (List *it = ast->decls; it; it = it->next) { - Declaration *decl = it->value; + for (List *it = ast->decls; it; it = it->next) { + DeclarationAST *decl = it->value; declaration(decl); } return false; } -bool Semantic::visit(FunctionDeclaration *ast) +bool Semantic::visit(FunctionDeclarationAST *ast) { type(ast->returnType); - for (List *it = ast->params; it; it = it->next) { - ParameterDeclaration *decl = it->value; + for (List *it = ast->params; it; it = it->next) { + ParameterDeclarationAST *decl = it->value; declaration(decl); } statement(ast->body); diff --git a/src/libs/glsl/glslsemantic.h b/src/libs/glsl/glslsemantic.h index 8d7cb77e8c..5e4386e0fe 100644 --- a/src/libs/glsl/glslsemantic.h +++ b/src/libs/glsl/glslsemantic.h @@ -39,59 +39,59 @@ public: Semantic(); virtual ~Semantic(); - void expression(Expression *ast); - void statement(Statement *ast); - void type(Type *ast); - void declaration(Declaration *ast); - void translationUnit(TranslationUnit *ast); - void functionIdentifier(FunctionIdentifier *ast); - void field(StructType::Field *ast); + void expression(ExpressionAST *ast); + void statement(StatementAST *ast); + void type(TypeAST *ast); + void declaration(DeclarationAST *ast); + void translationUnit(TranslationUnitAST *ast); + void functionIdentifier(FunctionIdentifierAST *ast); + void field(StructTypeAST::Field *ast); protected: - virtual bool visit(TranslationUnit *ast); - virtual bool visit(FunctionIdentifier *ast); - virtual bool visit(StructType::Field *ast); + virtual bool visit(TranslationUnitAST *ast); + virtual bool visit(FunctionIdentifierAST *ast); + virtual bool visit(StructTypeAST::Field *ast); // expressions - virtual bool visit(IdentifierExpression *ast); - virtual bool visit(LiteralExpression *ast); - virtual bool visit(BinaryExpression *ast); - virtual bool visit(UnaryExpression *ast); - virtual bool visit(TernaryExpression *ast); - virtual bool visit(AssignmentExpression *ast); - virtual bool visit(MemberAccessExpression *ast); - virtual bool visit(FunctionCallExpression *ast); - virtual bool visit(DeclarationExpression *ast); + virtual bool visit(IdentifierExpressionAST *ast); + virtual bool visit(LiteralExpressionAST *ast); + virtual bool visit(BinaryExpressionAST *ast); + virtual bool visit(UnaryExpressionAST *ast); + virtual bool visit(TernaryExpressionAST *ast); + virtual bool visit(AssignmentExpressionAST *ast); + virtual bool visit(MemberAccessExpressionAST *ast); + virtual bool visit(FunctionCallExpressionAST *ast); + virtual bool visit(DeclarationExpressionAST *ast); // statements - virtual bool visit(ExpressionStatement *ast); - virtual bool visit(CompoundStatement *ast); - virtual bool visit(IfStatement *ast); - virtual bool visit(WhileStatement *ast); - virtual bool visit(DoStatement *ast); - virtual bool visit(ForStatement *ast); - virtual bool visit(JumpStatement *ast); - virtual bool visit(ReturnStatement *ast); - virtual bool visit(SwitchStatement *ast); - virtual bool visit(CaseLabelStatement *ast); - virtual bool visit(DeclarationStatement *ast); + virtual bool visit(ExpressionStatementAST *ast); + virtual bool visit(CompoundStatementAST *ast); + virtual bool visit(IfStatementAST *ast); + virtual bool visit(WhileStatementAST *ast); + virtual bool visit(DoStatementAST *ast); + virtual bool visit(ForStatementAST *ast); + virtual bool visit(JumpStatementAST *ast); + virtual bool visit(ReturnStatementAST *ast); + virtual bool visit(SwitchStatementAST *ast); + virtual bool visit(CaseLabelStatementAST *ast); + virtual bool visit(DeclarationStatementAST *ast); // types - virtual bool visit(BasicType *ast); - virtual bool visit(NamedType *ast); - virtual bool visit(ArrayType *ast); - virtual bool visit(StructType *ast); - virtual bool visit(QualifiedType *ast); + virtual bool visit(BasicTypeAST *ast); + virtual bool visit(NamedTypeAST *ast); + virtual bool visit(ArrayTypeAST *ast); + virtual bool visit(StructTypeAST *ast); + virtual bool visit(QualifiedTypeAST *ast); // declarations - virtual bool visit(PrecisionDeclaration *ast); - virtual bool visit(ParameterDeclaration *ast); - virtual bool visit(VariableDeclaration *ast); - virtual bool visit(TypeDeclaration *ast); - virtual bool visit(TypeAndVariableDeclaration *ast); - virtual bool visit(InvariantDeclaration *ast); - virtual bool visit(InitDeclaration *ast); - virtual bool visit(FunctionDeclaration *ast); + virtual bool visit(PrecisionDeclarationAST *ast); + virtual bool visit(ParameterDeclarationAST *ast); + virtual bool visit(VariableDeclarationAST *ast); + virtual bool visit(TypeDeclarationAST *ast); + virtual bool visit(TypeAndVariableDeclarationAST *ast); + virtual bool visit(InvariantDeclarationAST *ast); + virtual bool visit(InitDeclarationAST *ast); + virtual bool visit(FunctionDeclarationAST *ast); }; } // namespace GLSL diff --git a/src/libs/glsl/glsltypes.cpp b/src/libs/glsl/glsltypes.cpp new file mode 100644 index 0000000000..14c8c7f02f --- /dev/null +++ b/src/libs/glsl/glsltypes.cpp @@ -0,0 +1,197 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "glsltypes.h" +#include + +using namespace GLSL; + +bool UndefinedType::isEqualTo(const Type *other) const +{ + if (other && other->asUndefinedType() != 0) + return true; + return false; +} + +bool UndefinedType::isLessThan(const Type *other) const +{ + Q_UNUSED(other); + Q_ASSERT(other != 0); + Q_ASSERT(other->asUndefinedType() != 0); + return false; +} + +bool VoidType::isEqualTo(const Type *other) const +{ + if (other && other->asVoidType() != 0) + return true; + return false; +} + +bool VoidType::isLessThan(const Type *other) const +{ + Q_UNUSED(other); + Q_ASSERT(other != 0); + Q_ASSERT(other->asVoidType() != 0); + return false; +} + +bool BoolType::isEqualTo(const Type *other) const +{ + if (other && other->asBoolType() != 0) + return true; + return false; +} + +bool BoolType::isLessThan(const Type *other) const +{ + Q_UNUSED(other); + Q_ASSERT(other != 0); + Q_ASSERT(other->asBoolType() != 0); + return false; +} + +bool IntType::isEqualTo(const Type *other) const +{ + if (other && other->asIntType() != 0) + return true; + return false; +} + +bool IntType::isLessThan(const Type *other) const +{ + Q_UNUSED(other); + Q_ASSERT(other != 0); + Q_ASSERT(other->asIntType() != 0); + return false; +} + +bool UIntType::isEqualTo(const Type *other) const +{ + if (other && other->asUIntType() != 0) + return true; + return false; +} + +bool UIntType::isLessThan(const Type *other) const +{ + Q_UNUSED(other); + Q_ASSERT(other != 0); + Q_ASSERT(other->asUIntType() != 0); + return false; +} + +bool FloatType::isEqualTo(const Type *other) const +{ + if (other && other->asFloatType() != 0) + return true; + return false; +} + +bool FloatType::isLessThan(const Type *other) const +{ + Q_UNUSED(other); + Q_ASSERT(other != 0); + Q_ASSERT(other->asFloatType() != 0); + return false; +} + +bool DoubleType::isEqualTo(const Type *other) const +{ + if (other && other->asDoubleType() != 0) + return true; + return false; +} + +bool DoubleType::isLessThan(const Type *other) const +{ + Q_UNUSED(other); + Q_ASSERT(other != 0); + Q_ASSERT(other->asDoubleType() != 0); + return false; +} + +bool VectorType::isEqualTo(const Type *other) const +{ + if (other) { + if (const VectorType *v = other->asVectorType()) { + if (_dimension != v->dimension()) + return false; + else if (_elementType != v->elementType()) + return false; + return true; + } + } + return false; +} + +bool VectorType::isLessThan(const Type *other) const +{ + Q_ASSERT(other != 0); + const VectorType *vec = other->asVectorType(); + Q_ASSERT(vec != 0); + if (_dimension < vec->dimension()) + return true; + else if (_dimension == vec->dimension() && _elementType < vec->elementType()) + return true; + return false; +} + +bool MatrixType::isEqualTo(const Type *other) const +{ + if (other) { + if (const MatrixType *v = other->asMatrixType()) { + if (_columns != v->columns()) + return false; + else if (_rows != v->rows()) + return false; + else if (_elementType != v->elementType()) + return false; + return true; + } + } + return false; +} + +bool MatrixType::isLessThan(const Type *other) const +{ + Q_ASSERT(other != 0); + const MatrixType *mat = other->asMatrixType(); + Q_ASSERT(mat != 0); + if (_columns < mat->columns()) + return true; + else if (_columns == mat->columns()) { + if (_rows < mat->rows()) + return true; + else if (_rows == mat->rows() && _elementType < mat->elementType()) + return true; + } + return false; +} + diff --git a/src/libs/glsl/glsltypes.h b/src/libs/glsl/glsltypes.h new file mode 100644 index 0000000000..c7766fb438 --- /dev/null +++ b/src/libs/glsl/glsltypes.h @@ -0,0 +1,158 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ +#ifndef GLSLTYPES_H +#define GLSLTYPES_H + +#include "glsl.h" + +namespace GLSL { + +class GLSL_EXPORT Type +{ +public: + virtual ~Type() {} + + virtual const UndefinedType *asUndefinedType() const { return 0; } + virtual const VoidType *asVoidType() const { return 0; } + virtual const BoolType *asBoolType() const { return 0; } + virtual const IntType *asIntType() const { return 0; } + virtual const UIntType *asUIntType() const { return 0; } + virtual const FloatType *asFloatType() const { return 0; } + virtual const DoubleType *asDoubleType() const { return 0; } + virtual const OpaqueType *asOpaqueType() const { return 0; } + virtual const VectorType *asVectorType() const { return 0; } + virtual const MatrixType *asMatrixType() const { return 0; } + + virtual bool isEqualTo(const Type *other) const = 0; + virtual bool isLessThan(const Type *other) const = 0; +}; + +class GLSL_EXPORT OpaqueType: public Type +{ +public: + virtual const OpaqueType *asOpaqueType() const { return this; } +}; + +class GLSL_EXPORT UndefinedType: public Type +{ +public: + virtual const UndefinedType *asUndefinedType() const { return this; } + virtual bool isEqualTo(const Type *other) const; + virtual bool isLessThan(const Type *other) const; +}; + +class GLSL_EXPORT VoidType: public Type +{ +public: + virtual const VoidType *asVoidType() const { return this; } + virtual bool isEqualTo(const Type *other) const; + virtual bool isLessThan(const Type *other) const; +}; + +class GLSL_EXPORT BoolType: public Type +{ +public: + virtual const BoolType *asBoolType() const { return this; } + virtual bool isEqualTo(const Type *other) const; + virtual bool isLessThan(const Type *other) const; +}; + +class GLSL_EXPORT IntType: public Type +{ +public: + virtual const IntType *asIntType() const { return this; } + virtual bool isEqualTo(const Type *other) const; + virtual bool isLessThan(const Type *other) const; +}; + +class GLSL_EXPORT UIntType: public Type +{ +public: + virtual const UIntType *asUIntType() const { return this; } + virtual bool isEqualTo(const Type *other) const; + virtual bool isLessThan(const Type *other) const; +}; + +class GLSL_EXPORT FloatType: public Type +{ +public: + virtual const FloatType *asFloatType() const { return this; } + virtual bool isEqualTo(const Type *other) const; + virtual bool isLessThan(const Type *other) const; +}; + +class GLSL_EXPORT DoubleType: public Type +{ +public: + virtual const DoubleType *asDoubleType() const { return this; } + virtual bool isEqualTo(const Type *other) const; + virtual bool isLessThan(const Type *other) const; +}; + +class GLSL_EXPORT VectorType: public Type +{ +public: + VectorType(const Type *elementType, int dimension) + : _elementType(elementType), _dimension(dimension) {} + + const Type *elementType() const { return _elementType; } + int dimension() const { return _dimension; } + + virtual const VectorType *asVectorType() const { return this; } + virtual bool isEqualTo(const Type *other) const; + virtual bool isLessThan(const Type *other) const; + +private: + const Type *_elementType; + int _dimension; +}; + +class GLSL_EXPORT MatrixType: public Type +{ +public: + MatrixType(const Type *elementType, int columns, int rows) + : _elementType(elementType), _columns(columns), _rows(rows) {} + + const Type *elementType() const { return _elementType; } + int columns() const { return _columns; } + int rows() const { return _rows; } + + virtual const MatrixType *asMatrixType() const { return this; } + virtual bool isEqualTo(const Type *other) const; + virtual bool isLessThan(const Type *other) const; + +private: + const Type *_elementType; + int _columns; + int _rows; +}; + +} // end of namespace GLSL + +#endif // GLSLTYPES_H diff --git a/src/libs/glsl/tests/main.cpp b/src/libs/glsl/tests/main.cpp index 7ae42c3fb5..e57179a752 100644 --- a/src/libs/glsl/tests/main.cpp +++ b/src/libs/glsl/tests/main.cpp @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) variant |= Lexer::Variant_VertexShader | Lexer::Variant_FragmentShader; Engine engine; Parser parser(&engine, source, size, variant); - TranslationUnit *ast = parser.parse(); + TranslationUnitAST *ast = parser.parse(); std::cout << argv[1] << (ast ? " OK " : " KO ") << std::endl; ASTDump dump(qout); diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp index c933ce20fe..f256ee50fb 100644 --- a/src/plugins/glsleditor/glsleditor.cpp +++ b/src/plugins/glsleditor/glsleditor.cpp @@ -264,7 +264,7 @@ void GLSLTextEditor::updateDocumentNow() Engine engine; Parser parser(&engine, preprocessedCode.constData(), preprocessedCode.size(), variant); - TranslationUnit *ast = parser.parse(); + TranslationUnitAST *ast = parser.parse(); QTextCharFormat errorFormat; errorFormat.setUnderlineStyle(QTextCharFormat::WaveUnderline); -- cgit v1.2.1