add tests for base fields remove klass local variable, add support for
authorRaffaele Sandrini <rasa@gmx.ch>
Tue, 2 May 2006 12:47:10 +0000 (12:47 +0000)
committerRaffaele Sandrini <rasa@src.gnome.org>
Tue, 2 May 2006 12:47:10 +0000 (12:47 +0000)
2006-05-02  Raffaele Sandrini  <rasa@gmx.ch>

        * tests/test-008.vala: add tests for base fields
        * valac/generator.c: remove klass local variable, add support for
          base fields.

svn path=/trunk/; revision=11

vala/ChangeLog
vala/tests/test-008.vala
vala/valac/generator.c

index 4eddb06..f994be4 100644 (file)
@@ -1,3 +1,9 @@
+2006-05-02  Raffaele Sandrini  <rasa@gmx.ch>
+
+       * tests/test-008.vala: add tests for base fields
+       * valac/generator.c: remove klass local variable, add support for
+         base fields.
+
 2006-05-01  Jürg Billeter  <j@bitron.ch>
 
        * valac/scanner.l: support ENUM, FLAGS, STRUCT
index 1ca9f00..58cd9b0 100644 (file)
@@ -1,5 +1,9 @@
 namespace Maman {
-       class Bar {
+       class Foo {
+               public int foo_a = 5;
+               public static int foo_b = 6;
+       }
+       class Bar : Foo {
                public int a = 1;
                private int b = 2;
                public static int c = 3;
@@ -11,7 +15,7 @@ namespace Maman {
                public void test () {
                        int aa = 6;
                        a = 3 + b;
-                       c = a + 5 + aa;
+                       c = a + 5 + aa + foo_a + foo_b;
                }
        }
 }
index e0a2203..47d7da9 100644 (file)
@@ -527,15 +527,18 @@ vala_code_generator_process_simple_name (ValaCodeGenerator *generator, ValaExpre
                break;
        case VALA_SYMBOL_TYPE_FIELD: {
                ValaField *field = expr->static_type_symbol->field;
+               ValaClass *class = field->class;
+               char *ns_upper = class->namespace->upper_case_cname;
+               char *class_upper = class->upper_case_cname;
                
                if ((field->modifiers & (VALA_FIELD_STATIC | VALA_FIELD_PRIVATE)) == (VALA_FIELD_STATIC | VALA_FIELD_PRIVATE)) {
                        fprintf (generator->c_file, "%s", expr->str);
                } else if ((field->modifiers & VALA_FIELD_STATIC) != 0) {
-                       fprintf (generator->c_file, "klass->%s", expr->str);
+                       fprintf (generator->c_file, "%s%s_GET_CLASS(self)->%s", ns_upper, class_upper, expr->str);
                } else if ((field->modifiers & VALA_FIELD_PRIVATE) != 0) {
                        fprintf (generator->c_file, "self->priv->%s", expr->str);
                } else if ((field->modifiers & VALA_FIELD_PUBLIC) != 0) {
-                       fprintf (generator->c_file, "self->%s", expr->str);
+                       fprintf (generator->c_file, "%s%s(self)->%s", ns_upper, class_upper, expr->str);
                }
                break;
        }
@@ -861,18 +864,8 @@ vala_code_generator_process_methods2 (ValaCodeGenerator *generator, ValaClass *c
                                g_hash_table_insert (generator->sym->symbol_table, param->name, sym);
                                sym->typeref = param->type;
                        }
-                       
-                       if ((method->modifiers & VALA_METHOD_STATIC) == 0) {
-                               /* make klass avalible, uuuuhhhh dirty */
-                               fprintf (generator->c_file, "{\n");
-                               fprintf (generator->c_file, "\t%sClass *klass = %s%s_GET_CLASS (self);\n", g_strdup_printf ("%s%s", namespace->name, class->name), class->namespace->upper_case_cname, class->upper_case_cname);
-                       }
 
                        vala_code_generator_process_block (generator, method->body);
-                       
-                       if ((method->modifiers & VALA_METHOD_STATIC) == 0) {
-                               fprintf (generator->c_file, "}\n");
-                       }
                }
                
                fprintf (generator->c_file, "\n");