add ?? prefix operator

This commit is contained in:
Andrew Kelley
2016-02-01 02:11:46 -07:00
parent b3459f64e7
commit 179443bd61
8 changed files with 29 additions and 26 deletions

View File

@@ -85,6 +85,7 @@ static LLVMValueRef gen_var_decl_raw(CodeGen *g, AstNode *source_node, AstNodeVa
static LLVMValueRef gen_assign_raw(CodeGen *g, AstNode *source_node, BinOpType bin_op,
LLVMValueRef target_ref, LLVMValueRef value,
TypeTableEntry *op1_type, TypeTableEntry *op2_type);
static LLVMValueRef gen_unwrap_maybe(CodeGen *g, AstNode *node, LLVMValueRef maybe_struct_ref);
static TypeTableEntry *get_type_for_type_node(AstNode *node) {
Expr *expr = get_resolved_expr(node);
@@ -1005,6 +1006,12 @@ static LLVMValueRef gen_prefix_op_expr(CodeGen *g, AstNode *node) {
return nullptr;
}
}
case PrefixOpUnwrapMaybe:
{
LLVMValueRef expr_val = gen_expr(g, expr_node);
// TODO in debug mode, put a panic here if null
return gen_unwrap_maybe(g, expr_node, expr_val);
}
}
zig_unreachable();
}