From f1d338194e9a00e56a42da1298f2ac0ed75797df Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 27 Feb 2016 22:06:46 -0700 Subject: rewrite how importing works * Introduce the concept of packages. Closes #3 * Add support for error notes. * Introduce `@import` and `@c_import` builtin functions and remove the `import` and `c_import` top level declarations. * Introduce the `use` top level declaration. * Add `--check-unused` parameter to perform semantic analysis and codegen on all top level declarations, not just exported ones and ones referenced by exported ones. * Delete the root export node and add `--library` argument. --- src/parseh.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/parseh.cpp') diff --git a/src/parseh.cpp b/src/parseh.cpp index 3513092e70..929a22c8b1 100644 --- a/src/parseh.cpp +++ b/src/parseh.cpp @@ -121,9 +121,9 @@ static AstNode *create_typed_var_decl_node(Context *c, bool is_const, const char AstNode *node = create_node(c, NodeTypeVariableDeclaration); buf_init_from_str(&node->data.variable_declaration.symbol, var_name); node->data.variable_declaration.is_const = is_const; - node->data.variable_declaration.visib_mod = c->visib_mod; + node->data.variable_declaration.top_level_decl.visib_mod = c->visib_mod; node->data.variable_declaration.expr = init_node; - node->data.variable_declaration.directives = nullptr; + node->data.variable_declaration.top_level_decl.directives = nullptr; node->data.variable_declaration.type = type_node; normalize_parent_ptrs(node); return node; @@ -146,7 +146,7 @@ static AstNode *create_struct_field_node(Context *c, const char *name, AstNode * assert(type_node); AstNode *node = create_node(c, NodeTypeStructField); buf_init_from_str(&node->data.struct_field.name, name); - node->data.struct_field.visib_mod = VisibModPub; + node->data.struct_field.top_level_decl.visib_mod = VisibModPub; node->data.struct_field.type = type_node; normalize_parent_ptrs(node); @@ -202,7 +202,7 @@ static AstNode *create_num_lit_signed(Context *c, int64_t x) { static AstNode *create_type_decl_node(Context *c, const char *name, AstNode *child_type_node) { AstNode *node = create_node(c, NodeTypeTypeDecl); buf_init_from_str(&node->data.type_decl.symbol, name); - node->data.type_decl.visib_mod = c->visib_mod; + node->data.type_decl.top_level_decl.visib_mod = c->visib_mod; node->data.type_decl.child_type = child_type_node; normalize_parent_ptrs(node); @@ -219,7 +219,7 @@ static AstNode *create_fn_proto_node(Context *c, Buf *name, TypeTableEntry *fn_t assert(fn_type->id == TypeTableEntryIdFn); AstNode *node = create_node(c, NodeTypeFnProto); node->data.fn_proto.is_inline = true; - node->data.fn_proto.visib_mod = c->visib_mod; + node->data.fn_proto.top_level_decl.visib_mod = c->visib_mod; buf_init_from_buf(&node->data.fn_proto.name, name); node->data.fn_proto.return_type = make_type_node(c, fn_type->data.fn.fn_type_id.return_type); @@ -677,7 +677,7 @@ static void visit_fn_decl(Context *c, const FunctionDecl *fn_decl) { buf_init_from_buf(&node->data.fn_proto.name, &fn_name); node->data.fn_proto.is_extern = fn_type->data.fn.fn_type_id.is_extern; - node->data.fn_proto.visib_mod = c->visib_mod; + node->data.fn_proto.top_level_decl.visib_mod = c->visib_mod; node->data.fn_proto.is_var_args = fn_type->data.fn.fn_type_id.is_var_args; node->data.fn_proto.return_type = make_type_node(c, fn_type->data.fn.fn_type_id.return_type); @@ -861,7 +861,7 @@ static void visit_enum_decl(Context *c, const EnumDecl *enum_decl) { AstNode *enum_node = create_node(c, NodeTypeStructDecl); buf_init_from_buf(&enum_node->data.struct_decl.name, full_type_name); enum_node->data.struct_decl.kind = ContainerKindEnum; - enum_node->data.struct_decl.visib_mod = VisibModExport; + enum_node->data.struct_decl.top_level_decl.visib_mod = VisibModExport; enum_node->data.struct_decl.type_entry = enum_type; for (uint32_t i = 0; i < field_count; i += 1) { @@ -1043,7 +1043,7 @@ static void visit_record_decl(Context *c, const RecordDecl *record_decl) { AstNode *struct_node = create_node(c, NodeTypeStructDecl); buf_init_from_buf(&struct_node->data.struct_decl.name, &struct_type->name); struct_node->data.struct_decl.kind = ContainerKindStruct; - struct_node->data.struct_decl.visib_mod = VisibModExport; + struct_node->data.struct_decl.top_level_decl.visib_mod = VisibModExport; struct_node->data.struct_decl.type_entry = struct_type; for (uint32_t i = 0; i < struct_type->data.structure.src_field_count; i += 1) { -- cgit v1.2.3