diff options
| author | gingerBill <bill@gingerbill.org> | 2023-07-17 16:56:10 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-07-17 16:56:10 +0100 |
| commit | bd73834e196d21aaed0bb1fd0a3d84e323b8aba7 (patch) | |
| tree | 356b6b2539cb0eb579e59057f16d7058a363f517 /src/tilde_stmt.cpp | |
| parent | 7f43c2429707c7b76c2703e9e8ba20d8c449ebad (diff) | |
Update Tilde; mock out `cg_build_return_stmt`
128-bit types are broken
Diffstat (limited to 'src/tilde_stmt.cpp')
| -rw-r--r-- | src/tilde_stmt.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/tilde_stmt.cpp b/src/tilde_stmt.cpp index a38886c2e..787b94a58 100644 --- a/src/tilde_stmt.cpp +++ b/src/tilde_stmt.cpp @@ -736,7 +736,33 @@ gb_internal void cg_build_assign_stmt(cgProcedure *p, AstAssignStmt *as) { } gb_internal void cg_build_return_stmt(cgProcedure *p, Slice<Ast *> const &return_results) { - + TypeTuple *tuple = &p->type->Proc.results->Tuple; + isize return_count = p->type->Proc.result_count; + gb_unused(tuple); + isize res_count = return_results.count; + gb_unused(res_count); + + if (return_count == 0) { + tb_inst_ret(p->func, 0, nullptr); + return; + } else if (return_count == 1) { + Entity *e = tuple->variables[0]; + if (res_count == 0) { + cgValue zero = cg_const_nil(p, tuple->variables[0]->type); + if (zero.kind == cgValue_Value) { + tb_inst_ret(p->func, 1, &zero.node); + } + return; + } + cgValue res = cg_build_expr(p, return_results[0]); + res = cg_emit_conv(p, res, e->type); + if (res.kind == cgValue_Value) { + tb_inst_ret(p->func, 1, &res.node); + } + return; + } else { + GB_PANIC("TODO(bill): MUTLIPLE RETURN VALUES"); + } } |