Add definitions for 1.10 built-in uniforms for ff state.
[mesa.git] / ast.h
diff --git a/ast.h b/ast.h
index 59bc4fb0b5e71ad653c85cc0d533ee76b52a4c31..a158910421d427ae1db1ed2ce86cb0f48d46694c 100644 (file)
--- a/ast.h
+++ b/ast.h
@@ -1,3 +1,4 @@
+/* -*- c++ -*- */
 /*
  * Copyright © 2009 Intel Corporation
  *
@@ -26,6 +27,7 @@
 #define AST_H
 
 #include "main/simple_list.h"
+#include "list.h"
 #include "glsl_parser_extras.h"
 
 struct ir_instruction;
@@ -37,8 +39,8 @@ class ast_node : public simple_node {
 public:
    virtual ~ast_node();
    virtual void print(void) const;
-   virtual ir_instruction *hir(struct simple_node *instructions,
-                              struct _mesa_glsl_parse_state *state);
+   virtual ir_rvalue *hir(exec_list *instructions,
+                         struct _mesa_glsl_parse_state *state);
 
    /**
     * Retrieve the source location of an AST node
@@ -149,10 +151,19 @@ public:
    ast_expression(int oper, ast_expression *,
                  ast_expression *, ast_expression *);
 
+   ast_expression(const char *identifier) :
+      oper(ast_identifier)
+   {
+      subexpressions[0] = NULL;
+      subexpressions[1] = NULL;
+      subexpressions[2] = NULL;
+      primary_expression.identifier = (char *) identifier;
+   }
+
    static const char *operator_string(enum ast_operators op);
 
-   virtual ir_instruction *hir(struct simple_node *instructions,
-                              struct _mesa_glsl_parse_state *state);
+   virtual ir_rvalue *hir(exec_list *instructions,
+                         struct _mesa_glsl_parse_state *state);
 
    virtual void print(void) const;
 
@@ -182,6 +193,42 @@ public:
    virtual void print(void) const;
 };
 
+/**
+ * Subclass of expressions for function calls
+ */
+class ast_function_expression : public ast_expression {
+public:
+   ast_function_expression(ast_expression *callee)
+      : ast_expression(ast_function_call, callee,
+                      NULL, NULL),
+       cons(false)
+   {
+      /* empty */
+   }
+
+   ast_function_expression(class ast_type_specifier *type)
+      : ast_expression(ast_function_call, (ast_expression *) type,
+                      NULL, NULL),
+       cons(true)
+   {
+      /* empty */
+   }
+
+   bool is_constructor() const
+   {
+      return cons;
+   }
+
+   virtual ir_rvalue *hir(exec_list *instructions,
+                         struct _mesa_glsl_parse_state *state);
+
+private:
+   /**
+    * Is this function call actually a constructor?
+    */
+   bool cons;
+};
+
 
 /**
  * Number of possible operators for an ast_expression
@@ -198,8 +245,8 @@ public:
    ast_compound_statement(int new_scope, ast_node *statements);
    virtual void print(void) const;
 
-   virtual ir_instruction *hir(struct simple_node *instructions,
-                              struct _mesa_glsl_parse_state *state);
+   virtual ir_rvalue *hir(exec_list *instructions,
+                         struct _mesa_glsl_parse_state *state);
 
    int new_scope;
    struct simple_node statements;
@@ -310,11 +357,27 @@ class ast_type_specifier : public ast_node {
 public:
    ast_type_specifier(int specifier);
 
+   /** Construct a type specifier from a type name */
+   ast_type_specifier(const char *name) 
+      : type_specifier(ast_type_name), type_name(name), structure(NULL),
+       is_array(false), array_size(NULL), precision(ast_precision_high)
+   {
+      /* empty */
+   }
+
+   /** Construct a type specifier from a structure definition */
+   ast_type_specifier(ast_struct_specifier *s)
+      : type_specifier(ast_struct), type_name(s->name), structure(s),
+       is_array(false), array_size(NULL), precision(ast_precision_high)
+   {
+      /* empty */
+   }
+
    virtual void print(void) const;
 
    enum ast_types type_specifier;
 
