| ... | ... | @@ -329,6 +329,13 @@ static IrInstruction *ir_build_const_bignum(IrBuilder *irb, AstNode *source_node |
| 329 | 329 | return &const_instruction->base; |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | static IrInstruction *ir_build_const_null(IrBuilder *irb, AstNode *source_node) { |
| 333 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, source_node); |
| 334 | const_instruction->base.type_entry = irb->codegen->builtin_types.entry_null; |
| 335 | const_instruction->base.static_value.special = ConstValSpecialStatic; |
| 336 | return &const_instruction->base; |
| 337 | } |
| 338 | |
| 332 | 339 | static IrInstruction *ir_build_const_usize(IrBuilder *irb, AstNode *source_node, uint64_t value) { |
| 333 | 340 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, source_node); |
| 334 | 341 | const_instruction->base.type_entry = irb->codegen->builtin_types.entry_usize; |
| ... | ... | @@ -1138,6 +1145,13 @@ static IrInstruction *ir_gen_num_lit(IrBuilder *irb, AstNode *node) { |
| 1138 | 1145 | return ir_build_const_bignum(irb, node, node->data.number_literal.bignum); |
| 1139 | 1146 | } |
| 1140 | 1147 | |
| 1148 | static IrInstruction *ir_gen_null_literal(IrBuilder *irb, AstNode *node) { |
| 1149 | assert(node->type == NodeTypeNullLiteral); |
| 1150 | |
| 1151 | return ir_build_const_null(irb, node); |
| 1152 | } |
| 1153 | |
| 1154 | |
| 1141 | 1155 | static IrInstruction *ir_gen_decl_ref(IrBuilder *irb, AstNode *source_node, AstNode *decl_node, |
| 1142 | 1156 | LValPurpose lval, BlockContext *scope) |
| 1143 | 1157 | { |
| ... | ... | @@ -1895,6 +1909,8 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, BlockCont |
| 1895 | 1909 | return ir_gen_undefined_literal(irb, node); |
| 1896 | 1910 | case NodeTypeAsmExpr: |
| 1897 | 1911 | return ir_gen_asm_expr(irb, node); |
| 1912 | case NodeTypeNullLiteral: |
| 1913 | return ir_gen_null_literal(irb, node); |
| 1898 | 1914 | case NodeTypeUnwrapErrorExpr: |
| 1899 | 1915 | case NodeTypeDefer: |
| 1900 | 1916 | case NodeTypeSliceExpr: |
| ... | ... | @@ -1905,7 +1921,6 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, BlockCont |
| 1905 | 1921 | case NodeTypeLabel: |
| 1906 | 1922 | case NodeTypeSwitchExpr: |
| 1907 | 1923 | case NodeTypeCharLiteral: |
| 1908 | | case NodeTypeNullLiteral: |
| 1909 | 1924 | case NodeTypeZeroesLiteral: |
| 1910 | 1925 | case NodeTypeErrorType: |
| 1911 | 1926 | case NodeTypeTypeLiteral: |
| ... | ... | @@ -3127,6 +3142,7 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc |
| 3127 | 3142 | case TypeTableEntryIdUnreachable: |
| 3128 | 3143 | case TypeTableEntryIdVar: |
| 3129 | 3144 | case TypeTableEntryIdBlock: |
| 3145 | case TypeTableEntryIdNullLit: |
| 3130 | 3146 | add_node_error(ira->codegen, var_type->source_node, |
| 3131 | 3147 | buf_sprintf("variable of type '%s' not allowed", buf_ptr(&result_type->name))); |
| 3132 | 3148 | result_type = ira->codegen->builtin_types.entry_invalid; |
| ... | ... | @@ -3140,7 +3156,6 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc |
| 3140 | 3156 | } |
| 3141 | 3157 | break; |
| 3142 | 3158 | case TypeTableEntryIdUndefLit: |
| 3143 | | case TypeTableEntryIdNullLit: |
| 3144 | 3159 | case TypeTableEntryIdVoid: |
| 3145 | 3160 | case TypeTableEntryIdBool: |
| 3146 | 3161 | case TypeTableEntryIdInt: |