mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
Rename noasync to nosuspend in C++ compiler
This commit is contained in:
parent
8d5636ebe4
commit
b957dc29a4
@ -672,7 +672,7 @@ enum NodeType {
|
||||
NodeTypeSwitchProng,
|
||||
NodeTypeSwitchRange,
|
||||
NodeTypeCompTime,
|
||||
NodeTypeNoAsync,
|
||||
NodeTypeNoSuspend,
|
||||
NodeTypeBreak,
|
||||
NodeTypeContinue,
|
||||
NodeTypeAsmExpr,
|
||||
@ -862,7 +862,7 @@ enum CallModifier {
|
||||
CallModifierAsync,
|
||||
CallModifierNeverTail,
|
||||
CallModifierNeverInline,
|
||||
CallModifierNoAsync,
|
||||
CallModifierNoSuspend,
|
||||
CallModifierAlwaysTail,
|
||||
CallModifierAlwaysInline,
|
||||
CallModifierCompileTime,
|
||||
@ -1014,7 +1014,7 @@ struct AstNodeCompTime {
|
||||
AstNode *expr;
|
||||
};
|
||||
|
||||
struct AstNodeNoAsync {
|
||||
struct AstNodeNoSuspend {
|
||||
AstNode *expr;
|
||||
};
|
||||
|
||||
@ -1225,7 +1225,7 @@ struct AstNode {
|
||||
AstNodeSwitchProng switch_prong;
|
||||
AstNodeSwitchRange switch_range;
|
||||
AstNodeCompTime comptime_expr;
|
||||
AstNodeNoAsync noasync_expr;
|
||||
AstNodeNoSuspend nosuspend_expr;
|
||||
AstNodeAsmExpr asm_expr;
|
||||
AstNodeFieldAccessExpr field_access_expr;
|
||||
AstNodePtrDerefExpr ptr_deref_expr;
|
||||
@ -1858,7 +1858,7 @@ enum PanicMsgId {
|
||||
PanicMsgIdResumedAnAwaitingFn,
|
||||
PanicMsgIdFrameTooSmall,
|
||||
PanicMsgIdResumedFnPendingAwait,
|
||||
PanicMsgIdBadNoAsyncCall,
|
||||
PanicMsgIdBadNoSuspendCall,
|
||||
PanicMsgIdResumeNotSuspendedFn,
|
||||
PanicMsgIdBadSentinel,
|
||||
PanicMsgIdShxTooBigRhs,
|
||||
@ -2376,7 +2376,7 @@ enum ScopeId {
|
||||
ScopeIdRuntime,
|
||||
ScopeIdTypeOf,
|
||||
ScopeIdExpr,
|
||||
ScopeIdNoAsync,
|
||||
ScopeIdNoSuspend,
|
||||
};
|
||||
|
||||
struct Scope {
|
||||
@ -2510,9 +2510,9 @@ struct ScopeCompTime {
|
||||
Scope base;
|
||||
};
|
||||
|
||||
// This scope is created for a noasync expression.
|
||||
// NodeTypeNoAsync
|
||||
struct ScopeNoAsync {
|
||||
// This scope is created for a nosuspend expression.
|
||||
// NodeTypeNoSuspend
|
||||
struct ScopeNoSuspend {
|
||||
Scope base;
|
||||
};
|
||||
|
||||
@ -4488,7 +4488,7 @@ struct IrInstSrcAwait {
|
||||
|
||||
IrInstSrc *frame;
|
||||
ResultLoc *result_loc;
|
||||
bool is_noasync;
|
||||
bool is_nosuspend;
|
||||
};
|
||||
|
||||
struct IrInstGenAwait {
|
||||
@ -4497,7 +4497,7 @@ struct IrInstGenAwait {
|
||||
IrInstGen *frame;
|
||||
IrInstGen *result_loc;
|
||||
ZigFn *target_fn;
|
||||
bool is_noasync;
|
||||
bool is_nosuspend;
|
||||
};
|
||||
|
||||
struct IrInstSrcResume {
|
||||
|
||||
@ -106,7 +106,7 @@ static ScopeExpr *find_expr_scope(Scope *scope) {
|
||||
case ScopeIdDecls:
|
||||
case ScopeIdFnDef:
|
||||
case ScopeIdCompTime:
|
||||
case ScopeIdNoAsync:
|
||||
case ScopeIdNoSuspend:
|
||||
case ScopeIdVarDecl:
|
||||
case ScopeIdCImport:
|
||||
case ScopeIdSuspend:
|
||||
@ -227,9 +227,9 @@ Scope *create_comptime_scope(CodeGen *g, AstNode *node, Scope *parent) {
|
||||
return &scope->base;
|
||||
}
|
||||
|
||||
Scope *create_noasync_scope(CodeGen *g, AstNode *node, Scope *parent) {
|
||||
ScopeNoAsync *scope = heap::c_allocator.create<ScopeNoAsync>();
|
||||
init_scope(g, &scope->base, ScopeIdNoAsync, node, parent);
|
||||
Scope *create_nosuspend_scope(CodeGen *g, AstNode *node, Scope *parent) {
|
||||
ScopeNoSuspend *scope = heap::c_allocator.create<ScopeNoSuspend>();
|
||||
init_scope(g, &scope->base, ScopeIdNoSuspend, node, parent);
|
||||
return &scope->base;
|
||||
}
|
||||
|
||||
@ -3771,7 +3771,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {
|
||||
case NodeTypeCompTime:
|
||||
preview_comptime_decl(g, node, decls_scope);
|
||||
break;
|
||||
case NodeTypeNoAsync:
|
||||
case NodeTypeNoSuspend:
|
||||
case NodeTypeParamDecl:
|
||||
case NodeTypeReturnExpr:
|
||||
case NodeTypeDefer:
|
||||
@ -4689,7 +4689,7 @@ void add_async_error_notes(CodeGen *g, ErrorMsg *msg, ZigFn *fn) {
|
||||
static Error analyze_callee_async(CodeGen *g, ZigFn *fn, ZigFn *callee, AstNode *call_node,
|
||||
bool must_not_be_async, CallModifier modifier)
|
||||
{
|
||||
if (modifier == CallModifierNoAsync)
|
||||
if (modifier == CallModifierNoSuspend)
|
||||
return ErrorNone;
|
||||
bool callee_is_async = false;
|
||||
switch (callee->type_entry->data.fn.fn_type_id.cc) {
|
||||
@ -4812,7 +4812,7 @@ static void analyze_fn_async(CodeGen *g, ZigFn *fn, bool resolve_frame) {
|
||||
}
|
||||
for (size_t i = 0; i < fn->await_list.length; i += 1) {
|
||||
IrInstGenAwait *await = fn->await_list.at(i);
|
||||
if (await->is_noasync) continue;
|
||||
if (await->is_nosuspend) continue;
|
||||
switch (analyze_callee_async(g, fn, await->target_fn, await->base.base.source_node, must_not_be_async,
|
||||
CallModifierNone))
|
||||
{
|
||||
@ -6239,7 +6239,7 @@ static void mark_suspension_point(Scope *scope) {
|
||||
case ScopeIdDecls:
|
||||
case ScopeIdFnDef:
|
||||
case ScopeIdCompTime:
|
||||
case ScopeIdNoAsync:
|
||||
case ScopeIdNoSuspend:
|
||||
case ScopeIdCImport:
|
||||
case ScopeIdSuspend:
|
||||
case ScopeIdTypeOf:
|
||||
@ -6472,7 +6472,7 @@ static Error resolve_async_frame(CodeGen *g, ZigType *frame_type) {
|
||||
// The funtion call result of foo() must be spilled.
|
||||
for (size_t i = 0; i < fn->await_list.length; i += 1) {
|
||||
IrInstGenAwait *await = fn->await_list.at(i);
|
||||
if (await->is_noasync) {
|
||||
if (await->is_nosuspend) {
|
||||
continue;
|
||||
}
|
||||
if (await->base.value->special != ConstValSpecialRuntime) {
|
||||
|
||||
@ -125,7 +125,7 @@ ScopeLoop *create_loop_scope(CodeGen *g, AstNode *node, Scope *parent);
|
||||
ScopeSuspend *create_suspend_scope(CodeGen *g, AstNode *node, Scope *parent);
|
||||
ScopeFnDef *create_fndef_scope(CodeGen *g, AstNode *node, Scope *parent, ZigFn *fn_entry);
|
||||
Scope *create_comptime_scope(CodeGen *g, AstNode *node, Scope *parent);
|
||||
Scope *create_noasync_scope(CodeGen *g, AstNode *node, Scope *parent);
|
||||
Scope *create_nosuspend_scope(CodeGen *g, AstNode *node, Scope *parent);
|
||||
Scope *create_runtime_scope(CodeGen *g, AstNode *node, Scope *parent, IrInstSrc *is_comptime);
|
||||
Scope *create_typeof_scope(CodeGen *g, AstNode *node, Scope *parent);
|
||||
ScopeExpr *create_expr_scope(CodeGen *g, AstNode *node, Scope *parent);
|
||||
|
||||
@ -220,8 +220,8 @@ static const char *node_type_str(NodeType node_type) {
|
||||
return "SwitchRange";
|
||||
case NodeTypeCompTime:
|
||||
return "CompTime";
|
||||
case NodeTypeNoAsync:
|
||||
return "NoAsync";
|
||||
case NodeTypeNoSuspend:
|
||||
return "NoSuspend";
|
||||
case NodeTypeBreak:
|
||||
return "Break";
|
||||
case NodeTypeContinue:
|
||||
@ -709,8 +709,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
|
||||
switch (node->data.fn_call_expr.modifier) {
|
||||
case CallModifierNone:
|
||||
break;
|
||||
case CallModifierNoAsync:
|
||||
fprintf(ar->f, "noasync ");
|
||||
case CallModifierNoSuspend:
|
||||
fprintf(ar->f, "nosuspend ");
|
||||
break;
|
||||
case CallModifierAsync:
|
||||
fprintf(ar->f, "async ");
|
||||
@ -1093,10 +1093,10 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
|
||||
render_node_grouped(ar, node->data.comptime_expr.expr);
|
||||
break;
|
||||
}
|
||||
case NodeTypeNoAsync:
|
||||
case NodeTypeNoSuspend:
|
||||
{
|
||||
fprintf(ar->f, "noasync ");
|
||||
render_node_grouped(ar, node->data.noasync_expr.expr);
|
||||
fprintf(ar->f, "nosuspend ");
|
||||
render_node_grouped(ar, node->data.nosuspend_expr.expr);
|
||||
break;
|
||||
}
|
||||
case NodeTypeForExpr:
|
||||
|
||||
@ -685,7 +685,7 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) {
|
||||
case ScopeIdLoop:
|
||||
case ScopeIdSuspend:
|
||||
case ScopeIdCompTime:
|
||||
case ScopeIdNoAsync:
|
||||
case ScopeIdNoSuspend:
|
||||
case ScopeIdRuntime:
|
||||
case ScopeIdTypeOf:
|
||||
case ScopeIdExpr:
|
||||
@ -966,8 +966,8 @@ static Buf *panic_msg_buf(PanicMsgId msg_id) {
|
||||
return buf_create_from_str("frame too small");
|
||||
case PanicMsgIdResumedFnPendingAwait:
|
||||
return buf_create_from_str("resumed an async function which can only be awaited");
|
||||
case PanicMsgIdBadNoAsyncCall:
|
||||
return buf_create_from_str("async function called in noasync scope suspended");
|
||||
case PanicMsgIdBadNoSuspendCall:
|
||||
return buf_create_from_str("async function called in nosuspend scope suspended");
|
||||
case PanicMsgIdResumeNotSuspendedFn:
|
||||
return buf_create_from_str("resumed a non-suspended function");
|
||||
case PanicMsgIdBadSentinel:
|
||||
@ -4061,7 +4061,7 @@ static void render_async_var_decls(CodeGen *g, Scope *scope) {
|
||||
case ScopeIdLoop:
|
||||
case ScopeIdSuspend:
|
||||
case ScopeIdCompTime:
|
||||
case ScopeIdNoAsync:
|
||||
case ScopeIdNoSuspend:
|
||||
case ScopeIdRuntime:
|
||||
case ScopeIdTypeOf:
|
||||
case ScopeIdExpr:
|
||||
@ -4212,9 +4212,9 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn
|
||||
// even if prefix_arg_err_ret_stack is true, let the async function do its own
|
||||
// initialization.
|
||||
} else {
|
||||
if (instruction->modifier == CallModifierNoAsync && !fn_is_async(g->cur_fn)) {
|
||||
if (instruction->modifier == CallModifierNoSuspend && !fn_is_async(g->cur_fn)) {
|
||||
// Async function called as a normal function, and calling function is not async.
|
||||
// This is allowed because it was called with `noasync` which asserts that it will
|
||||
// This is allowed because it was called with `nosuspend` which asserts that it will
|
||||
// never suspend.
|
||||
awaiter_init_val = zero;
|
||||
} else {
|
||||
@ -4325,7 +4325,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn
|
||||
case CallModifierCompileTime:
|
||||
zig_unreachable();
|
||||
case CallModifierNone:
|
||||
case CallModifierNoAsync:
|
||||
case CallModifierNoSuspend:
|
||||
case CallModifierAsync:
|
||||
call_attr = ZigLLVM_CallAttrAuto;
|
||||
break;
|
||||
@ -4401,7 +4401,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn
|
||||
get_llvm_type(g, instruction->base.value->type), "");
|
||||
}
|
||||
return nullptr;
|
||||
} else if (instruction->modifier == CallModifierNoAsync && !fn_is_async(g->cur_fn)) {
|
||||
} else if (instruction->modifier == CallModifierNoSuspend && !fn_is_async(g->cur_fn)) {
|
||||
gen_resume(g, fn_val, frame_result_loc, ResumeIdCall);
|
||||
|
||||
if (ir_want_runtime_safety(g, &instruction->base)) {
|
||||
@ -4412,13 +4412,13 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn
|
||||
all_ones, LLVMAtomicOrderingRelease);
|
||||
LLVMValueRef ok_val = LLVMBuildICmp(g->builder, LLVMIntEQ, prev_val, all_ones, "");
|
||||
|
||||
LLVMBasicBlockRef bad_block = LLVMAppendBasicBlock(g->cur_fn_val, "NoAsyncPanic");
|
||||
LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "NoAsyncOk");
|
||||
LLVMBasicBlockRef bad_block = LLVMAppendBasicBlock(g->cur_fn_val, "NoSuspendPanic");
|
||||
LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "NoSuspendOk");
|
||||
LLVMBuildCondBr(g->builder, ok_val, ok_block, bad_block);
|
||||
|
||||
// The async function suspended, but this noasync call asserted it wouldn't.
|
||||
// The async function suspended, but this nosuspend call asserted it wouldn't.
|
||||
LLVMPositionBuilderAtEnd(g->builder, bad_block);
|
||||
gen_safety_crash(g, PanicMsgIdBadNoAsyncCall);
|
||||
gen_safety_crash(g, PanicMsgIdBadNoSuspendCall);
|
||||
|
||||
LLVMPositionBuilderAtEnd(g->builder, ok_block);
|
||||
}
|
||||
@ -6391,7 +6391,7 @@ static LLVMValueRef ir_render_await(CodeGen *g, IrExecutableGen *executable, IrI
|
||||
LLVMValueRef result_loc = (instruction->result_loc == nullptr) ?
|
||||
nullptr : ir_llvm_value(g, instruction->result_loc);
|
||||
|
||||
if (instruction->is_noasync ||
|
||||
if (instruction->is_nosuspend ||
|
||||
(instruction->target_fn != nullptr && !fn_is_async(instruction->target_fn)))
|
||||
{
|
||||
return gen_await_early_return(g, &instruction->base, target_frame_ptr, result_type,
|
||||
@ -7918,7 +7918,7 @@ static void do_code_gen(CodeGen *g) {
|
||||
}
|
||||
|
||||
if (!is_async) {
|
||||
// allocate async frames for noasync calls & awaits to async functions
|
||||
// allocate async frames for nosuspend calls & awaits to async functions
|
||||
ZigType *largest_call_frame_type = nullptr;
|
||||
IrInstGen *all_calls_alloca = ir_create_alloca(g, &fn_table_entry->fndef_scope->base,
|
||||
fn_table_entry->body_node, fn_table_entry, g->builtin_types.entry_void, "@async_call_frame");
|
||||
@ -7928,7 +7928,7 @@ static void do_code_gen(CodeGen *g) {
|
||||
continue;
|
||||
if (!fn_is_async(call->fn_entry))
|
||||
continue;
|
||||
if (call->modifier != CallModifierNoAsync)
|
||||
if (call->modifier != CallModifierNoSuspend)
|
||||
continue;
|
||||
if (call->frame_result_loc != nullptr)
|
||||
continue;
|
||||
|
||||
60
src/ir.cpp
60
src/ir.cpp
@ -4846,12 +4846,12 @@ static IrInstGen *ir_build_suspend_finish_gen(IrAnalyze *ira, IrInst *source_ins
|
||||
}
|
||||
|
||||
static IrInstSrc *ir_build_await_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node,
|
||||
IrInstSrc *frame, ResultLoc *result_loc, bool is_noasync)
|
||||
IrInstSrc *frame, ResultLoc *result_loc, bool is_nosuspend)
|
||||
{
|
||||
IrInstSrcAwait *instruction = ir_build_instruction<IrInstSrcAwait>(irb, scope, source_node);
|
||||
instruction->frame = frame;
|
||||
instruction->result_loc = result_loc;
|
||||
instruction->is_noasync = is_noasync;
|
||||
instruction->is_nosuspend = is_nosuspend;
|
||||
|
||||
ir_ref_instruction(frame, irb->current_basic_block);
|
||||
|
||||
@ -4859,14 +4859,14 @@ static IrInstSrc *ir_build_await_src(IrBuilderSrc *irb, Scope *scope, AstNode *s
|
||||
}
|
||||
|
||||
static IrInstGenAwait *ir_build_await_gen(IrAnalyze *ira, IrInst *source_instruction,
|
||||
IrInstGen *frame, ZigType *result_type, IrInstGen *result_loc, bool is_noasync)
|
||||
IrInstGen *frame, ZigType *result_type, IrInstGen *result_loc, bool is_nosuspend)
|
||||
{
|
||||
IrInstGenAwait *instruction = ir_build_inst_gen<IrInstGenAwait>(&ira->new_irb,
|
||||
source_instruction->scope, source_instruction->source_node);
|
||||
instruction->base.value->type = result_type;
|
||||
instruction->frame = frame;
|
||||
instruction->result_loc = result_loc;
|
||||
instruction->is_noasync = is_noasync;
|
||||
instruction->is_nosuspend = is_nosuspend;
|
||||
|
||||
ir_ref_inst_gen(frame);
|
||||
if (result_loc != nullptr) ir_ref_inst_gen(result_loc);
|
||||
@ -4982,7 +4982,7 @@ static void ir_count_defers(IrBuilderSrc *irb, Scope *inner_scope, Scope *outer_
|
||||
case ScopeIdLoop:
|
||||
case ScopeIdSuspend:
|
||||
case ScopeIdCompTime:
|
||||
case ScopeIdNoAsync:
|
||||
case ScopeIdNoSuspend:
|
||||
case ScopeIdRuntime:
|
||||
case ScopeIdTypeOf:
|
||||
case ScopeIdExpr:
|
||||
@ -5072,7 +5072,7 @@ static bool ir_gen_defers_for_block(IrBuilderSrc *irb, Scope *inner_scope, Scope
|
||||
case ScopeIdLoop:
|
||||
case ScopeIdSuspend:
|
||||
case ScopeIdCompTime:
|
||||
case ScopeIdNoAsync:
|
||||
case ScopeIdNoSuspend:
|
||||
case ScopeIdRuntime:
|
||||
case ScopeIdTypeOf:
|
||||
case ScopeIdExpr:
|
||||
@ -7335,10 +7335,10 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod
|
||||
zig_unreachable();
|
||||
}
|
||||
|
||||
static ScopeNoAsync *get_scope_noasync(Scope *scope) {
|
||||
static ScopeNoSuspend *get_scope_nosuspend(Scope *scope) {
|
||||
while (scope) {
|
||||
if (scope->id == ScopeIdNoAsync)
|
||||
return (ScopeNoAsync *)scope;
|
||||
if (scope->id == ScopeIdNoSuspend)
|
||||
return (ScopeNoSuspend *)scope;
|
||||
if (scope->id == ScopeIdFnDef)
|
||||
return nullptr;
|
||||
|
||||
@ -7355,15 +7355,15 @@ static IrInstSrc *ir_gen_fn_call(IrBuilderSrc *irb, Scope *scope, AstNode *node,
|
||||
if (node->data.fn_call_expr.modifier == CallModifierBuiltin)
|
||||
return ir_gen_builtin_fn_call(irb, scope, node, lval, result_loc);
|
||||
|
||||
bool is_noasync = get_scope_noasync(scope) != nullptr;
|
||||
bool is_nosuspend = get_scope_nosuspend(scope) != nullptr;
|
||||
CallModifier modifier = node->data.fn_call_expr.modifier;
|
||||
if (is_noasync) {
|
||||
if (is_nosuspend) {
|
||||
if (modifier == CallModifierAsync) {
|
||||
add_node_error(irb->codegen, node,
|
||||
buf_sprintf("async call in noasync scope"));
|
||||
buf_sprintf("async call in nosuspend scope"));
|
||||
return irb->codegen->invalid_inst_src;
|
||||
}
|
||||
modifier = CallModifierNoAsync;
|
||||
modifier = CallModifierNoSuspend;
|
||||
}
|
||||
|
||||
AstNode *fn_ref_node = node->data.fn_call_expr.fn_ref_expr;
|
||||
@ -9222,10 +9222,10 @@ static IrInstSrc *ir_gen_comptime(IrBuilderSrc *irb, Scope *parent_scope, AstNod
|
||||
return ir_gen_node_extra(irb, node->data.comptime_expr.expr, child_scope, lval, nullptr);
|
||||
}
|
||||
|
||||
static IrInstSrc *ir_gen_noasync(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node, LVal lval) {
|
||||
assert(node->type == NodeTypeNoAsync);
|
||||
static IrInstSrc *ir_gen_nosuspend(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node, LVal lval) {
|
||||
assert(node->type == NodeTypeNoSuspend);
|
||||
|
||||
Scope *child_scope = create_noasync_scope(irb->codegen, node, parent_scope);
|
||||
Scope *child_scope = create_nosuspend_scope(irb->codegen, node, parent_scope);
|
||||
// purposefully pass null for result_loc and let EndExpr handle it
|
||||
return ir_gen_node_extra(irb, node->data.comptime_expr.expr, child_scope, lval, nullptr);
|
||||
}
|
||||
@ -9813,8 +9813,8 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod
|
||||
|
||||
static IrInstSrc *ir_gen_resume(IrBuilderSrc *irb, Scope *scope, AstNode *node) {
|
||||
assert(node->type == NodeTypeResume);
|
||||
if (get_scope_noasync(scope) != nullptr) {
|
||||
add_node_error(irb->codegen, node, buf_sprintf("resume in noasync scope"));
|
||||
if (get_scope_nosuspend(scope) != nullptr) {
|
||||
add_node_error(irb->codegen, node, buf_sprintf("resume in nosuspend scope"));
|
||||
return irb->codegen->invalid_inst_src;
|
||||
}
|
||||
|
||||
@ -9830,7 +9830,7 @@ static IrInstSrc *ir_gen_await_expr(IrBuilderSrc *irb, Scope *scope, AstNode *no
|
||||
{
|
||||
assert(node->type == NodeTypeAwaitExpr);
|
||||
|
||||
bool is_noasync = get_scope_noasync(scope) != nullptr;
|
||||
bool is_nosuspend = get_scope_nosuspend(scope) != nullptr;
|
||||
|
||||
AstNode *expr_node = node->data.await_expr.expr;
|
||||
if (expr_node->type == NodeTypeFnCallExpr && expr_node->data.fn_call_expr.modifier == CallModifierBuiltin) {
|
||||
@ -9864,7 +9864,7 @@ static IrInstSrc *ir_gen_await_expr(IrBuilderSrc *irb, Scope *scope, AstNode *no
|
||||
if (target_inst == irb->codegen->invalid_inst_src)
|
||||
return irb->codegen->invalid_inst_src;
|
||||
|
||||
IrInstSrc *await_inst = ir_build_await_src(irb, scope, node, target_inst, result_loc, is_noasync);
|
||||
IrInstSrc *await_inst = ir_build_await_src(irb, scope, node, target_inst, result_loc, is_nosuspend);
|
||||
return ir_lval_wrap(irb, scope, await_inst, lval, result_loc);
|
||||
}
|
||||
|
||||
@ -9876,8 +9876,8 @@ static IrInstSrc *ir_gen_suspend(IrBuilderSrc *irb, Scope *parent_scope, AstNode
|
||||
add_node_error(irb->codegen, node, buf_sprintf("suspend outside function definition"));
|
||||
return irb->codegen->invalid_inst_src;
|
||||
}
|
||||
if (get_scope_noasync(parent_scope) != nullptr) {
|
||||
add_node_error(irb->codegen, node, buf_sprintf("suspend in noasync scope"));
|
||||
if (get_scope_nosuspend(parent_scope) != nullptr) {
|
||||
add_node_error(irb->codegen, node, buf_sprintf("suspend in nosuspend scope"));
|
||||
return irb->codegen->invalid_inst_src;
|
||||
}
|
||||
|
||||
@ -10017,8 +10017,8 @@ static IrInstSrc *ir_gen_node_raw(IrBuilderSrc *irb, AstNode *node, Scope *scope
|
||||
return ir_gen_switch_expr(irb, scope, node, lval, result_loc);
|
||||
case NodeTypeCompTime:
|
||||
return ir_expr_wrap(irb, scope, ir_gen_comptime(irb, scope, node, lval), result_loc);
|
||||
case NodeTypeNoAsync:
|
||||
return ir_expr_wrap(irb, scope, ir_gen_noasync(irb, scope, node, lval), result_loc);
|
||||
case NodeTypeNoSuspend:
|
||||
return ir_expr_wrap(irb, scope, ir_gen_nosuspend(irb, scope, node, lval), result_loc);
|
||||
case NodeTypeErrorType:
|
||||
return ir_lval_wrap(irb, scope, ir_gen_error_type(irb, scope, node), lval, result_loc);
|
||||
case NodeTypeBreak:
|
||||
@ -10105,7 +10105,7 @@ static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *sco
|
||||
case NodeTypeIfOptional:
|
||||
case NodeTypeSwitchExpr:
|
||||
case NodeTypeCompTime:
|
||||
case NodeTypeNoAsync:
|
||||
case NodeTypeNoSuspend:
|
||||
case NodeTypeErrorType:
|
||||
case NodeTypeBreak:
|
||||
case NodeTypeContinue:
|
||||
@ -20025,7 +20025,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
|
||||
|
||||
if (impl_fn_type_id->cc == CallingConventionAsync &&
|
||||
parent_fn_entry->inferred_async_node == nullptr &&
|
||||
modifier != CallModifierNoAsync)
|
||||
modifier != CallModifierNoSuspend)
|
||||
{
|
||||
parent_fn_entry->inferred_async_node = fn_ref->base.source_node;
|
||||
parent_fn_entry->inferred_async_fn = impl_fn;
|
||||
@ -20123,7 +20123,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
|
||||
|
||||
if (fn_type_id->cc == CallingConventionAsync &&
|
||||
parent_fn_entry->inferred_async_node == nullptr &&
|
||||
modifier != CallModifierNoAsync)
|
||||
modifier != CallModifierNoSuspend)
|
||||
{
|
||||
parent_fn_entry->inferred_async_node = fn_ref->base.source_node;
|
||||
parent_fn_entry->inferred_async_fn = fn_entry;
|
||||
@ -20233,7 +20233,7 @@ static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, IrInst* source_instr,
|
||||
case CallModifierNone:
|
||||
case CallModifierAlwaysInline:
|
||||
case CallModifierAlwaysTail:
|
||||
case CallModifierNoAsync:
|
||||
case CallModifierNoSuspend:
|
||||
modifier = CallModifierCompileTime;
|
||||
break;
|
||||
case CallModifierNeverInline:
|
||||
@ -30277,7 +30277,7 @@ static IrInstGen *ir_analyze_instruction_await(IrAnalyze *ira, IrInstSrcAwait *i
|
||||
ir_assert(fn_entry != nullptr, &instruction->base.base);
|
||||
|
||||
// If it's not @Frame(func) then it's definitely a suspend point
|
||||
if (target_fn == nullptr && !instruction->is_noasync) {
|
||||
if (target_fn == nullptr && !instruction->is_nosuspend) {
|
||||
if (fn_entry->inferred_async_node == nullptr) {
|
||||
fn_entry->inferred_async_node = instruction->base.base.source_node;
|
||||
}
|
||||
@ -30301,7 +30301,7 @@ static IrInstGen *ir_analyze_instruction_await(IrAnalyze *ira, IrInstSrcAwait *i
|
||||
}
|
||||
|
||||
IrInstGenAwait *result = ir_build_await_gen(ira, &instruction->base.base, frame, result_type, result_loc,
|
||||
instruction->is_noasync);
|
||||
instruction->is_nosuspend);
|
||||
result->target_fn = target_fn;
|
||||
fn_entry->await_list.append(result);
|
||||
return ir_finish_anal(ira, &result->base);
|
||||
|
||||
@ -861,8 +861,8 @@ static void ir_print_call_src(IrPrintSrc *irp, IrInstSrcCall *call_instruction)
|
||||
switch (call_instruction->modifier) {
|
||||
case CallModifierNone:
|
||||
break;
|
||||
case CallModifierNoAsync:
|
||||
fprintf(irp->f, "noasync ");
|
||||
case CallModifierNoSuspend:
|
||||
fprintf(irp->f, "nosuspend ");
|
||||
break;
|
||||
case CallModifierAsync:
|
||||
fprintf(irp->f, "async ");
|
||||
@ -906,8 +906,8 @@ static void ir_print_call_gen(IrPrintGen *irp, IrInstGenCall *call_instruction)
|
||||
switch (call_instruction->modifier) {
|
||||
case CallModifierNone:
|
||||
break;
|
||||
case CallModifierNoAsync:
|
||||
fprintf(irp->f, "noasync ");
|
||||
case CallModifierNoSuspend:
|
||||
fprintf(irp->f, "nosuspend ");
|
||||
break;
|
||||
case CallModifierAsync:
|
||||
fprintf(irp->f, "async ");
|
||||
|
||||
@ -913,7 +913,7 @@ static AstNode *ast_parse_container_field(ParseContext *pc) {
|
||||
// Statement
|
||||
// <- KEYWORD_comptime? VarDecl
|
||||
// / KEYWORD_comptime BlockExprStatement
|
||||
// / KEYWORD_noasync BlockExprStatement
|
||||
// / KEYWORD_nosuspend BlockExprStatement
|
||||
// / KEYWORD_suspend (SEMICOLON / BlockExprStatement)
|
||||
// / KEYWORD_defer BlockExprStatement
|
||||
// / KEYWORD_errdefer Payload? BlockExprStatement
|
||||
@ -937,11 +937,11 @@ static AstNode *ast_parse_statement(ParseContext *pc) {
|
||||
return res;
|
||||
}
|
||||
|
||||
Token *noasync = eat_token_if(pc, TokenIdKeywordNoAsync);
|
||||
if (noasync != nullptr) {
|
||||
Token *nosuspend = eat_token_if(pc, TokenIdKeywordNoSuspend);
|
||||
if (nosuspend != nullptr) {
|
||||
AstNode *statement = ast_expect(pc, ast_parse_block_expr_statement);
|
||||
AstNode *res = ast_create_node(pc, NodeTypeNoAsync, noasync);
|
||||
res->data.noasync_expr.expr = statement;
|
||||
AstNode *res = ast_create_node(pc, NodeTypeNoSuspend, nosuspend);
|
||||
res->data.nosuspend_expr.expr = statement;
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -1289,7 +1289,7 @@ static AstNode *ast_parse_prefix_expr(ParseContext *pc) {
|
||||
// / IfExpr
|
||||
// / KEYWORD_break BreakLabel? Expr?
|
||||
// / KEYWORD_comptime Expr
|
||||
// / KEYWORD_noasync Expr
|
||||
// / KEYWORD_nosuspend Expr
|
||||
// / KEYWORD_continue BreakLabel?
|
||||
// / KEYWORD_resume Expr
|
||||
// / KEYWORD_return Expr?
|
||||
@ -1324,11 +1324,11 @@ static AstNode *ast_parse_primary_expr(ParseContext *pc) {
|
||||
return res;
|
||||
}
|
||||
|
||||
Token *noasync = eat_token_if(pc, TokenIdKeywordNoAsync);
|
||||
if (noasync != nullptr) {
|
||||
Token *nosuspend = eat_token_if(pc, TokenIdKeywordNoSuspend);
|
||||
if (nosuspend != nullptr) {
|
||||
AstNode *expr = ast_expect(pc, ast_parse_expr);
|
||||
AstNode *res = ast_create_node(pc, NodeTypeNoAsync, noasync);
|
||||
res->data.noasync_expr.expr = expr;
|
||||
AstNode *res = ast_create_node(pc, NodeTypeNoSuspend, nosuspend);
|
||||
res->data.nosuspend_expr.expr = expr;
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -1640,7 +1640,7 @@ static AstNode *ast_parse_suffix_expr(ParseContext *pc) {
|
||||
// / IfTypeExpr
|
||||
// / INTEGER
|
||||
// / KEYWORD_comptime TypeExpr
|
||||
// / KEYWORD_noasync TypeExpr
|
||||
// / KEYWORD_nosuspend TypeExpr
|
||||
// / KEYWORD_error DOT IDENTIFIER
|
||||
// / KEYWORD_false
|
||||
// / KEYWORD_null
|
||||
@ -1742,11 +1742,11 @@ static AstNode *ast_parse_primary_type_expr(ParseContext *pc) {
|
||||
return res;
|
||||
}
|
||||
|
||||
Token *noasync = eat_token_if(pc, TokenIdKeywordNoAsync);
|
||||
if (noasync != nullptr) {
|
||||
Token *nosuspend = eat_token_if(pc, TokenIdKeywordNoSuspend);
|
||||
if (nosuspend != nullptr) {
|
||||
AstNode *expr = ast_expect(pc, ast_parse_type_expr);
|
||||
AstNode *res = ast_create_node(pc, NodeTypeNoAsync, noasync);
|
||||
res->data.noasync_expr.expr = expr;
|
||||
AstNode *res = ast_create_node(pc, NodeTypeNoSuspend, nosuspend);
|
||||
res->data.nosuspend_expr.expr = expr;
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -3189,7 +3189,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont
|
||||
case NodeTypeCompTime:
|
||||
visit_field(&node->data.comptime_expr.expr, visit, context);
|
||||
break;
|
||||
case NodeTypeNoAsync:
|
||||
case NodeTypeNoSuspend:
|
||||
visit_field(&node->data.comptime_expr.expr, visit, context);
|
||||
break;
|
||||
case NodeTypeBreak:
|
||||
|
||||
@ -128,8 +128,8 @@ static const struct ZigKeyword zig_keywords[] = {
|
||||
{"if", TokenIdKeywordIf},
|
||||
{"inline", TokenIdKeywordInline},
|
||||
{"noalias", TokenIdKeywordNoAlias},
|
||||
{"noasync", TokenIdKeywordNoAsync},
|
||||
{"noinline", TokenIdKeywordNoInline},
|
||||
{"nosuspend", TokenIdKeywordNoSuspend},
|
||||
{"null", TokenIdKeywordNull},
|
||||
{"or", TokenIdKeywordOr},
|
||||
{"orelse", TokenIdKeywordOrElse},
|
||||
@ -1589,8 +1589,8 @@ const char * token_name(TokenId id) {
|
||||
case TokenIdKeywordIf: return "if";
|
||||
case TokenIdKeywordInline: return "inline";
|
||||
case TokenIdKeywordNoAlias: return "noalias";
|
||||
case TokenIdKeywordNoAsync: return "noasync";
|
||||
case TokenIdKeywordNoInline: return "noinline";
|
||||
case TokenIdKeywordNoSuspend: return "nosuspend";
|
||||
case TokenIdKeywordNull: return "null";
|
||||
case TokenIdKeywordOr: return "or";
|
||||
case TokenIdKeywordOrElse: return "orelse";
|
||||
|
||||
@ -78,7 +78,7 @@ enum TokenId {
|
||||
TokenIdKeywordNoInline,
|
||||
TokenIdKeywordLinkSection,
|
||||
TokenIdKeywordNoAlias,
|
||||
TokenIdKeywordNoAsync,
|
||||
TokenIdKeywordNoSuspend,
|
||||
TokenIdKeywordNull,
|
||||
TokenIdKeywordOr,
|
||||
TokenIdKeywordOrElse,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user