diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-01-09 00:37:48 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-01-09 00:37:48 -0700 |
| commit | bdca82ea66259de136ce9374e172f567ee93ef89 (patch) | |
| tree | 090b73d70f8270f5f803b771d99b8cfbfbf592da /src/analyze.cpp | |
| parent | 0c24ed8a818dddc1c77a41c07815b036a94279ca (diff) | |
| download | zig-bdca82ea66259de136ce9374e172f567ee93ef89.tar.gz zig-bdca82ea66259de136ce9374e172f567ee93ef89.zip | |
implement pub const
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 141492689a..29729070af 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -2635,6 +2635,29 @@ static void analyze_top_level_declaration(CodeGen *g, ImportTableEntry *import, } } } + + // import all the public variables + { + auto it = target_import->block_context->variable_table.entry_iterator(); + for (;;) { + auto *entry = it.next(); + if (!entry) + break; + + VariableTableEntry *var = entry->value; + bool is_pub = (var->decl_node->data.variable_declaration.visib_mod != VisibModPrivate); + if (is_pub) { + auto existing_entry = import->type_table.maybe_get(entry->key); + if (existing_entry) { + add_node_error(g, node, + buf_sprintf("import of variable '%s' overrides existing definition", + buf_ptr(&var->name))); + } else { + import->block_context->variable_table.put(entry->key, entry->value); + } + } + } + } break; } case NodeTypeStructDecl: |
