Remove classes array from CFCHierarchy Replaced by class array in CFCParcel.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/8fbf9c96 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/8fbf9c96 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/8fbf9c96 Branch: refs/heads/master Commit: 8fbf9c960b0bcfccedf15a83e6bb7ae1191e2e24 Parents: 859f5b8 Author: Nick Wellnhofer <wellnho...@aevum.de> Authored: Tue Feb 28 15:18:21 2017 +0100 Committer: Nick Wellnhofer <wellnho...@aevum.de> Committed: Thu Mar 2 20:08:05 2017 +0100 ---------------------------------------------------------------------- compiler/src/CFCHierarchy.c | 43 ---------------------------------------- compiler/src/CFCParcel.c | 3 +++ 2 files changed, 3 insertions(+), 43 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8fbf9c96/compiler/src/CFCHierarchy.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCHierarchy.c b/compiler/src/CFCHierarchy.c index 0b5100c..6393133 100644 --- a/compiler/src/CFCHierarchy.c +++ b/compiler/src/CFCHierarchy.c @@ -56,9 +56,6 @@ struct CFCHierarchy { size_t num_trees; CFCFile **files; size_t num_files; - CFCClass **classes; - size_t classes_cap; - size_t num_classes; }; typedef struct CFCFindFilesContext { @@ -133,10 +130,6 @@ CFCHierarchy_init(CFCHierarchy *self, const char *dest) { self->num_trees = 0; self->files = (CFCFile**)CALLOCATE(1, sizeof(CFCFile*)); self->num_files = 0; - self->classes_cap = 10; - self->classes = (CFCClass**)CALLOCATE( - (self->classes_cap + 1), sizeof(CFCClass*)); - self->num_classes = 0; self->parser = CFCParser_new(); self->inc_dest = CFCUtil_sprintf("%s" CHY_DIR_SEP "include", self->dest); @@ -153,15 +146,11 @@ CFCHierarchy_destroy(CFCHierarchy *self) { for (size_t i = 0; self->files[i] != NULL; i++) { CFCBase_decref((CFCBase*)self->files[i]); } - for (size_t i = 0; self->classes[i] != NULL; i++) { - CFCBase_decref((CFCBase*)self->classes[i]); - } CFCUtil_free_string_array(self->sources); CFCUtil_free_string_array(self->includes); CFCUtil_free_string_array(self->prereqs); FREEMEM(self->trees); FREEMEM(self->files); - FREEMEM(self->classes); FREEMEM(self->dest); FREEMEM(self->inc_dest); FREEMEM(self->src_dest); @@ -233,10 +222,6 @@ CFCHierarchy_build(CFCHierarchy *self) { S_find_doc_files(self->sources[i]); } - for (int i = 0; self->classes[i] != NULL; i++) { - CFCClass_resolve_types(self->classes[i]); - } - // It's important that prereq parcels are processed first. for (size_t i = 0; parcels[i] != NULL; i++) { CFCParcel_connect_and_sort_classes(parcels[i]); @@ -454,7 +439,6 @@ S_parse_cf_files(CFCHierarchy *self, const char *source_dir, int is_included) { CFCBase_decref((CFCBase*)file_spec); FREEMEM(path_part); } - self->classes[self->num_classes] = NULL; CFCUtil_free_string_array(context.paths); } @@ -639,22 +623,6 @@ 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); - for (size_t j = 0; classes[j] != NULL; j++) { - const char *new_class_name = CFCClass_get_name(classes[j]); - for (size_t k = 0; existing_classes[k] != NULL; k++) { - const char *existing_class_name - = CFCClass_get_name(existing_classes[k]); - if (strcmp(new_class_name, existing_class_name) == 0) { - CFCUtil_die("Class '%s' already registered", - new_class_name); - } - } - } - } - self->num_files++; size_t size = (self->num_files + 1) * sizeof(CFCFile*); self->files = (CFCFile**)REALLOCATE(self->files, size); @@ -664,17 +632,6 @@ S_add_file(CFCHierarchy *self, CFCFile *file) { for (size_t i = 0; classes[i] != NULL; i++) { CFCClass *klass = classes[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*)klass); - self->classes[self->num_classes] = NULL; - const char *parent_name = CFCClass_get_parent_class_name(klass); if (!parent_name) { S_add_tree(self, klass); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8fbf9c96/compiler/src/CFCParcel.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCParcel.c b/compiler/src/CFCParcel.c index 0a24478..9a2655f 100644 --- a/compiler/src/CFCParcel.c +++ b/compiler/src/CFCParcel.c @@ -635,6 +635,9 @@ CFCParcel_connect_and_sort_classes(CFCParcel *self) { // Subtree root. sorted[--todo] = klass; } + + // Resolve types. + CFCClass_resolve_types(klass); } qsort(&sorted[todo], num_classes - todo, sizeof(sorted[0]),