X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fsyntax.h;h=da7b0907e37460d5b7041d32e2c921dee9473563;hb=0febee9a8fdf1f9b03d3f2e23e72f8194b3698c7;hp=3fb848d2ceb81a91fdc07ab19f0e072b0b71010c;hpb=c0be4e4ae1a8b6ac31ff6b7080e2242c13d947ff;p=libs%2Fgl.git diff --git a/source/glsl/syntax.h b/source/glsl/syntax.h index 3fb848d2..da7b0907 100644 --- a/source/glsl/syntax.h +++ b/source/glsl/syntax.h @@ -3,10 +3,12 @@ #include #include +#include #include #include #include #include "features.h" +#include "glsl_error.h" #include "sourcemap.h" #pragma push_macro("interface") @@ -29,7 +31,8 @@ struct Operator enum Associativity { LEFT_TO_RIGHT, - RIGHT_TO_LEFT + RIGHT_TO_LEFT, + ASSOCIATIVE }; char token[4]; @@ -38,6 +41,14 @@ struct Operator Associativity assoc; static const Operator operators[]; + + static const Operator &get_operator(const std::string &, Type); +}; + +enum +{ + BUILTIN_SOURCE = -1, + GENERATED_SOURCE = 0 }; struct NodeVisitor; @@ -90,11 +101,12 @@ class NodeArray: public NodeContainer > > struct StructDeclaration; struct VariableDeclaration; +struct InterfaceBlock; struct FunctionDeclaration; struct Statement: Node { - unsigned source; + int source; unsigned line; Statement(); @@ -106,8 +118,7 @@ struct Block: Node { NodeList body; bool use_braces; - bool anonymous; - std::map types; + std::map variables; Block *parent; @@ -120,6 +131,10 @@ struct Block: Node struct Expression: Node { + const Operator *oper; + + Expression(); + virtual Expression *clone() const = 0; }; @@ -142,6 +157,7 @@ struct ParenthesizedExpression: Expression struct VariableReference: Expression { std::string name; + VariableDeclaration *declaration; VariableReference(); @@ -151,10 +167,24 @@ struct VariableReference: Expression virtual void visit(NodeVisitor &); }; +struct InterfaceBlockReference: Expression +{ + std::string name; + + InterfaceBlock *declaration; + + InterfaceBlockReference(); + InterfaceBlockReference(const InterfaceBlockReference &); + + virtual InterfaceBlockReference *clone() const { return new InterfaceBlockReference(*this); } + virtual void visit(NodeVisitor &); +}; + struct MemberAccess: Expression { NodePtr left; std::string member; + VariableDeclaration *declaration; MemberAccess(); @@ -166,11 +196,7 @@ struct MemberAccess: Expression struct UnaryExpression: Expression { - std::string oper; NodePtr expression; - bool prefix; - - UnaryExpression(); virtual UnaryExpression *clone() const { return new UnaryExpression(*this); } virtual void visit(NodeVisitor &); @@ -179,9 +205,7 @@ struct UnaryExpression: Expression struct BinaryExpression: Expression { NodePtr left; - std::string oper; NodePtr right; - std::string after; virtual BinaryExpression *clone() const { return new BinaryExpression(*this); } virtual void visit(NodeVisitor &); @@ -190,6 +214,7 @@ struct BinaryExpression: Expression struct Assignment: BinaryExpression { bool self_referencing; + VariableDeclaration *target_declaration; Assignment(); @@ -202,10 +227,11 @@ struct Assignment: BinaryExpression struct FunctionCall: Expression { std::string name; - FunctionDeclaration *declaration; bool constructor; NodeArray arguments; + FunctionDeclaration *declaration; + FunctionCall(); FunctionCall(const FunctionCall &); @@ -242,9 +268,9 @@ struct Layout: Node { struct Qualifier { - // TODO the standard calls this name, not identifier - std::string identifier; - std::string value; + std::string name; + bool has_value; + int value; }; std::vector qualifiers; @@ -275,22 +301,24 @@ struct StructDeclaration: Statement struct VariableDeclaration: Statement { + NodePtr layout; bool constant; std::string sampling; std::string interpolation; std::string interface; std::string precision; std::string type; - StructDeclaration *type_declaration; std::string name; bool array; NodePtr array_size; NodePtr init_expression; + + StructDeclaration *type_declaration; VariableDeclaration *linked_declaration; - NodePtr layout; VariableDeclaration(); VariableDeclaration(const VariableDeclaration &); + ~VariableDeclaration(); virtual VariableDeclaration *clone() const { return new VariableDeclaration(*this); } virtual void visit(NodeVisitor &); @@ -304,7 +332,11 @@ struct InterfaceBlock: Statement std::string instance_name; bool array; + InterfaceBlock *linked_block; + InterfaceBlock(); + InterfaceBlock(const InterfaceBlock &); + ~InterfaceBlock(); virtual InterfaceBlock *clone() const { return new InterfaceBlock(*this); } virtual void visit(NodeVisitor &); @@ -315,9 +347,10 @@ struct FunctionDeclaration: Statement std::string return_type; std::string name; NodeArray parameters; - FunctionDeclaration *definition; Block body; + FunctionDeclaration *definition; + FunctionDeclaration(); FunctionDeclaration(const FunctionDeclaration &); @@ -337,7 +370,7 @@ struct Conditional: Statement struct Iteration: Statement { - NodePtr init_statement; + NodePtr init_statement; NodePtr condition; NodePtr loop_expression; Block body; @@ -383,10 +416,12 @@ struct Stage Type type; Stage *previous; Block content; - std::map in_variables; - std::map out_variables; + std::map types; + std::map interface_blocks; + std::map functions; std::map locations; Features required_features; + std::vector diagnostics; Stage(Type);