Differentiate in ast_function_expression between constructors and func. calls
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 10 Mar 2010 22:12:22 +0000 (14:12 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 10 Mar 2010 22:12:22 +0000 (14:12 -0800)
ast.h
glsl_parser.ypp

diff --git a/ast.h b/ast.h
index ad614e98fe617b4ae699a0c111aa37dea642b18d..d82325747c288fb157f4c461de3a3b8b74561de7 100644 (file)
--- a/ast.h
+++ b/ast.h
@@ -198,16 +198,35 @@ public:
  */
 class ast_function_expression : public ast_expression {
 public:
-   ast_function_expression(ast_node *callee)
-      : ast_expression(ast_function_call, (ast_expression *) callee,
-                      NULL, NULL)
+   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_instruction *hir(exec_list *instructions,
                               struct _mesa_glsl_parse_state *state);
+
+private:
+   /**
+    * Is this function call actually a constructor?
+    */
+   bool cons;
 };
 
 
index 2f337b127c53e58c78acb1e69ef01a0c04a82fe4..058a03231dace870ed07d984a7133dfb25b73a9c 100644 (file)
@@ -337,23 +337,22 @@ function_call_header_with_parameters:
        // recognized through "type_specifier".
 function_call_header:
        function_identifier '('
-       {
-          $$ = new ast_function_expression($1);
-       }
        ;
 
 function_identifier:
        type_specifier
        {
-          $$ = (struct ast_node *) $1;
+          $$ = new ast_function_expression($1);
        }
        | IDENTIFIER
        {
-          $$ = new ast_expression($1);
+          ast_expression *callee = new ast_expression($1);
+          $$ = new ast_function_expression(callee);
        }
        | FIELD_SELECTION
        {
-          $$ = new ast_expression($1);
+          ast_expression *callee = new ast_expression($1);
+          $$ = new ast_function_expression(callee);
        }
        ;