aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-expr.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.h')
-rw-r--r--gcc/rust/backend/rust-compile-expr.h105
1 files changed, 1 insertions, 104 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h
index 5464c88..4cc4dfc 100644
--- a/gcc/rust/backend/rust-compile-expr.h
+++ b/gcc/rust/backend/rust-compile-expr.h
@@ -127,110 +127,7 @@ public:
void visit (HIR::MethodCallExpr &expr) override;
- void visit (HIR::IdentifierExpr &expr) override
- {
- NodeId ast_node_id = expr.get_mappings ().get_nodeid ();
-
- bool is_value = false;
- NodeId ref_node_id = UNKNOWN_NODEID;
- if (ctx->get_resolver ()->lookup_resolved_name (ast_node_id, &ref_node_id))
- {
- // these ref_node_ids will resolve to a pattern declaration but we are
- // interested in the definition that this refers to get the parent id
- Resolver::Definition def;
- if (!ctx->get_resolver ()->lookup_definition (ref_node_id, &def))
- {
- rust_error_at (expr.get_locus (),
- "unknown reference for resolved name");
- return;
- }
- ref_node_id = def.parent;
- is_value = true;
- }
- else if (!ctx->get_resolver ()->lookup_resolved_type (ast_node_id,
- &ref_node_id))
- {
- rust_error_at (expr.get_locus (),
- "Failed to lookup type reference for node: %s",
- expr.as_string ().c_str ());
- return;
- }
-
- if (ref_node_id == UNKNOWN_NODEID)
- {
- rust_fatal_error (expr.get_locus (), "unresolved IdentifierExpr: %s",
- expr.as_string ().c_str ());
- return;
- }
-
- // node back to HIR
- HirId ref;
- if (!ctx->get_mappings ()->lookup_node_to_hir (
- expr.get_mappings ().get_crate_num (), ref_node_id, &ref))
- {
- rust_error_at (expr.get_locus (), "reverse lookup failure");
- return;
- }
-
- TyTy::BaseType *lookup = nullptr;
- if (!ctx->get_tyctx ()->lookup_type (ref, &lookup))
- {
- rust_fatal_error (expr.get_locus (),
- "failed to find type relevant to this context: %s",
- expr.get_mappings ().as_string ().c_str ());
- return;
- }
-
- bool is_type_ref = !is_value;
- if (is_type_ref)
- {
- // this might be a case for
- //
- // struct S;
- //
- // fn main() {
- // let s = S;
- // }
-
- if (lookup->is_unit ())
- {
- translated = ctx->get_backend ()->unit_expression ();
- return;
- }
-
- // rust actually treats like this an fn call or structs with fields but
- // unit structs are just the struct name lets catch it with an is-unit
- // check
- gcc_unreachable ();
- }
-
- tree fn = NULL_TREE;
- Bvariable *var = nullptr;
- if (ctx->lookup_const_decl (ref, &translated))
- {
- return;
- }
- else if (ctx->lookup_function_decl (ref, &fn))
- {
- translated
- = ctx->get_backend ()->function_code_expression (fn,
- expr.get_locus ());
- }
- else if (ctx->lookup_var_decl (ref, &var))
- {
- translated
- = ctx->get_backend ()->var_expression (var, expr.get_locus ());
- }
- else if (ctx->lookup_pattern_binding (ref, &translated))
- {
- return;
- }
- else
- {
- rust_fatal_error (expr.get_locus (),
- "failed to lookup compiled reference");
- }
- }
+ void visit (HIR::IdentifierExpr &expr) override;
void visit (HIR::LiteralExpr &expr) override
{