diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-05-06 18:30:11 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-05-06 18:30:11 +0000 |
commit | 1f94e0c6f7f5b1066ecb949efa24303719a65278 (patch) | |
tree | c18af34edf1fff20f42a2c6e71229c91f0d3bd97 /gcc | |
parent | 2e8d9212daaa8c6162ab872485dd03d28c96ea4c (diff) | |
download | gcc-1f94e0c6f7f5b1066ecb949efa24303719a65278.zip gcc-1f94e0c6f7f5b1066ecb949efa24303719a65278.tar.gz gcc-1f94e0c6f7f5b1066ecb949efa24303719a65278.tar.bz2 |
Use backend interface for string types.
From-SVN: r173502
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/types.cc | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index a03ab1f..fe96741 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -2172,14 +2172,27 @@ Type::lookup_complex_type(const char* name) // struct with two fields: a pointer to the characters and a length. tree -String_type::do_get_tree(Gogo*) -{ - static tree struct_type; - return Gogo::builtin_struct(&struct_type, "__go_string", NULL_TREE, 2, - "__data", - build_pointer_type(unsigned_char_type_node), - "__length", - integer_type_node); +String_type::do_get_tree(Gogo* gogo) +{ + static Btype* backend_string_type; + if (backend_string_type == NULL) + { + std::vector<Backend::Btyped_identifier> fields(2); + + Type* b = gogo->lookup_global("byte")->type_value(); + Type* pb = Type::make_pointer_type(b); + fields[0].name = "__data"; + fields[0].btype = tree_to_type(pb->get_tree(gogo)); + fields[0].location = UNKNOWN_LOCATION; + + Type* int_type = Type::lookup_integer_type("int"); + fields[1].name = "__length"; + fields[1].btype = tree_to_type(int_type->get_tree(gogo)); + fields[1].location = UNKNOWN_LOCATION; + + backend_string_type = gogo->backend()->struct_type(fields); + } + return type_to_tree(backend_string_type); } // Return a tree for the length of STRING. |