lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [5/6] git commit: Only add files from required parcels to hierarchy
Date Tue, 18 Mar 2014 16:38:02 GMT
Only add files from required parcels to hierarchy


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/d587230f
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/d587230f
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/d587230f

Branch: refs/heads/single-parcel-per-file
Commit: d587230f8a49fca6478769de10807012214a3234
Parents: 5ec0912
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Tue Mar 18 17:09:57 2014 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Tue Mar 18 17:23:22 2014 +0100

----------------------------------------------------------------------
 compiler/src/CFCHierarchy.c   | 35 +++++++++++++++++++++--------------
 compiler/src/CFCPerl.c        |  3 +--
 compiler/src/CFCPerlTypeMap.c |  2 +-
 3 files changed, 23 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/d587230f/compiler/src/CFCHierarchy.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCHierarchy.c b/compiler/src/CFCHierarchy.c
index 116e172..c5fcac5 100644
--- a/compiler/src/CFCHierarchy.c
+++ b/compiler/src/CFCHierarchy.c
@@ -344,7 +344,7 @@ S_parse_cf_files(CFCHierarchy *self, const char *source_dir, int is_included)
{
         CFCFileSpec *file_spec = CFCFileSpec_new(source_dir, path_part,
                                                  is_included);
 
-        // Slurp, parse, add parsed file to pool.
+        // Slurp and parse file.
         size_t unused;
         char *content = CFCUtil_slurp_text(source_path, &unused);
         CFCFile *file = CFCParser_parse_file(self->parser, content, file_spec);
@@ -352,20 +352,13 @@ S_parse_cf_files(CFCHierarchy *self, const char *source_dir, int is_included)
{
         if (!file) {
             CFCUtil_die("parser error for %s", source_path);
         }
-        S_add_file(self, file);
-
-        CFCClass **classes_in_file = CFCFile_classes(file);
-        for (size_t j = 0; classes_in_file[j] != NULL; j++) {
-            if (self->num_classes == self->classes_cap) {
-                self->classes_cap += 10;
-                self->classes = (CFCClass**)REALLOCATE(
-                                  self->classes,
-                                  (self->classes_cap + 1) * sizeof(CFCClass*));
-            }
-            self->classes[self->num_classes++]
-                = (CFCClass*)CFCBase_incref((CFCBase*)classes_in_file[j]);
-            self->classes[self->num_classes] = NULL;
+
+        // Add parsed file to pool if it's from a required parcel.
+        CFCParcel *parcel = CFCFile_get_parcel(file);
+        if (CFCParcel_required(parcel)) {
+            S_add_file(self, file);
         }
+
         CFCBase_decref((CFCBase*)file);
         CFCBase_decref((CFCBase*)file_spec);
     }
@@ -530,6 +523,7 @@ static void
 S_add_file(CFCHierarchy *self, CFCFile *file) {
     CFCUTIL_NULL_CHECK(file);
     CFCClass **classes = CFCFile_classes(file);
+
     for (size_t i = 0; self->files[i] != NULL; i++) {
         CFCFile *existing = self->files[i];
         CFCClass **existing_classes = CFCFile_classes(existing);
@@ -545,12 +539,25 @@ S_add_file(CFCHierarchy *self, CFCFile *file) {
             }
         }
     }
+
     self->num_files++;
     size_t size = (self->num_files + 1) * sizeof(CFCFile*);
     self->files = (CFCFile**)REALLOCATE(self->files, size);
     self->files[self->num_files - 1]
         = (CFCFile*)CFCBase_incref((CFCBase*)file);
     self->files[self->num_files] = NULL;
+
+    for (size_t i = 0; classes[i] != NULL; i++) {
+        if (self->num_classes == self->classes_cap) {
+            self->classes_cap += 10;
+            self->classes = (CFCClass**)REALLOCATE(
+                              self->classes,
+                              (self->classes_cap + 1) * sizeof(CFCClass*));
+        }
+        self->classes[self->num_classes++]
+            = (CFCClass*)CFCBase_incref((CFCBase*)classes[i]);
+        self->classes[self->num_classes] = NULL;
+    }
 }
 
 struct CFCFile**

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/d587230f/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerl.c b/compiler/src/CFCPerl.c
index c907b57..9447c76 100644
--- a/compiler/src/CFCPerl.c
+++ b/compiler/src/CFCPerl.c
@@ -404,8 +404,7 @@ CFCPerl_write_bindings(CFCPerl *self) {
     // Pound-includes for generated headers.
     for (size_t i = 0; ordered[i] != NULL; i++) {
         CFCClass *klass = ordered[i];
-        // TODO: Don't include headers for parcels the source parcels don't
-        // depend on.
+        // It might be possible to skip indirect dependencies here.
         const char *include_h = CFCClass_include_h(klass);
         generated_xs = CFCUtil_cat(generated_xs, "#include \"", include_h,
                                    "\"\n", NULL);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/d587230f/compiler/src/CFCPerlTypeMap.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlTypeMap.c b/compiler/src/CFCPerlTypeMap.c
index 4553a13..ddba4a4 100644
--- a/compiler/src/CFCPerlTypeMap.c
+++ b/compiler/src/CFCPerlTypeMap.c
@@ -264,7 +264,7 @@ CFCPerlTypeMap_write_xs_typemap(CFCHierarchy *hierarchy) {
     char *output = CFCUtil_strdup("");
     for (int i = 0; classes[i] != NULL; i++) {
         CFCClass *klass = classes[i];
-        // TODO: Skip classes from parcels the source parcels don't depend on.
+        // It might be possible to skip indirect dependencies here.
 
         const char *full_struct_sym = CFCClass_full_struct_sym(klass);
         const char *vtable_var      = CFCClass_full_vtable_var(klass);


Mime
View raw message