Commit edd75d03e3

Andrew Kelley <andrew@ziglang.org>
2021-04-17 00:52:26
ZIR: rename decl_val and decl_ref to remove redundant suffix
1 parent adc2aed
Changed files (3)
src/AstGen.zig
@@ -1276,8 +1276,8 @@ fn blockExprStmts(
                         .cmp_gt,
                         .cmp_neq,
                         .coerce_result_ptr,
-                        .decl_ref_named,
-                        .decl_val_named,
+                        .decl_ref,
+                        .decl_val,
                         .load,
                         .div,
                         .elem_ptr,
@@ -4260,9 +4260,9 @@ fn identifier(
     // depending on the scope, determined by the generic instantiation.
     const str_index = try gz.identAsString(ident_token);
     switch (rl) {
-        .ref, .none_or_ref => return gz.addStrTok(.decl_ref_named, str_index, ident_token),
+        .ref, .none_or_ref => return gz.addStrTok(.decl_ref, str_index, ident_token),
         else => {
-            const result = try gz.addStrTok(.decl_val_named, str_index, ident_token);
+            const result = try gz.addStrTok(.decl_val, str_index, ident_token);
             return rvalue(gz, scope, rl, result, ident);
         },
     }
src/Sema.zig
@@ -170,8 +170,8 @@ pub fn analyzeBody(
             .cmp_lte => try sema.zirCmp(block, inst, .lte),
             .cmp_neq => try sema.zirCmp(block, inst, .neq),
             .coerce_result_ptr => try sema.zirCoerceResultPtr(block, inst),
-            .decl_ref_named => try sema.zirDeclRefNamed(block, inst),
-            .decl_val_named => try sema.zirDeclValNamed(block, inst),
+            .decl_ref => try sema.zirDeclRef(block, inst),
+            .decl_val => try sema.zirDeclVal(block, inst),
             .load => try sema.zirLoad(block, inst),
             .div => try sema.zirArithmetic(block, inst),
             .elem_ptr => try sema.zirElemPtr(block, inst),
@@ -1658,7 +1658,7 @@ fn zirDbgStmtNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE
     _ = try block.addDbgStmt(src, abs_byte_off);
 }
 
-fn zirDeclRefNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
+fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
     const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
     const src = inst_data.src();
     const decl_name = inst_data.get(sema.code);
@@ -1666,7 +1666,7 @@ fn zirDeclRefNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner
     return sema.analyzeDeclRef(block, src, decl);
 }
 
-fn zirDeclValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
+fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst {
     const inst_data = sema.code.instructions.items(.data)[inst].str_tok;
     const src = inst_data.src();
     const decl_name = inst_data.get(sema.code);
src/Zir.zig
@@ -296,12 +296,12 @@ pub const Inst = struct {
         /// Declares the beginning of a statement. Used for debug info.
         /// Uses the `node` union field.
         dbg_stmt_node,
-        /// Same as `decl_ref` except instead of indexing into decls, uses
-        /// a name to identify the Decl. Uses the `str_tok` union field.
-        decl_ref_named,
-        /// Same as `decl_val` except instead of indexing into decls, uses
-        /// a name to identify the Decl. Uses the `str_tok` union field.
-        decl_val_named,
+        /// Uses a name to identify a Decl and takes a pointer to it.
+        /// Uses the `str_tok` union field.
+        decl_ref,
+        /// Uses a name to identify a Decl and uses it as a value.
+        /// Uses the `str_tok` union field.
+        decl_val,
         /// Load the value from a pointer. Assumes `x.*` syntax.
         /// Uses `un_node` field. AST node is the `x.*` syntax.
         load,
@@ -765,8 +765,8 @@ pub const Inst = struct {
                 .enum_decl_nonexhaustive,
                 .opaque_decl,
                 .dbg_stmt_node,
-                .decl_ref_named,
-                .decl_val_named,
+                .decl_ref,
+                .decl_val,
                 .load,
                 .div,
                 .elem_ptr,
@@ -1868,8 +1868,8 @@ const Writer = struct {
 
             .error_value,
             .enum_literal,
-            .decl_ref_named,
-            .decl_val_named,
+            .decl_ref,
+            .decl_val,
             .import,
             => try self.writeStrTok(stream, inst),