#ifndef AST_H
#define AST_H
-#include "main/simple_list.h"
#include "list.h"
#include "glsl_parser_extras.h"
struct YYLTYPE;
-class ast_node : public simple_node {
+class ast_node {
public:
virtual ~ast_node();
virtual void print(void) const;
*
* \sa ast_node::get_location
*/
- void set_location(const struct YYLTYPE *locp)
+ void set_location(const struct YYLTYPE &locp)
{
- this->location.source = locp->source;
- this->location.line = locp->first_line;
- this->location.column = locp->first_column;
+ this->location.source = locp.source;
+ this->location.line = locp.first_line;
+ this->location.column = locp.first_column;
}
-
- int type;
-
struct {
unsigned source;
unsigned line;
unsigned column;
} location;
+ exec_node link;
+
protected:
ast_node(void);
};
/**
- * List of expressions for an \c ast_sequence.
+ * List of expressions for an \c ast_sequence or parameters for an
+ * \c ast_function_call
*/
- struct simple_node expressions;
+ exec_list expressions;
};
class ast_expression_bin : public ast_expression {
struct _mesa_glsl_parse_state *state);
int new_scope;
- struct simple_node statements;
+ exec_list statements;
};
class ast_declaration : public ast_node {
ast_struct_specifier(char *identifier, ast_node *declarator_list);
virtual void print(void) const;
+ virtual ir_rvalue *hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state);
+
char *name;
- struct simple_node declarations;
+ exec_list declarations;
};
/* empty */
}
+ const struct glsl_type *glsl_type(const char **name,
+ struct _mesa_glsl_parse_state *state)
+ const;
+
virtual void print(void) const;
+ ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *);
+
enum ast_types type_specifier;
const char *type_name;
struct _mesa_glsl_parse_state *state);
ast_fully_specified_type *type;
- struct simple_node declarations;
+ exec_list declarations;
/**
* Special flag for vertex shader "invariant" declarations.
char *identifier;
int is_array;
ast_expression *array_size;
+
+ static void parameters_to_hir(exec_list *ast_parameters,
+ bool formal, exec_list *ir_parameters,
+ struct _mesa_glsl_parse_state *state);
+
+private:
+ /** Is this parameter declaration part of a formal parameter list? */
+ bool formal_parameter;
+
+ /**
+ * Is this parameter 'void' type?
+ *
+ * This field is set by \c ::hir.
+ */
+ bool is_void;
};
virtual void print(void) const;
+ virtual ir_rvalue *hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state);
+
ast_fully_specified_type *return_type;
char *identifier;
- struct simple_node parameters;
+ exec_list parameters;
+
+private:
+ /**
+ * Is this prototype part of the function definition?
+ *
+ * Used by ast_function_definition::hir to process the parameters, etc.
+ * of the function.
+ *
+ * \sa ::hir
+ */
+ bool is_definition;
+
+ /**
+ * Function signature corresponding to this function prototype instance
+ *
+ * Used by ast_function_definition::hir to process the parameters, etc.
+ * of the function.
+ *
+ * \sa ::hir
+ */
+ class ir_function_signature *signature;
+
+ friend class ast_function_definition;
};
class ast_switch_statement : public ast_node {
public:
ast_expression *expression;
- struct simple_node statements;
+ exec_list statements;
};
class ast_iteration_statement : public ast_node {
virtual void print(void) const;
+ virtual ir_rvalue *hir(exec_list *, struct _mesa_glsl_parse_state *);
+
enum ast_iteration_modes {
ast_for,
ast_while,
ast_expression *rest_expression;
ast_node *body;
+
+private:
+ /**
+ * Generate IR from the condition of a loop
+ *
+ * This is factored out of ::hir because some loops have the condition
+ * test at the top (for and while), and others have it at the end (do-while).
+ */
+ void condition_to_hir(class ir_loop *, struct _mesa_glsl_parse_state *);
};