forked from qt-creator/qt-creator
Variable and parameter declarations for GLSL
This commit is contained in:
@@ -288,6 +288,10 @@ public:
|
|||||||
int qualifier;
|
int qualifier;
|
||||||
List<LayoutQualifier *> *layout_list;
|
List<LayoutQualifier *> *layout_list;
|
||||||
} type_qualifier;
|
} type_qualifier;
|
||||||
|
struct {
|
||||||
|
Type *type;
|
||||||
|
const std::string *name;
|
||||||
|
} param_declarator;
|
||||||
// ### ast nodes...
|
// ### ast nodes...
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1126,7 +1130,7 @@ case $rule_number: {
|
|||||||
declaration ::= init_declarator_list SEMICOLON ;
|
declaration ::= init_declarator_list SEMICOLON ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<InitDeclaration>(sym(1).declaration_list);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
@@ -1217,182 +1221,230 @@ case $rule_number: {
|
|||||||
parameter_declarator ::= type_specifier IDENTIFIER ;
|
parameter_declarator ::= type_specifier IDENTIFIER ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
sym(1).param_declarator.type = type(1);
|
||||||
|
sym(1).param_declarator.name = string(2);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
parameter_declarator ::= type_specifier IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET ;
|
parameter_declarator ::= type_specifier IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
sym(1).param_declarator.type = makeAstNode<ArrayType>(type(1), expression(4));
|
||||||
|
sym(1).param_declarator.name = string(2);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
parameter_declaration ::= parameter_type_qualifier parameter_qualifier parameter_declarator ;
|
parameter_declaration ::= parameter_type_qualifier parameter_qualifier parameter_declarator ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<ParameterDeclaration>
|
||||||
|
(makeAstNode<QualifiedType>
|
||||||
|
(sym(1).qualifier, sym(3).param_declarator.type,
|
||||||
|
(List<LayoutQualifier *> *)0),
|
||||||
|
ParameterDeclaration::Qualifier(sym(2).qualifier),
|
||||||
|
sym(3).param_declarator.name);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
parameter_declaration ::= parameter_qualifier parameter_declarator ;
|
parameter_declaration ::= parameter_qualifier parameter_declarator ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<ParameterDeclaration>
|
||||||
|
(sym(2).param_declarator.type,
|
||||||
|
ParameterDeclaration::Qualifier(sym(1).qualifier),
|
||||||
|
sym(2).param_declarator.name);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
parameter_declaration ::= parameter_type_qualifier parameter_qualifier parameter_type_specifier ;
|
parameter_declaration ::= parameter_type_qualifier parameter_qualifier parameter_type_specifier ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<ParameterDeclaration>
|
||||||
|
(makeAstNode<QualifiedType>
|
||||||
|
(sym(1).qualifier, type(3), (List<LayoutQualifier *> *)0),
|
||||||
|
ParameterDeclaration::Qualifier(sym(2).qualifier),
|
||||||
|
(const std::string *)0);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
parameter_declaration ::= parameter_qualifier parameter_type_specifier ;
|
parameter_declaration ::= parameter_qualifier parameter_type_specifier ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<ParameterDeclaration>
|
||||||
|
(type(2), ParameterDeclaration::Qualifier(sym(1).qualifier),
|
||||||
|
(const std::string *)0);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
parameter_qualifier ::= empty ;
|
parameter_qualifier ::= empty ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
sym(1).qualifier = ParameterDeclaration::In;
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
parameter_qualifier ::= IN ;
|
parameter_qualifier ::= IN ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
sym(1).qualifier = ParameterDeclaration::In;
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
parameter_qualifier ::= OUT ;
|
parameter_qualifier ::= OUT ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
sym(1).qualifier = ParameterDeclaration::Out;
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
parameter_qualifier ::= INOUT ;
|
parameter_qualifier ::= INOUT ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
sym(1).qualifier = ParameterDeclaration::InOut;
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
parameter_type_specifier ::= type_specifier ;
|
parameter_type_specifier ::= type_specifier ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
// nothing to do.
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
init_declarator_list ::= single_declaration ;
|
init_declarator_list ::= single_declaration ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
sym(1).declaration_list = makeAstNode< List<Declaration *> >
|
||||||
|
(sym(1).declaration);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
init_declarator_list ::= init_declarator_list COMMA IDENTIFIER ;
|
init_declarator_list ::= init_declarator_list COMMA IDENTIFIER ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
Type *type = VariableDeclaration::declarationType(sym(1).declaration_list);
|
||||||
|
Declaration *decl = makeAstNode<VariableDeclaration>(type, string(3));
|
||||||
|
sym(1).declaration_list = makeAstNode< List<Declaration *> >
|
||||||
|
(sym(1).declaration_list, decl);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
init_declarator_list ::= init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET ;
|
init_declarator_list ::= init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
Type *type = VariableDeclaration::declarationType(sym(1).declaration_list);
|
||||||
|
type = makeAstNode<ArrayType>(type);
|
||||||
|
Declaration *decl = makeAstNode<VariableDeclaration>(type, string(3));
|
||||||
|
sym(1).declaration_list = makeAstNode< List<Declaration *> >
|
||||||
|
(sym(1).declaration_list, decl);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
init_declarator_list ::= init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET ;
|
init_declarator_list ::= init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
Type *type = VariableDeclaration::declarationType(sym(1).declaration_list);
|
||||||
|
type = makeAstNode<ArrayType>(type, expression(5));
|
||||||
|
Declaration *decl = makeAstNode<VariableDeclaration>(type, string(3));
|
||||||
|
sym(1).declaration_list = makeAstNode< List<Declaration *> >
|
||||||
|
(sym(1).declaration_list, decl);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
init_declarator_list ::= init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET EQUAL initializer ;
|
init_declarator_list ::= init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET EQUAL initializer ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
Type *type = VariableDeclaration::declarationType(sym(1).declaration_list);
|
||||||
|
type = makeAstNode<ArrayType>(type);
|
||||||
|
Declaration *decl = makeAstNode<VariableDeclaration>
|
||||||
|
(type, string(3), expression(7));
|
||||||
|
sym(1).declaration_list = makeAstNode< List<Declaration *> >
|
||||||
|
(sym(1).declaration_list, decl);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
init_declarator_list ::= init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET EQUAL initializer ;
|
init_declarator_list ::= init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET EQUAL initializer ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
Type *type = VariableDeclaration::declarationType(sym(1).declaration_list);
|
||||||
|
type = makeAstNode<ArrayType>(type, expression(5));
|
||||||
|
Declaration *decl = makeAstNode<VariableDeclaration>
|
||||||
|
(type, string(3), expression(8));
|
||||||
|
sym(1).declaration_list = makeAstNode< List<Declaration *> >
|
||||||
|
(sym(1).declaration_list, decl);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
init_declarator_list ::= init_declarator_list COMMA IDENTIFIER EQUAL initializer ;
|
init_declarator_list ::= init_declarator_list COMMA IDENTIFIER EQUAL initializer ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
Type *type = VariableDeclaration::declarationType(sym(1).declaration_list);
|
||||||
|
Declaration *decl = makeAstNode<VariableDeclaration>
|
||||||
|
(type, string(3), expression(5));
|
||||||
|
sym(1).declaration_list = makeAstNode< List<Declaration *> >
|
||||||
|
(sym(1).declaration_list, decl);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
single_declaration ::= fully_specified_type ;
|
single_declaration ::= fully_specified_type ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<TypeDeclaration>(type(1));
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
single_declaration ::= fully_specified_type IDENTIFIER ;
|
single_declaration ::= fully_specified_type IDENTIFIER ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<VariableDeclaration>(type(1), string(2));
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
single_declaration ::= fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET ;
|
single_declaration ::= fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<VariableDeclaration>
|
||||||
|
(makeAstNode<ArrayType>(type(1)), string(2));
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
single_declaration ::= fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET ;
|
single_declaration ::= fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<VariableDeclaration>
|
||||||
|
(makeAstNode<ArrayType>(type(1), expression(4)), string(2));
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
single_declaration ::= fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET EQUAL initializer ;
|
single_declaration ::= fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET EQUAL initializer ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<VariableDeclaration>
|
||||||
|
(makeAstNode<ArrayType>(type(1)), string(2), expression(6));
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
single_declaration ::= fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET EQUAL initializer ;
|
single_declaration ::= fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET EQUAL initializer ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<VariableDeclaration>
|
||||||
|
(makeAstNode<ArrayType>(type(1), expression(4)),
|
||||||
|
string(2), expression(7));
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
single_declaration ::= fully_specified_type IDENTIFIER EQUAL initializer ;
|
single_declaration ::= fully_specified_type IDENTIFIER EQUAL initializer ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<VariableDeclaration>
|
||||||
|
(type(1), string(2), expression(4));
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
single_declaration ::= INVARIANT IDENTIFIER ;
|
single_declaration ::= INVARIANT IDENTIFIER ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<InvariantDeclaration>(string(2));
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
@@ -2391,14 +2443,14 @@ case $rule_number: {
|
|||||||
initializer ::= assignment_expression ;
|
initializer ::= assignment_expression ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
// nothing to do.
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
declaration_statement ::= declaration ;
|
declaration_statement ::= declaration ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<DeclarationStatement>(sym(1).declaration_list);
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
@@ -2568,7 +2620,8 @@ case $rule_number: {
|
|||||||
condition ::= fully_specified_type IDENTIFIER EQUAL initializer ;
|
condition ::= fully_specified_type IDENTIFIER EQUAL initializer ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
ast(1) = makeAstNode<DeclarationExpression>
|
||||||
|
(type(1), string(2), expression(4));
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
@@ -2755,7 +2808,7 @@ case $rule_number: {
|
|||||||
external_declaration ::= declaration ;
|
external_declaration ::= declaration ;
|
||||||
/.
|
/.
|
||||||
case $rule_number: {
|
case $rule_number: {
|
||||||
// ast(1) = new ...AST(...);
|
// nothing to do.
|
||||||
} break;
|
} break;
|
||||||
./
|
./
|
||||||
|
|
||||||
|
|||||||
@@ -124,6 +124,15 @@ void FunctionIdentifier::accept0(Visitor *visitor)
|
|||||||
visitor->endVisit(this);
|
visitor->endVisit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeclarationExpression::accept0(Visitor *visitor)
|
||||||
|
{
|
||||||
|
if (visitor->visit(this)) {
|
||||||
|
accept(type, visitor);
|
||||||
|
accept(initializer, visitor);
|
||||||
|
}
|
||||||
|
visitor->endVisit(this);
|
||||||
|
}
|
||||||
|
|
||||||
void ExpressionStatement::accept0(Visitor *visitor)
|
void ExpressionStatement::accept0(Visitor *visitor)
|
||||||
{
|
{
|
||||||
if (visitor->visit(this))
|
if (visitor->visit(this))
|
||||||
@@ -206,6 +215,13 @@ void CaseLabelStatement::accept0(Visitor *visitor)
|
|||||||
visitor->endVisit(this);
|
visitor->endVisit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeclarationStatement::accept0(Visitor *visitor)
|
||||||
|
{
|
||||||
|
if (visitor->visit(this))
|
||||||
|
accept(decls, visitor);
|
||||||
|
visitor->endVisit(this);
|
||||||
|
}
|
||||||
|
|
||||||
BasicType::BasicType(int _token, const char *_name, Category _category)
|
BasicType::BasicType(int _token, const char *_name, Category _category)
|
||||||
: Type(Kind_BasicType), token(_token), name(_name), categ(_category)
|
: Type(Kind_BasicType), token(_token), name(_name), categ(_category)
|
||||||
{
|
{
|
||||||
@@ -348,3 +364,45 @@ void PrecisionDeclaration::accept0(Visitor *visitor)
|
|||||||
accept(type, visitor);
|
accept(type, visitor);
|
||||||
visitor->endVisit(this);
|
visitor->endVisit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ParameterDeclaration::accept0(Visitor *visitor)
|
||||||
|
{
|
||||||
|
if (visitor->visit(this))
|
||||||
|
accept(type, visitor);
|
||||||
|
visitor->endVisit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VariableDeclaration::accept0(Visitor *visitor)
|
||||||
|
{
|
||||||
|
if (visitor->visit(this)) {
|
||||||
|
accept(type, visitor);
|
||||||
|
accept(initializer, visitor);
|
||||||
|
}
|
||||||
|
visitor->endVisit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
Type *VariableDeclaration::declarationType(List<Declaration *> *decls)
|
||||||
|
{
|
||||||
|
VariableDeclaration *var = decls->value->asVariableDeclaration();
|
||||||
|
return var ? var->type : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TypeDeclaration::accept0(Visitor *visitor)
|
||||||
|
{
|
||||||
|
if (visitor->visit(this))
|
||||||
|
accept(type, visitor);
|
||||||
|
visitor->endVisit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InvariantDeclaration::accept0(Visitor *visitor)
|
||||||
|
{
|
||||||
|
visitor->visit(this);
|
||||||
|
visitor->endVisit(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitDeclaration::accept0(Visitor *visitor)
|
||||||
|
{
|
||||||
|
if (visitor->visit(this))
|
||||||
|
accept(decls, visitor);
|
||||||
|
visitor->endVisit(this);
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class AssignmentExpression;
|
|||||||
class MemberAccessExpression;
|
class MemberAccessExpression;
|
||||||
class FunctionCallExpression;
|
class FunctionCallExpression;
|
||||||
class FunctionIdentifier;
|
class FunctionIdentifier;
|
||||||
|
class DeclarationExpression;
|
||||||
class Statement;
|
class Statement;
|
||||||
class ExpressionStatement;
|
class ExpressionStatement;
|
||||||
class CompoundStatement;
|
class CompoundStatement;
|
||||||
@@ -58,6 +59,7 @@ class JumpStatement;
|
|||||||
class ReturnStatement;
|
class ReturnStatement;
|
||||||
class SwitchStatement;
|
class SwitchStatement;
|
||||||
class CaseLabelStatement;
|
class CaseLabelStatement;
|
||||||
|
class DeclarationStatement;
|
||||||
class Type;
|
class Type;
|
||||||
class BasicType;
|
class BasicType;
|
||||||
class NamedType;
|
class NamedType;
|
||||||
@@ -66,6 +68,11 @@ class StructType;
|
|||||||
class QualifiedType;
|
class QualifiedType;
|
||||||
class Declaration;
|
class Declaration;
|
||||||
class PrecisionDeclaration;
|
class PrecisionDeclaration;
|
||||||
|
class ParameterDeclaration;
|
||||||
|
class VariableDeclaration;
|
||||||
|
class TypeDeclaration;
|
||||||
|
class InvariantDeclaration;
|
||||||
|
class InitDeclaration;
|
||||||
class Visitor;
|
class Visitor;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -161,6 +168,7 @@ public:
|
|||||||
Kind_FunctionCall,
|
Kind_FunctionCall,
|
||||||
Kind_MemberFunctionCall,
|
Kind_MemberFunctionCall,
|
||||||
Kind_FunctionIdentifier,
|
Kind_FunctionIdentifier,
|
||||||
|
Kind_DeclarationExpression,
|
||||||
|
|
||||||
// Assignment expressions
|
// Assignment expressions
|
||||||
Kind_Assign,
|
Kind_Assign,
|
||||||
@@ -190,6 +198,7 @@ public:
|
|||||||
Kind_Switch,
|
Kind_Switch,
|
||||||
Kind_CaseLabel,
|
Kind_CaseLabel,
|
||||||
Kind_DefaultLabel,
|
Kind_DefaultLabel,
|
||||||
|
Kind_DeclarationStatement,
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
Kind_BasicType,
|
Kind_BasicType,
|
||||||
@@ -202,7 +211,12 @@ public:
|
|||||||
Kind_QualifiedType,
|
Kind_QualifiedType,
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
Kind_PrecisionDeclaration
|
Kind_PrecisionDeclaration,
|
||||||
|
Kind_ParameterDeclaration,
|
||||||
|
Kind_VariableDeclaration,
|
||||||
|
Kind_TypeDeclaration,
|
||||||
|
Kind_InvariantDeclaration,
|
||||||
|
Kind_InitDeclaration
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual TranslationUnit *asTranslationUnit() { return 0; }
|
virtual TranslationUnit *asTranslationUnit() { return 0; }
|
||||||
@@ -217,6 +231,7 @@ public:
|
|||||||
virtual MemberAccessExpression *asMemberAccessExpression() { return 0; }
|
virtual MemberAccessExpression *asMemberAccessExpression() { return 0; }
|
||||||
virtual FunctionCallExpression *asFunctionCallExpression() { return 0; }
|
virtual FunctionCallExpression *asFunctionCallExpression() { return 0; }
|
||||||
virtual FunctionIdentifier *asFunctionIdentifier() { return 0; }
|
virtual FunctionIdentifier *asFunctionIdentifier() { return 0; }
|
||||||
|
virtual DeclarationExpression *asDeclarationExpression() { return 0; }
|
||||||
|
|
||||||
virtual Statement *asStatement() { return 0; }
|
virtual Statement *asStatement() { return 0; }
|
||||||
virtual ExpressionStatement *asExpressionStatement() { return 0; }
|
virtual ExpressionStatement *asExpressionStatement() { return 0; }
|
||||||
@@ -229,6 +244,7 @@ public:
|
|||||||
virtual ReturnStatement *asReturnStatement() { return 0; }
|
virtual ReturnStatement *asReturnStatement() { return 0; }
|
||||||
virtual SwitchStatement *asSwitchStatement() { return 0; }
|
virtual SwitchStatement *asSwitchStatement() { return 0; }
|
||||||
virtual CaseLabelStatement *asCaseLabelStatement() { return 0; }
|
virtual CaseLabelStatement *asCaseLabelStatement() { return 0; }
|
||||||
|
virtual DeclarationStatement *asDeclarationStatement() { return 0; }
|
||||||
|
|
||||||
virtual Type *asType() { return 0; }
|
virtual Type *asType() { return 0; }
|
||||||
virtual BasicType *asBasicType() { return 0; }
|
virtual BasicType *asBasicType() { return 0; }
|
||||||
@@ -239,6 +255,11 @@ public:
|
|||||||
|
|
||||||
virtual Declaration *asDeclaration() { return 0; }
|
virtual Declaration *asDeclaration() { return 0; }
|
||||||
virtual PrecisionDeclaration *asPrecisionDeclaration() { return 0; }
|
virtual PrecisionDeclaration *asPrecisionDeclaration() { return 0; }
|
||||||
|
virtual ParameterDeclaration *asParameterDeclaration() { return 0; }
|
||||||
|
virtual VariableDeclaration *asVariableDeclaration() { return 0; }
|
||||||
|
virtual TypeDeclaration *asTypeDeclaration() { return 0; }
|
||||||
|
virtual InvariantDeclaration *asInvariantDeclaration() { return 0; }
|
||||||
|
virtual InitDeclaration *asInitDeclaration() { return 0; }
|
||||||
|
|
||||||
void accept(Visitor *visitor);
|
void accept(Visitor *visitor);
|
||||||
static void accept(AST *ast, Visitor *visitor);
|
static void accept(AST *ast, Visitor *visitor);
|
||||||
@@ -436,6 +457,24 @@ public: // attributes
|
|||||||
Type *type;
|
Type *type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GLSL_EXPORT DeclarationExpression: public Expression
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeclarationExpression(Type *_type, const std::string *_name,
|
||||||
|
Expression *_initializer)
|
||||||
|
: Expression(Kind_DeclarationExpression), type(_type)
|
||||||
|
, name(_name), initializer(_initializer) {}
|
||||||
|
|
||||||
|
virtual DeclarationExpression *asDeclarationExpression() { return this; }
|
||||||
|
|
||||||
|
virtual void accept0(Visitor *visitor);
|
||||||
|
|
||||||
|
public: // attributes
|
||||||
|
Type *type;
|
||||||
|
const std::string *name;
|
||||||
|
Expression *initializer;
|
||||||
|
};
|
||||||
|
|
||||||
class GLSL_EXPORT Statement: public AST
|
class GLSL_EXPORT Statement: public AST
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@@ -594,6 +633,20 @@ public: // attributes
|
|||||||
Expression *expr;
|
Expression *expr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GLSL_EXPORT DeclarationStatement: public Statement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeclarationStatement(List<Declaration *> *_decls)
|
||||||
|
: Statement(Kind_DeclarationStatement), decls(finish(_decls)) {}
|
||||||
|
|
||||||
|
virtual DeclarationStatement *asDeclarationStatement() { return this; }
|
||||||
|
|
||||||
|
virtual void accept0(Visitor *visitor);
|
||||||
|
|
||||||
|
public: // attributes
|
||||||
|
List<Declaration *> *decls;
|
||||||
|
};
|
||||||
|
|
||||||
class GLSL_EXPORT Type: public AST
|
class GLSL_EXPORT Type: public AST
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@@ -775,7 +828,7 @@ class GLSL_EXPORT QualifiedType: public Type
|
|||||||
public:
|
public:
|
||||||
QualifiedType(int _qualifiers, Type *_type, List<LayoutQualifier *> *_layout_list)
|
QualifiedType(int _qualifiers, Type *_type, List<LayoutQualifier *> *_layout_list)
|
||||||
: Type(Kind_QualifiedType), qualifiers(_qualifiers), type(_type)
|
: Type(Kind_QualifiedType), qualifiers(_qualifiers), type(_type)
|
||||||
, layout_list(_layout_list) {}
|
, layout_list(finish(_layout_list)) {}
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@@ -842,6 +895,92 @@ public: // attributes
|
|||||||
Type *type;
|
Type *type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ParameterDeclaration: public Declaration
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum Qualifier
|
||||||
|
{
|
||||||
|
In,
|
||||||
|
Out,
|
||||||
|
InOut
|
||||||
|
};
|
||||||
|
ParameterDeclaration(Type *_type, Qualifier _qualifier,
|
||||||
|
const std::string *_name)
|
||||||
|
: Declaration(Kind_ParameterDeclaration), type(_type)
|
||||||
|
, qualifier(_qualifier), name(_name) {}
|
||||||
|
|
||||||
|
virtual ParameterDeclaration *asParameterDeclaration() { return this; }
|
||||||
|
|
||||||
|
virtual void accept0(Visitor *visitor);
|
||||||
|
|
||||||
|
public: // attributes
|
||||||
|
Type *type;
|
||||||
|
Qualifier qualifier;
|
||||||
|
const std::string *name;
|
||||||
|
};
|
||||||
|
|
||||||
|
class VariableDeclaration: public Declaration
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VariableDeclaration(Type *_type, const std::string *_name,
|
||||||
|
Expression *_initializer = 0)
|
||||||
|
: Declaration(Kind_VariableDeclaration), type(_type)
|
||||||
|
, name(_name), initializer(_initializer) {}
|
||||||
|
|
||||||
|
virtual VariableDeclaration *asVariableDeclaration() { return this; }
|
||||||
|
|
||||||
|
virtual void accept0(Visitor *visitor);
|
||||||
|
|
||||||
|
static Type *declarationType(List<Declaration *> *decls);
|
||||||
|
|
||||||
|
public: // attributes
|
||||||
|
Type *type;
|
||||||
|
const std::string *name;
|
||||||
|
Expression *initializer;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TypeDeclaration: public Declaration
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TypeDeclaration(Type *_type)
|
||||||
|
: Declaration(Kind_TypeDeclaration), type(_type) {}
|
||||||
|
|
||||||
|
virtual TypeDeclaration *asTypeDeclaration() { return this; }
|
||||||
|
|
||||||
|
virtual void accept0(Visitor *visitor);
|
||||||
|
|
||||||
|
public: // attributes
|
||||||
|
Type *type;
|
||||||
|
};
|
||||||
|
|
||||||
|
class InvariantDeclaration: public Declaration
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InvariantDeclaration(const std::string *_name)
|
||||||
|
: Declaration(Kind_InvariantDeclaration), name(_name) {}
|
||||||
|
|
||||||
|
virtual InvariantDeclaration *asInvariantDeclaration() { return this; }
|
||||||
|
|
||||||
|
virtual void accept0(Visitor *visitor);
|
||||||
|
|
||||||
|
public: // attributes
|
||||||
|
const std::string *name;
|
||||||
|
};
|
||||||
|
|
||||||
|
class InitDeclaration: public Declaration
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
InitDeclaration(List<Declaration *> *_decls)
|
||||||
|
: Declaration(Kind_InitDeclaration), decls(finish(_decls)) {}
|
||||||
|
|
||||||
|
virtual InitDeclaration *asInitDeclaration() { return this; }
|
||||||
|
|
||||||
|
virtual void accept0(Visitor *visitor);
|
||||||
|
|
||||||
|
public: // attributes
|
||||||
|
List<Declaration *> *decls;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace GLSL
|
} // namespace GLSL
|
||||||
|
|
||||||
#endif // GLSLAST_H
|
#endif // GLSLAST_H
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ public:
|
|||||||
virtual bool visit(FunctionIdentifier *) { return true; }
|
virtual bool visit(FunctionIdentifier *) { return true; }
|
||||||
virtual void endVisit(FunctionIdentifier *) {}
|
virtual void endVisit(FunctionIdentifier *) {}
|
||||||
|
|
||||||
|
virtual bool visit(DeclarationExpression *) { return true; }
|
||||||
|
virtual void endVisit(DeclarationExpression *) {}
|
||||||
|
|
||||||
virtual bool visit(ExpressionStatement *) { return true; }
|
virtual bool visit(ExpressionStatement *) { return true; }
|
||||||
virtual void endVisit(ExpressionStatement *) {}
|
virtual void endVisit(ExpressionStatement *) {}
|
||||||
|
|
||||||
@@ -102,6 +105,9 @@ public:
|
|||||||
virtual bool visit(CaseLabelStatement *) { return true; }
|
virtual bool visit(CaseLabelStatement *) { return true; }
|
||||||
virtual void endVisit(CaseLabelStatement *) {}
|
virtual void endVisit(CaseLabelStatement *) {}
|
||||||
|
|
||||||
|
virtual bool visit(DeclarationStatement *) { return true; }
|
||||||
|
virtual void endVisit(DeclarationStatement *) {}
|
||||||
|
|
||||||
virtual bool visit(BasicType *) { return true; }
|
virtual bool visit(BasicType *) { return true; }
|
||||||
virtual void endVisit(BasicType *) {}
|
virtual void endVisit(BasicType *) {}
|
||||||
|
|
||||||
@@ -122,6 +128,21 @@ public:
|
|||||||
|
|
||||||
virtual bool visit(PrecisionDeclaration *) { return true; }
|
virtual bool visit(PrecisionDeclaration *) { return true; }
|
||||||
virtual void endVisit(PrecisionDeclaration *) {}
|
virtual void endVisit(PrecisionDeclaration *) {}
|
||||||
|
|
||||||
|
virtual bool visit(ParameterDeclaration *) { return true; }
|
||||||
|
virtual void endVisit(ParameterDeclaration *) {}
|
||||||
|
|
||||||
|
virtual bool visit(VariableDeclaration *) { return true; }
|
||||||
|
virtual void endVisit(VariableDeclaration *) {}
|
||||||
|
|
||||||
|
virtual bool visit(TypeDeclaration *) { return true; }
|
||||||
|
virtual void endVisit(TypeDeclaration *) {}
|
||||||
|
|
||||||
|
virtual bool visit(InvariantDeclaration *) { return true; }
|
||||||
|
virtual void endVisit(InvariantDeclaration *) {}
|
||||||
|
|
||||||
|
virtual bool visit(InitDeclaration *) { return true; }
|
||||||
|
virtual void endVisit(InitDeclaration *) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GLSL
|
} // namespace GLSL
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -79,6 +79,10 @@ public:
|
|||||||
int qualifier;
|
int qualifier;
|
||||||
List<LayoutQualifier *> *layout_list;
|
List<LayoutQualifier *> *layout_list;
|
||||||
} type_qualifier;
|
} type_qualifier;
|
||||||
|
struct {
|
||||||
|
Type *type;
|
||||||
|
const std::string *name;
|
||||||
|
} param_declarator;
|
||||||
// ### ast nodes...
|
// ### ast nodes...
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user