ctx->add_statement (return_value);
// now just return unit expression
- tree unit_expr = unit_expression (ctx, locus);
+ tree unit_expr = unit_expression (locus);
tree return_stmt
= Backend::return_statement (fndecl, unit_expr, locus);
ctx->add_statement (return_stmt);
// we can only do this if the function is of unit type otherwise other
// errors should have occurred
location_t locus = function_body.get_locus ();
- tree return_value = unit_expression (ctx, locus);
+ tree return_value = unit_expression (locus);
tree return_stmt
= Backend::return_statement (fndecl, return_value, locus);
ctx->add_statement (return_stmt);
}
tree
-HIRCompileBase::unit_expression (Context *ctx, location_t locus)
+HIRCompileBase::unit_expression (location_t locus)
{
- tree unit_type = TyTyResolveCompile::get_unit_type (ctx);
+ tree unit_type = TyTyResolveCompile::get_unit_type ();
return Backend::constructor_expression (unit_type, false, {}, -1, locus);
}
const Resolver::CanonicalPath *canonical_path,
TyTy::FnType *fntype);
- static tree unit_expression (Context *ctx, location_t locus);
+ static tree unit_expression (location_t locus);
void setup_fndecl (tree fndecl, bool is_main_entry_point, bool is_generic_fn,
HIR::Visibility &visibility,
else if (result != nullptr)
{
location_t locus = expr.get_locus ();
- tree compiled_expr = unit_expression (ctx, expr.get_locus ());
+ tree compiled_expr = unit_expression (expr.get_locus ());
tree result_reference = Backend::var_expression (result, locus);
tree assignment
{
if (expr.is_unit ())
{
- translated = unit_expression (ctx, expr.get_locus ());
+ translated = unit_expression (expr.get_locus ());
return;
}
tree return_value = expr.has_return_expr ()
? CompileExpr::Compile (expr.return_expr.get (), ctx)
- : unit_expression (ctx, expr.get_locus ());
+ : unit_expression (expr.get_locus ());
if (expr.has_return_expr ())
{
}
rust_assert (tyty->is_unit ());
- translated = unit_expression (ctx, struct_expr.get_locus ());
+ translated = unit_expression (struct_expr.get_locus ());
}
void
{
ctx->add_statement (init_expr);
- auto unit_type_init_expr = unit_expression (ctx, rval_locus);
+ auto unit_type_init_expr = unit_expression (rval_locus);
auto s = Backend::init_statement (fnctx.fndecl, var, unit_type_init_expr);
ctx->add_statement (s);
}
TyTy::ADTType *adt = static_cast<TyTy::ADTType *> (lookup);
if (adt->is_unit ())
- return unit_expression (ctx, expr_locus);
+ return unit_expression (expr_locus);
if (!adt->is_enum ())
return error_mark_node;
// see: gcc/c/c-decl.cc:8230-8241
// https://github.com/Rust-GCC/gccrs/blob/0024bc2f028369b871a65ceb11b2fddfb0f9c3aa/gcc/c/c-decl.c#L8229-L8241
tree
-TyTyResolveCompile::get_implicit_enumeral_node_type (Context *ctx)
+TyTyResolveCompile::get_implicit_enumeral_node_type ()
{
// static tree enum_node = NULL_TREE;
// if (enum_node == NULL_TREE)
}
tree
-TyTyResolveCompile::get_unit_type (Context *ctx)
+TyTyResolveCompile::get_unit_type ()
{
static tree unit_type;
if (unit_type == nullptr)
// add in the qualifier field for the variant
tree enumeral_type
- = TyTyResolveCompile::get_implicit_enumeral_node_type (ctx);
+ = TyTyResolveCompile::get_implicit_enumeral_node_type ();
Backend::typed_identifier f (RUST_ENUM_DISR_FIELD_NAME, enumeral_type,
ctx->get_mappings ().lookup_location (
variant->get_id ()));
{
if (type.num_fields () == 0)
{
- translated = get_unit_type (ctx);
+ translated = get_unit_type ();
return;
}
void
TyTyResolveCompile::visit (const TyTy::NeverType &)
{
- translated = get_unit_type (ctx);
+ translated = get_unit_type ();
}
void
static tree compile (Context *ctx, const TyTy::BaseType *ty,
bool trait_object_mode = false);
- static tree get_implicit_enumeral_node_type (Context *ctx);
+ static tree get_implicit_enumeral_node_type ();
- static tree get_unit_type (Context *ctx);
+ static tree get_unit_type ();
void visit (const TyTy::InferType &) override;
void visit (const TyTy::ADTType &) override;