summaryrefslogtreecommitdiff
path: root/src/glsl/ast.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl/ast.h')
-rw-r--r--src/glsl/ast.h95
1 files changed, 74 insertions, 21 deletions
diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index 44c31b6e62..e5aa5c1b3b 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -33,6 +33,20 @@ struct _mesa_glsl_parse_state;
struct YYLTYPE;
+/**
+ * \defgroup AST Abstract syntax tree node definitions
+ *
+ * An abstract syntax tree is generated by the parser. This is a fairly
+ * direct representation of the gramma derivation for the source program.
+ * No symantic checking is done during the generation of the AST. Only
+ * syntactic checking is done. Symantic checking is performed by a later
+ * stage that converts the AST to a more generic intermediate representation.
+ *
+ *@{
+ */
+/**
+ * Base class of all abstract syntax tree nodes
+ */
class ast_node {
public:
/* Callers of this talloc-based new need not call delete. It's
@@ -54,7 +68,14 @@ public:
talloc_free(table);
}
+ /**
+ * Print an AST node in something approximating the original GLSL code
+ */
virtual void print(void) const;
+
+ /**
+ * Convert the AST node to the high-level intermediate representation
+ */
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
@@ -91,19 +112,29 @@ public:
this->location.column = locp.first_column;
}
+ /**
+ * Source location of the AST node.
+ */
struct {
- unsigned source;
- unsigned line;
- unsigned column;
+ unsigned source; /**< GLSL source number. */
+ unsigned line; /**< Line number within the source string. */
+ unsigned column; /**< Column in the line. */
} location;
exec_node link;
protected:
+ /**
+ * The only constructor is protected so that only derived class objects can
+ * be created.
+ */
ast_node(void);
};
+/**
+ * Operators for AST expression nodes.
+ */
enum ast_operators {
ast_assign,
ast_plus, /**< Unary + operator. */
@@ -161,6 +192,9 @@ enum ast_operators {
ast_sequence
};
+/**
+ * Representation of any sort of expression.
+ */
class ast_expression : public ast_node {
public:
ast_expression(int oper, ast_expression *,
@@ -290,23 +324,42 @@ enum {
};
struct ast_type_qualifier {
- unsigned invariant:1;
- unsigned constant:1;
- unsigned attribute:1;
- unsigned varying:1;
- unsigned in:1;
- unsigned out:1;
- unsigned centroid:1;
- unsigned uniform:1;
- unsigned smooth:1;
- unsigned flat:1;
- unsigned noperspective:1;
-
- /** \name Layout qualifiers for GL_ARB_fragment_coord_conventions */
- /*@{*/
- unsigned origin_upper_left:1;
- unsigned pixel_center_integer:1;
- /*@}*/
+ union {
+ struct {
+ unsigned invariant:1;
+ unsigned constant:1;
+ unsigned attribute:1;
+ unsigned varying:1;
+ unsigned in:1;
+ unsigned out:1;
+ unsigned centroid:1;
+ unsigned uniform:1;
+ unsigned smooth:1;
+ unsigned flat:1;
+ unsigned noperspective:1;
+
+ /** \name Layout qualifiers for GL_ARB_fragment_coord_conventions */
+ /*@{*/
+ unsigned origin_upper_left:1;
+ unsigned pixel_center_integer:1;
+ /*@}*/
+
+ /**
+ * Flag set if GL_ARB_explicit_attrib_location "location" layout
+ * qualifier is used.
+ */
+ unsigned explicit_location:1;
+ } q;
+ unsigned i;
+ } flags;
+
+ /**
+ * Location specified via GL_ARB_explicit_attrib_location layout
+ *
+ * \note
+ * This field is only valid if \c explicit_location is set.
+ */
+ unsigned location;
};
class ast_struct_specifier : public ast_node {
@@ -651,7 +704,7 @@ public:
ast_function *prototype;
ast_compound_statement *body;
};
-
+/*@}*/
extern void
_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state);