X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fsyntax.h;h=682a0f5aeeaa2246b01226df25536a23a91d9c7a;hb=19a24f859cd7fcf581442319499ae24b3e7385a4;hp=7729611c2a5e2a3d013b2e8a5112391af52ae668;hpb=c6d59d1b35ee981c10ee8b9870338ffbaaa23e19;p=libs%2Fgl.git diff --git a/source/glsl/syntax.h b/source/glsl/syntax.h index 7729611c..682a0f5a 100644 --- a/source/glsl/syntax.h +++ b/source/glsl/syntax.h @@ -39,6 +39,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; @@ -96,7 +104,7 @@ struct FunctionDeclaration; struct Statement: Node { - unsigned source; + int source; unsigned line; Statement(); @@ -108,9 +116,8 @@ struct Block: Node { NodeList body; bool use_braces; - std::map types; + std::map variables; - std::map interfaces; Block *parent; Block(); @@ -122,6 +129,10 @@ struct Block: Node struct Expression: Node { + const Operator *oper; + + Expression(); + virtual Expression *clone() const = 0; }; @@ -144,6 +155,7 @@ struct ParenthesizedExpression: Expression struct VariableReference: Expression { std::string name; + VariableDeclaration *declaration; VariableReference(); @@ -156,6 +168,7 @@ struct VariableReference: Expression struct InterfaceBlockReference: Expression { std::string name; + InterfaceBlock *declaration; InterfaceBlockReference(); @@ -169,6 +182,7 @@ struct MemberAccess: Expression { NodePtr left; std::string member; + VariableDeclaration *declaration; MemberAccess(); @@ -180,11 +194,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 &); @@ -193,9 +203,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 &); @@ -204,6 +212,7 @@ struct BinaryExpression: Expression struct Assignment: BinaryExpression { bool self_referencing; + VariableDeclaration *target_declaration; Assignment(); @@ -216,10 +225,11 @@ struct Assignment: BinaryExpression struct FunctionCall: Expression { std::string name; - FunctionDeclaration *declaration; bool constructor; NodeArray arguments; + FunctionDeclaration *declaration; + FunctionCall(); FunctionCall(const FunctionCall &); @@ -289,19 +299,20 @@ 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 &); @@ -318,6 +329,7 @@ struct InterfaceBlock: Statement Block members; std::string instance_name; bool array; + InterfaceBlock *linked_block; InterfaceBlock(); @@ -333,9 +345,10 @@ struct FunctionDeclaration: Statement std::string return_type; std::string name; NodeArray parameters; - FunctionDeclaration *definition; Block body; + FunctionDeclaration *definition; + FunctionDeclaration(); FunctionDeclaration(const FunctionDeclaration &); @@ -401,6 +414,9 @@ struct Stage Type type; Stage *previous; Block content; + std::map types; + std::map interface_blocks; + std::map functions; std::map locations; Features required_features;