Browse Source

cppparser: fix scope bug in constructor inits
This also fixes the Android build.

rdb 8 years ago
parent
commit
d6657baf29
2 changed files with 682 additions and 708 deletions
  1. 671 706
      dtool/src/cppparser/cppBison.cxx.prebuilt
  2. 11 2
      dtool/src/cppparser/cppBison.yxx

File diff suppressed because it is too large
+ 671 - 706
dtool/src/cppparser/cppBison.cxx.prebuilt


+ 11 - 2
dtool/src/cppparser/cppBison.yxx

@@ -928,12 +928,21 @@ type_like_declaration:
 
 
   current_scope->add_declaration($2, global_scope, current_lexer, @2);
   current_scope->add_declaration($2, global_scope, current_lexer, @2);
 }
 }
-        | storage_class constructor_prototype maybe_initialize_or_constructor_body
+        | storage_class constructor_prototype
 {
 {
   if ($2 != (CPPInstance *)NULL) {
   if ($2 != (CPPInstance *)NULL) {
+    // Push the scope so that the initializers can make use of things defined
+    // in the class body.
+    push_scope($2->get_scope(current_scope, global_scope));
     $2->_storage_class |= (current_storage_class | $1);
     $2->_storage_class |= (current_storage_class | $1);
+  }
+}
+        maybe_initialize_or_constructor_body
+{
+  if ($2 != (CPPInstance *)NULL) {
+    pop_scope();
     current_scope->add_declaration($2, global_scope, current_lexer, @2);
     current_scope->add_declaration($2, global_scope, current_lexer, @2);
-    $2->set_initializer($3);
+    $2->set_initializer($4);
   }
   }
 }
 }
         | storage_class function_prototype maybe_initialize_or_function_body
         | storage_class function_prototype maybe_initialize_or_function_body

Some files were not shown because too many files changed in this diff