summaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/expressions.cc26
-rw-r--r--gcc/go/gofrontend/types.cc33
3 files changed, 48 insertions, 13 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 6fcd18593a6..8d3547b3295 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-11e249a59e8c627fe9c2938c38e39cb1efefb1fb
+57da43e8159bfe1a31e49683c371cf36e2fb6051
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 0d25dda1f44..c9750bd0aee 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -1197,19 +1197,29 @@ Func_descriptor_expression::do_get_backend(Translate_context* context)
Gogo* gogo = context->gogo();
std::string var_name;
- if (no->package() == NULL)
- var_name = gogo->pkgpath_symbol();
+ bool is_descriptor = false;
+ if (no->is_function_declaration()
+ && !no->func_declaration_value()->asm_name().empty()
+ && Linemap::is_predeclared_location(no->location()))
+ {
+ var_name = no->func_declaration_value()->asm_name() + "_descriptor";
+ is_descriptor = true;
+ }
else
- var_name = no->package()->pkgpath_symbol();
- var_name.push_back('.');
- var_name.append(Gogo::unpack_hidden_name(no->name()));
- var_name.append("$descriptor");
+ {
+ if (no->package() == NULL)
+ var_name = gogo->pkgpath_symbol();
+ else
+ var_name = no->package()->pkgpath_symbol();
+ var_name.push_back('.');
+ var_name.append(Gogo::unpack_hidden_name(no->name()));
+ var_name.append("$descriptor");
+ }
Btype* btype = this->type()->get_backend(gogo);
Bvariable* bvar;
- if (no->package() != NULL
- || Linemap::is_predeclared_location(no->location()))
+ if (no->package() != NULL || is_descriptor)
bvar = context->backend()->immutable_struct_reference(var_name, btype,
loc);
else
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index dcc6bc829c6..5c8950a028b 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -1474,6 +1474,27 @@ Type::make_type_descriptor_type()
Type* void_type = Type::make_void_type();
Type* unsafe_pointer_type = Type::make_pointer_type(void_type);
+ Typed_identifier_list *params = new Typed_identifier_list();
+ params->push_back(Typed_identifier("key", unsafe_pointer_type, bloc));
+ params->push_back(Typed_identifier("key_size", uintptr_type, bloc));
+
+ Typed_identifier_list* results = new Typed_identifier_list();
+ results->push_back(Typed_identifier("", uintptr_type, bloc));
+
+ Type* hash_fntype = Type::make_function_type(NULL, params, results,
+ bloc);
+
+ params = new Typed_identifier_list();
+ params->push_back(Typed_identifier("key1", unsafe_pointer_type, bloc));
+ params->push_back(Typed_identifier("key2", unsafe_pointer_type, bloc));
+ params->push_back(Typed_identifier("key_size", uintptr_type, bloc));
+
+ results = new Typed_identifier_list();
+ results->push_back(Typed_identifier("", Type::lookup_bool_type(), bloc));
+
+ Type* equal_fntype = Type::make_function_type(NULL, params, results,
+ bloc);
+
// Forward declaration for the type descriptor type.
Named_object* named_type_descriptor_type =
Named_object::make_type_declaration("commonType", NULL, bloc);
@@ -1514,8 +1535,8 @@ Type::make_type_descriptor_type()
"fieldAlign", uint8_type,
"size", uintptr_type,
"hash", uint32_type,
- "hashfn", uintptr_type,
- "equalfn", uintptr_type,
+ "hashfn", hash_fntype,
+ "equalfn", equal_fntype,
"gc", uintptr_type,
"string", pointer_string_type,
"", pointer_uncommon_type,
@@ -1852,6 +1873,10 @@ Type::write_specific_type_functions(Gogo* gogo, Named_type* name,
gogo->add_block(b, bloc);
gogo->lower_block(equal_fn, b);
gogo->finish_function(bloc);
+
+ // Build the function descriptors for the type descriptor to refer to.
+ hash_fn->func_value()->descriptor(gogo, hash_fn);
+ equal_fn->func_value()->descriptor(gogo, equal_fn);
}
// Write a hash function that simply calls the hash function for a
@@ -2009,8 +2034,8 @@ Type::type_descriptor_constructor(Gogo* gogo, int runtime_type_kind,
Named_object* equal_fn;
this->type_functions(gogo, name, hash_fntype, equal_fntype, &hash_fn,
&equal_fn);
- vals->push_back(Expression::make_func_code_reference(hash_fn, bloc));
- vals->push_back(Expression::make_func_code_reference(equal_fn, bloc));
+ vals->push_back(Expression::make_func_reference(hash_fn, NULL, bloc));
+ vals->push_back(Expression::make_func_reference(equal_fn, NULL, bloc));
++p;
go_assert(p->is_field_name("gc"));