-   char *type_name;
+   const char *type_name;
    ast_struct_specifier *structure;
 
    int is_array;
@@ -338,8 +401,8 @@ public:
    ast_declarator_list(ast_fully_specified_type *);
    virtual void print(void) const;
 
-   virtual ir_instruction *hir(struct simple_node *instructions,
-                              struct _mesa_glsl_parse_state *state);
+   virtual ir_rvalue *hir(exec_list *instructions,
+                         struct _mesa_glsl_parse_state *state);
 
    ast_fully_specified_type *type;
    struct simple_node declarations;
@@ -359,8 +422,8 @@ class ast_parameter_declarator : public ast_node {
 public:
    virtual void print(void) const;
 
-   virtual ir_instruction *hir(struct simple_node *instructions,
-                              struct _mesa_glsl_parse_state *state);
+   virtual ir_rvalue *hir(exec_list *instructions,
+                         struct _mesa_glsl_parse_state *state);
 
    ast_fully_specified_type *type;
    char *identifier;
@@ -406,8 +469,8 @@ public:
    ast_expression_statement(ast_expression *);
    virtual void print(void) const;
 
-   virtual ir_instruction *hir(struct simple_node *instructions,
-                              struct _mesa_glsl_parse_state *state);
+   virtual ir_rvalue *hir(exec_list *instructions,
+                         struct _mesa_glsl_parse_state *state);
 
    ast_expression *expression;
 };
@@ -468,6 +531,9 @@ public:
    ast_jump_statement(int mode, ast_expression *return_value);
    virtual void print(void) const;
 
+   virtual ir_rvalue *hir(exec_list *instructions,
+                         struct _mesa_glsl_parse_state *state);
+
    enum ast_jump_modes {
       ast_continue,
       ast_break,
@@ -483,47 +549,20 @@ class ast_function_definition : public ast_node {
 public:
    virtual void print(void) const;
 
-   virtual ir_instruction *hir(struct simple_node *instructions,
-                              struct _mesa_glsl_parse_state *state);
+   virtual ir_rvalue *hir(exec_list *instructions,
+                         struct _mesa_glsl_parse_state *state);
 
    ast_function *prototype;
    ast_compound_statement *body;
 };
 
 
-extern struct ir_instruction *
-ast_expression_to_hir(const ast_node *ast,
-                     struct simple_node *instructions,
-                     struct _mesa_glsl_parse_state *state);
-
-extern struct ir_instruction *
-ast_expression_statement_to_hir(const struct ast_node *ast,
-                               struct simple_node *instructions,
-                               struct _mesa_glsl_parse_state *state);
-
-extern struct ir_instruction *
-ast_compound_statement_to_hir(const struct ast_node *ast,
-                             struct simple_node *instructions,
-                             struct _mesa_glsl_parse_state *state);
-
-extern struct ir_instruction *
-ast_function_definition_to_hir(const struct ast_node *ast,
-                              struct simple_node *instructions,
-                              struct _mesa_glsl_parse_state *state);
-
-extern struct ir_instruction *
-ast_declarator_list_to_hir(const struct ast_node *ast,
-                          struct simple_node *instructions,
-                          struct _mesa_glsl_parse_state *state);
-
-extern struct ir_instruction *
-ast_parameter_declarator_to_hir(const struct ast_node *ast,
-                               struct simple_node *instructions,
-                               struct _mesa_glsl_parse_state *state);
+extern void
+_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state);
 
-extern struct ir_instruction *
+extern struct ir_rvalue *
 _mesa_ast_field_selection_to_hir(const struct ast_expression *expr,
-                                struct simple_node *instructions,
+                                exec_list *instructions,
                                 struct _mesa_glsl_parse_state *state);
 
 #endif /* AST_H */