Commit 6a5e61acd1

Andrew Kelley <superjoe30@gmail.com>
2017-01-16 23:24:13
get rid of zeroes literal
closes #222
1 parent ab8b14a
doc/langref.md
@@ -149,7 +149,7 @@ GotoExpression = option("inline") "goto" Symbol
 
 GroupedExpression = "(" Expression ")"
 
-KeywordLiteral = "true" | "false" | "null" | "break" | "continue" | "undefined" | "zeroes" | "error" | "type" | "this"
+KeywordLiteral = "true" | "false" | "null" | "break" | "continue" | "undefined" | "error" | "type" | "this"
 
 ContainerDecl = option("extern") ("struct" | "enum" | "union") "{" many(StructMember) "}"
 
src/all_types.hpp
@@ -126,7 +126,6 @@ enum ConstValSpecial {
     ConstValSpecialRuntime,
     ConstValSpecialStatic,
     ConstValSpecialUndef,
-    ConstValSpecialZeroes,
 };
 
 enum RuntimeHintErrorUnion {
@@ -271,7 +270,6 @@ enum NodeType {
     NodeTypeBoolLiteral,
     NodeTypeNullLiteral,
     NodeTypeUndefinedLiteral,
-    NodeTypeZeroesLiteral,
     NodeTypeThisLiteral,
     NodeTypeIfBoolExpr,
     NodeTypeIfVarExpr,
@@ -655,9 +653,6 @@ struct AstNodeNullLiteral {
 struct AstNodeUndefinedLiteral {
 };
 
-struct AstNodeZeroesLiteral {
-};
-
 struct AstNodeThisLiteral {
 };
 
@@ -737,7 +732,6 @@ struct AstNode {
         AstNodeStructValueField struct_val_field;
         AstNodeNullLiteral null_literal;
         AstNodeUndefinedLiteral undefined_literal;
-        AstNodeZeroesLiteral zeroes_literal;
         AstNodeThisLiteral this_literal;
         AstNodeSymbolExpr symbol_expr;
         AstNodeBoolLiteral bool_literal;
src/analyze.cpp
@@ -60,7 +60,6 @@ AstNode *first_executing_node(AstNode *node) {
         case NodeTypeBoolLiteral:
         case NodeTypeNullLiteral:
         case NodeTypeUndefinedLiteral:
-        case NodeTypeZeroesLiteral:
         case NodeTypeThisLiteral:
         case NodeTypeIfBoolExpr:
         case NodeTypeIfVarExpr:
@@ -1793,7 +1792,6 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {
         case NodeTypeBoolLiteral:
         case NodeTypeNullLiteral:
         case NodeTypeUndefinedLiteral:
-        case NodeTypeZeroesLiteral:
         case NodeTypeThisLiteral:
         case NodeTypeSymbol:
         case NodeTypePrefixOpExpr:
@@ -3403,9 +3401,6 @@ void render_const_value(Buf *buf, ConstExprValue *const_val) {
         case ConstValSpecialUndef:
             buf_appendf(buf, "undefined");
             return;
-        case ConstValSpecialZeroes:
-            buf_appendf(buf, "zeroes");
-            return;
         case ConstValSpecialStatic:
             break;
     }
src/ast_render.cpp
@@ -177,8 +177,6 @@ static const char *node_type_str(NodeType node_type) {
             return "NullLiteral";
         case NodeTypeUndefinedLiteral:
             return "UndefinedLiteral";
-        case NodeTypeZeroesLiteral:
-            return "ZeroesLiteral";
         case NodeTypeThisLiteral:
             return "ThisLiteral";
         case NodeTypeIfBoolExpr:
@@ -877,7 +875,6 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
         case NodeTypeErrorValueDecl:
         case NodeTypeStructField:
         case NodeTypeUse:
-        case NodeTypeZeroesLiteral:
             zig_panic("TODO more ast rendering");
     }
 }
src/codegen.cpp
@@ -1244,13 +1244,10 @@ static LLVMValueRef ir_render_decl_var(CodeGen *g, IrExecutable *executable,
     IrInstruction *init_value = decl_var_instruction->init_value;
 
     bool have_init_expr = false;
-    bool want_zeroes = false;
 
     ConstExprValue *const_val = &init_value->value;
     if (const_val->special == ConstValSpecialRuntime || const_val->special == ConstValSpecialStatic)
         have_init_expr = true;
-    if (const_val->special == ConstValSpecialZeroes)
-        want_zeroes = true;
 
     if (have_init_expr) {
         assert(var->value.type == init_value->value.type);
@@ -1259,14 +1256,14 @@ static LLVMValueRef ir_render_decl_var(CodeGen *g, IrExecutable *executable,
         bool ignore_uninit = false;
         // handle runtime stack allocation
         bool want_safe = ir_want_debug_safety(g, &decl_var_instruction->base);
-        if (!ignore_uninit && (want_safe || want_zeroes)) {
+        if (!ignore_uninit && want_safe) {
             TypeTableEntry *usize = g->builtin_types.entry_usize;
             uint64_t size_bytes = LLVMStoreSizeOfType(g->target_data_ref, var->value.type->type_ref);
             uint64_t align_bytes = get_memcpy_align(g, var->value.type);
 
             // memset uninitialized memory to 0xa
             LLVMTypeRef ptr_u8 = LLVMPointerType(LLVMInt8Type(), 0);
-            LLVMValueRef fill_char = LLVMConstInt(LLVMInt8Type(), want_zeroes ? 0x00 : 0xaa, false);
+            LLVMValueRef fill_char = LLVMConstInt(LLVMInt8Type(), 0xaa, false);
             LLVMValueRef dest_ptr = LLVMBuildBitCast(g->builder, var->value_ref, ptr_u8, "");
             LLVMValueRef byte_count = LLVMConstInt(usize->type_ref, size_bytes, false);
             LLVMValueRef align_in_bytes = LLVMConstInt(LLVMInt32Type(), align_bytes, false);
@@ -2440,8 +2437,6 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {
             zig_unreachable();
         case ConstValSpecialUndef:
             return LLVMGetUndef(canon_type->type_ref);
-        case ConstValSpecialZeroes:
-            return LLVMConstNull(canon_type->type_ref);
         case ConstValSpecialStatic:
             break;
 
src/ir.cpp
@@ -5223,8 +5223,6 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop
             zig_panic("TODO IR gen NodeTypeErrorValueDecl");
         case NodeTypeTypeDecl:
             zig_panic("TODO IR gen NodeTypeTypeDecl");
-        case NodeTypeZeroesLiteral:
-            zig_panic("TODO zeroes is deprecated");
     }
     zig_unreachable();
 }
@@ -5930,9 +5928,6 @@ static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, Un
                 ir_add_error(ira, value, buf_sprintf("use of undefined value"));
                 return nullptr;
             }
-        case ConstValSpecialZeroes:
-            ir_add_error(ira, value, buf_sprintf("zeroes is deprecated"));
-            return nullptr;
     }
     zig_unreachable();
 }
src/parser.cpp
@@ -622,7 +622,7 @@ static AstNode *ast_parse_goto_expr(ParseContext *pc, size_t *token_index, bool
 }
 /*
 PrimaryExpression = Number | String | CharLiteral | KeywordLiteral | GroupedExpression | GotoExpression | BlockExpression | Symbol | ("@" Symbol FnCallExpression) | ArrayType | (option("extern") FnProto) | AsmExpression | ("error" "." Symbol) | ContainerDecl
-KeywordLiteral = "true" | "false" | "null" | "break" | "continue" | "undefined" | "zeroes" | "error" | "type" | "this"
+KeywordLiteral = "true" | "false" | "null" | "break" | "continue" | "undefined" | "error" | "type" | "this"
 */
 static AstNode *ast_parse_primary_expr(ParseContext *pc, size_t *token_index, bool mandatory) {
     Token *token = &pc->tokens->at(*token_index);
@@ -670,10 +670,6 @@ static AstNode *ast_parse_primary_expr(ParseContext *pc, size_t *token_index, bo
         AstNode *node = ast_create_node(pc, NodeTypeUndefinedLiteral, token);
         *token_index += 1;
         return node;
-    } else if (token->id == TokenIdKeywordZeroes) {
-        AstNode *node = ast_create_node(pc, NodeTypeZeroesLiteral, token);
-        *token_index += 1;
-        return node;
     } else if (token->id == TokenIdKeywordThis) {
         AstNode *node = ast_create_node(pc, NodeTypeThisLiteral, token);
         *token_index += 1;
@@ -2585,9 +2581,6 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont
         case NodeTypeUndefinedLiteral:
             // none
             break;
-        case NodeTypeZeroesLiteral:
-            // none
-            break;
         case NodeTypeThisLiteral:
             // none
             break;
src/tokenizer.cpp
@@ -140,7 +140,6 @@ static const struct ZigKeyword zig_keywords[] = {
     {"var", TokenIdKeywordVar},
     {"volatile", TokenIdKeywordVolatile},
     {"while", TokenIdKeywordWhile},
-    {"zeroes", TokenIdKeywordZeroes},
 };
 
 bool is_zig_keyword(Buf *buf) {
@@ -1472,7 +1471,6 @@ const char * token_name(TokenId id) {
         case TokenIdKeywordNoAlias: return "noalias";
         case TokenIdKeywordSwitch: return "switch";
         case TokenIdKeywordUndefined: return "undefined";
-        case TokenIdKeywordZeroes: return "zeroes";
         case TokenIdKeywordThis: return "this";
         case TokenIdKeywordError: return "error";
         case TokenIdKeywordType: return "type";
src/tokenizer.hpp
@@ -40,7 +40,6 @@ enum TokenId {
     TokenIdKeywordNoAlias,
     TokenIdKeywordSwitch,
     TokenIdKeywordUndefined,
-    TokenIdKeywordZeroes,
     TokenIdKeywordError,
     TokenIdKeywordType,
     TokenIdKeywordInline,