Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
b7190f2f
Commit
b7190f2f
authored
Oct 24, 2011
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename is_open_array_type to is_slice_type.
From-SVN: r180361
parent
bb12a72a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
38 deletions
+37
-38
gcc/go/gofrontend/expressions.cc
+22
-23
gcc/go/gofrontend/gogo.cc
+1
-1
gcc/go/gofrontend/statements.cc
+2
-2
gcc/go/gofrontend/types.cc
+10
-10
gcc/go/gofrontend/types.h
+2
-2
No files found.
gcc/go/gofrontend/expressions.cc
View file @
b7190f2f
...
...
@@ -234,8 +234,7 @@ Expression::convert_for_assignment(Translate_context* context, Type* lhs_type,
else
if
(
rhs_type
->
interface_type
()
!=
NULL
)
return
Expression
::
convert_interface_to_type
(
context
,
lhs_type
,
rhs_type
,
rhs_tree
,
location
);
else
if
(
lhs_type
->
is_open_array_type
()
&&
rhs_type
->
is_nil_type
())
else
if
(
lhs_type
->
is_slice_type
()
&&
rhs_type
->
is_nil_type
())
{
// Assigning nil to an open array.
go_assert
(
TREE_CODE
(
lhs_type_tree
)
==
RECORD_TYPE
);
...
...
@@ -3315,7 +3314,7 @@ Type_conversion_expression::do_lower(Gogo*, Named_object*,
mpfr_clear
(
imag
);
}
if
(
type
->
is_
open_array
_type
()
&&
type
->
named_type
()
==
NULL
)
if
(
type
->
is_
slice
_type
()
&&
type
->
named_type
()
==
NULL
)
{
Type
*
element_type
=
type
->
array_type
()
->
element_type
()
->
forwarded
();
bool
is_byte
=
element_type
==
Type
::
lookup_integer_type
(
"uint8"
);
...
...
@@ -3663,7 +3662,7 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
len
);
}
}
else
if
(
type
->
is_
open_array
_type
()
&&
expr_type
->
is_string_type
())
else
if
(
type
->
is_
slice
_type
()
&&
expr_type
->
is_string_type
())
{
Type
*
e
=
type
->
array_type
()
->
element_type
()
->
forwarded
();
go_assert
(
e
->
integer_type
()
!=
NULL
);
...
...
@@ -3831,9 +3830,9 @@ Unsafe_type_conversion_expression::do_get_tree(Translate_context* context)
source_location
loc
=
this
->
location
();
bool
use_view_convert
=
false
;
if
(
t
->
is_
open_array
_type
())
if
(
t
->
is_
slice
_type
())
{
go_assert
(
et
->
is_
open_array
_type
());
go_assert
(
et
->
is_
slice
_type
());
use_view_convert
=
true
;
}
else
if
(
t
->
map_type
()
!=
NULL
)
...
...
@@ -7302,7 +7301,7 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
if
(
args
==
NULL
||
args
->
empty
())
return
this
;
Type
*
slice_type
=
args
->
front
()
->
type
();
if
(
!
slice_type
->
is_
open_array
_type
())
if
(
!
slice_type
->
is_
slice
_type
())
{
error_at
(
args
->
front
()
->
location
(),
"argument 1 must be a slice"
);
this
->
set_is_error
();
...
...
@@ -7342,7 +7341,7 @@ Builtin_call_expression::lower_make()
bool
is_slice
=
false
;
bool
is_map
=
false
;
bool
is_chan
=
false
;
if
(
type
->
is_
open_array
_type
())
if
(
type
->
is_
slice
_type
())
is_slice
=
true
;
else
if
(
type
->
map_type
()
!=
NULL
)
is_map
=
true
;
...
...
@@ -7554,7 +7553,7 @@ Builtin_call_expression::do_is_constant() const
if
(
arg_type
->
points_to
()
!=
NULL
&&
arg_type
->
points_to
()
->
array_type
()
!=
NULL
&&
!
arg_type
->
points_to
()
->
is_
open_array
_type
())
&&
!
arg_type
->
points_to
()
->
is_
slice
_type
())
arg_type
=
arg_type
->
points_to
();
if
(
arg_type
->
array_type
()
!=
NULL
...
...
@@ -7633,7 +7632,7 @@ Builtin_call_expression::do_integer_constant_value(bool iota_is_constant,
if
(
arg_type
->
points_to
()
!=
NULL
&&
arg_type
->
points_to
()
->
array_type
()
!=
NULL
&&
!
arg_type
->
points_to
()
->
is_
open_array
_type
())
&&
!
arg_type
->
points_to
()
->
is_
slice
_type
())
arg_type
=
arg_type
->
points_to
();
if
(
arg_type
->
array_type
()
!=
NULL
...
...
@@ -8080,7 +8079,7 @@ Builtin_call_expression::do_check_types(Gogo*)
Type
*
arg_type
=
this
->
one_arg
()
->
type
();
if
(
arg_type
->
points_to
()
!=
NULL
&&
arg_type
->
points_to
()
->
array_type
()
!=
NULL
&&
!
arg_type
->
points_to
()
->
is_
open_array
_type
())
&&
!
arg_type
->
points_to
()
->
is_
slice
_type
())
arg_type
=
arg_type
->
points_to
();
if
(
this
->
code_
==
BUILTIN_CAP
)
{
...
...
@@ -8135,7 +8134,7 @@ Builtin_call_expression::do_check_types(Gogo*)
||
type
->
channel_type
()
!=
NULL
||
type
->
map_type
()
!=
NULL
||
type
->
function_type
()
!=
NULL
||
type
->
is_
open_array
_type
())
||
type
->
is_
slice
_type
())
;
else
this
->
report_error
(
_
(
"unsupported argument type to "
...
...
@@ -8192,7 +8191,7 @@ Builtin_call_expression::do_check_types(Gogo*)
break
;
Type
*
e1
;
if
(
arg1_type
->
is_
open_array
_type
())
if
(
arg1_type
->
is_
slice
_type
())
e1
=
arg1_type
->
array_type
()
->
element_type
();
else
{
...
...
@@ -8201,7 +8200,7 @@ Builtin_call_expression::do_check_types(Gogo*)
}
Type
*
e2
;
if
(
arg2_type
->
is_
open_array
_type
())
if
(
arg2_type
->
is_
slice
_type
())
e2
=
arg2_type
->
array_type
()
->
element_type
();
else
if
(
arg2_type
->
is_string_type
())
e2
=
Type
::
lookup_integer_type
(
"uint8"
);
...
...
@@ -8321,7 +8320,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
{
arg_type
=
arg_type
->
points_to
();
go_assert
(
arg_type
->
array_type
()
!=
NULL
&&
!
arg_type
->
is_
open_array
_type
());
&&
!
arg_type
->
is_
slice
_type
());
go_assert
(
POINTER_TYPE_P
(
TREE_TYPE
(
arg_tree
)));
arg_tree
=
build_fold_indirect_ref
(
arg_tree
);
}
...
...
@@ -8515,7 +8514,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
fnname
=
"__go_print_interface"
;
}
}
else
if
(
type
->
is_
open_array
_type
())
else
if
(
type
->
is_
slice
_type
())
{
static
tree
print_slice_fndecl
;
pfndecl
=
&
print_slice_fndecl
;
...
...
@@ -8694,7 +8693,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
Type
*
arg2_type
=
arg2
->
type
();
tree
arg2_val
;
tree
arg2_len
;
if
(
arg2_type
->
is_
open_array
_type
())
if
(
arg2_type
->
is_
slice
_type
())
{
at
=
arg2_type
->
array_type
();
arg2_tree
=
save_expr
(
arg2_tree
);
...
...
@@ -9078,7 +9077,7 @@ Call_expression::lower_varargs(Gogo* gogo, Named_object* function,
source_location
loc
=
this
->
location
();
go_assert
(
param_count
>
0
);
go_assert
(
varargs_type
->
is_
open_array
_type
());
go_assert
(
varargs_type
->
is_
slice
_type
());
size_t
arg_count
=
this
->
args_
==
NULL
?
0
:
this
->
args_
->
size
();
if
(
arg_count
<
param_count
-
1
)
...
...
@@ -9903,7 +9902,7 @@ Index_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
return
Expression
::
make_array_index
(
left
,
start
,
end
,
location
);
else
if
(
type
->
points_to
()
!=
NULL
&&
type
->
points_to
()
->
array_type
()
!=
NULL
&&
!
type
->
points_to
()
->
is_
open_array
_type
())
&&
!
type
->
points_to
()
->
is_
slice
_type
())
{
Expression
*
deref
=
Expression
::
make_unary
(
OPERATOR_MULT
,
left
,
location
);
...
...
@@ -10060,7 +10059,7 @@ Array_index_expression::do_type()
this
->
type_
=
Type
::
make_error_type
();
else
if
(
this
->
end_
==
NULL
)
this
->
type_
=
type
->
element_type
();
else
if
(
type
->
is_
open_array
_type
())
else
if
(
type
->
is_
slice
_type
())
{
// A slice of a slice has the same type as the original
// slice.
...
...
@@ -10150,7 +10149,7 @@ Array_index_expression::do_check_types(Gogo*)
// A slice of an array requires an addressable array. A slice of a
// slice is always possible.
if
(
this
->
end_
!=
NULL
&&
!
array_type
->
is_
open_array
_type
())
if
(
this
->
end_
!=
NULL
&&
!
array_type
->
is_
slice
_type
())
{
if
(
!
this
->
array_
->
is_addressable
())
this
->
report_error
(
_
(
"array is not addressable"
));
...
...
@@ -10169,7 +10168,7 @@ Array_index_expression::do_is_addressable() const
return
false
;
// An index into a slice is addressable.
if
(
this
->
array_
->
type
()
->
is_
open_array
_type
())
if
(
this
->
array_
->
type
()
->
is_
slice
_type
())
return
true
;
// An index into an array is addressable if the array is
...
...
@@ -12234,7 +12233,7 @@ Expression*
Expression
::
make_slice_composite_literal
(
Type
*
type
,
Expression_list
*
vals
,
source_location
location
)
{
go_assert
(
type
->
is_
open_array
_type
());
go_assert
(
type
->
is_
slice
_type
());
return
new
Open_array_construction_expression
(
type
,
vals
,
location
);
}
...
...
gcc/go/gofrontend/gogo.cc
View file @
b7190f2f
...
...
@@ -3662,7 +3662,7 @@ Variable::type_from_range(Expression* expr, bool get_index_type,
if
(
t
->
array_type
()
!=
NULL
||
(
t
->
points_to
()
!=
NULL
&&
t
->
points_to
()
->
array_type
()
!=
NULL
&&
!
t
->
points_to
()
->
is_
open_array
_type
()))
&&
!
t
->
points_to
()
->
is_
slice
_type
()))
{
if
(
get_index_type
)
return
Type
::
lookup_integer_type
(
"int"
);
...
...
gcc/go/gofrontend/statements.cc
View file @
b7190f2f
...
...
@@ -4319,7 +4319,7 @@ Send_statement::do_get_backend(Translate_context* context)
case
Type
:
:
TYPE_ARRAY
:
is_small
=
false
;
can_take_address
=
!
element_type
->
is_
open_array
_type
();
can_take_address
=
!
element_type
->
is_
slice
_type
();
break
;
default
:
...
...
@@ -5181,7 +5181,7 @@ For_range_statement::do_lower(Gogo* gogo, Named_object*, Block* enclosing,
Type
*
range_type
=
this
->
range_
->
type
();
if
(
range_type
->
points_to
()
!=
NULL
&&
range_type
->
points_to
()
->
array_type
()
!=
NULL
&&
!
range_type
->
points_to
()
->
is_
open_array
_type
())
&&
!
range_type
->
points_to
()
->
is_
slice
_type
())
range_type
=
range_type
->
points_to
();
Type
*
index_type
;
...
...
gcc/go/gofrontend/types.cc
View file @
b7190f2f
...
...
@@ -240,7 +240,7 @@ Type::points_to() const
// Return whether this is an open array type.
bool
Type
::
is_
open_array
_type
()
const
Type
::
is_
slice
_type
()
const
{
return
this
->
array_type
()
!=
NULL
&&
this
->
array_type
()
->
length
()
==
NULL
;
}
...
...
@@ -457,7 +457,7 @@ Type::are_compatible_for_binop(const Type* lhs, const Type* rhs)
if
(
lhs
->
is_nil_type
()
&&
(
rhs
->
points_to
()
!=
NULL
||
rhs
->
interface_type
()
!=
NULL
||
rhs
->
is_
open_array
_type
()
||
rhs
->
is_
slice
_type
()
||
rhs
->
map_type
()
!=
NULL
||
rhs
->
channel_type
()
!=
NULL
||
rhs
->
function_type
()
!=
NULL
))
...
...
@@ -465,7 +465,7 @@ Type::are_compatible_for_binop(const Type* lhs, const Type* rhs)
if
(
rhs
->
is_nil_type
()
&&
(
lhs
->
points_to
()
!=
NULL
||
lhs
->
interface_type
()
!=
NULL
||
lhs
->
is_
open_array
_type
()
||
lhs
->
is_
slice
_type
()
||
lhs
->
map_type
()
!=
NULL
||
lhs
->
channel_type
()
!=
NULL
||
lhs
->
function_type
()
!=
NULL
))
...
...
@@ -556,7 +556,7 @@ Type::are_assignable_check_hidden(const Type* lhs, const Type* rhs,
if
(
rhs
->
is_nil_type
()
&&
(
lhs
->
points_to
()
!=
NULL
||
lhs
->
function_type
()
!=
NULL
||
lhs
->
is_
open_array
_type
()
||
lhs
->
is_
slice
_type
()
||
lhs
->
map_type
()
!=
NULL
||
lhs
->
channel_type
()
!=
NULL
||
lhs
->
interface_type
()
!=
NULL
))
...
...
@@ -662,7 +662,7 @@ Type::are_convertible(const Type* lhs, const Type* rhs, std::string* reason)
{
if
(
rhs
->
integer_type
()
!=
NULL
)
return
true
;
if
(
rhs
->
is_
open_array
_type
()
&&
rhs
->
named_type
()
==
NULL
)
if
(
rhs
->
is_
slice
_type
()
&&
rhs
->
named_type
()
==
NULL
)
{
const
Type
*
e
=
rhs
->
array_type
()
->
element_type
()
->
forwarded
();
if
(
e
->
integer_type
()
!=
NULL
...
...
@@ -674,7 +674,7 @@ Type::are_convertible(const Type* lhs, const Type* rhs, std::string* reason)
// A string may be converted to []byte or []int.
if
(
rhs
->
is_string_type
()
&&
lhs
->
is_
open_array
_type
()
&&
lhs
->
is_
slice
_type
()
&&
lhs
->
named_type
()
==
NULL
)
{
const
Type
*
e
=
lhs
->
array_type
()
->
element_type
()
->
forwarded
();
...
...
@@ -6480,7 +6480,7 @@ Find_type_use::type(Type* type)
// essentially a pointer: a pointer, a slice, a function, a map, or
// a channel.
if
(
type
->
points_to
()
!=
NULL
||
type
->
is_
open_array
_type
()
||
type
->
is_
slice
_type
()
||
type
->
function_type
()
!=
NULL
||
type
->
map_type
()
!=
NULL
||
type
->
channel_type
()
!=
NULL
)
...
...
@@ -6699,7 +6699,7 @@ Named_type::convert(Gogo* gogo)
case
TYPE_ARRAY
:
// Slice types were completed in create_placeholder.
if
(
!
base
->
is_
open_array
_type
())
if
(
!
base
->
is_
slice
_type
())
{
Btype
*
bet
=
base
->
array_type
()
->
get_backend_element
(
gogo
);
Bexpression
*
blen
=
base
->
array_type
()
->
get_backend_length
(
gogo
);
...
...
@@ -6789,7 +6789,7 @@ Named_type::create_placeholder(Gogo* gogo)
break
;
case
TYPE_ARRAY
:
if
(
base
->
is_
open_array
_type
())
if
(
base
->
is_
slice
_type
())
bt
=
gogo
->
backend
()
->
placeholder_struct_type
(
this
->
name
(),
this
->
location_
);
else
...
...
@@ -6822,7 +6822,7 @@ Named_type::create_placeholder(Gogo* gogo)
this
->
named_btype_
=
bt
;
if
(
base
->
is_
open_array
_type
())
if
(
base
->
is_
slice
_type
())
{
// We do not record slices as dependencies of other types,
// because we can fill them in completely here with the final
...
...
gcc/go/gofrontend/types.h
View file @
b7190f2f
...
...
@@ -741,9 +741,9 @@ class Type
array_type
()
const
{
return
this
->
convert
<
const
Array_type
,
TYPE_ARRAY
>
();
}
// Return whether if this is a
n open array
type.
// Return whether if this is a
slice
type.
bool
is_
open_array
_type
()
const
;
is_
slice
_type
()
const
;
// If this is a map type, return it. Otherwise, return NULL.
Map_type
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment