aboutsummaryrefslogtreecommitdiff
path: root/gcjx/model/arrayinit.cc
blob: 27c188b06a6bc7d36f16fa90570cda64ef809270 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Array initializers.

// Copyright (C) 2004 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
// gcjx is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// gcjx is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with gcjx; see the file COPYING.LIB.  If
// not, write to the Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#include "typedefs.hh"

void
model_array_initializer::resolve (resolution_scope *scope)
{
  element_type->resolve (scope);
  model_type *ct = element_type->type ();
  for (std::list<ref_expression>::iterator i = initializers.begin ();
       i != initializers.end ();
       ++i)
    {
      (*i)->resolve (scope);
      if (assignment_conversion (ct, *i) == NULL)
	std::cerr << (*i)->error ("expression in array initializer of "
				  "type %1 can't be converted to element "
				  "type %2 by assignment")
	  % (*i)->type () % ct;
      fold (*i);
    }
  set_type (ct->array ());
}

void
model_array_initializer::visit (visitor *v)
{
  v->visit_array_initializer (this, element_type, initializers);
}

void
model_array_initializer::already_resolved ()
{
  assert (element_type->type () != NULL);
  set_type (element_type->type ());
}



void
model_annotation_initializer::resolve (resolution_scope *scope)
{
  // Just resolve and fold the elements.  Whether the elements are
  // actually commensurate with the annotation type is handled
  // elsewhere.
  for (std::list<ref_expression>::iterator i = initializers.begin ();
       i != initializers.end ();
       ++i)
    {
      (*i)->resolve (scope);
      fold (*i);
    }
}

void
model_annotation_initializer::visit (visitor *v)
{
  v->visit_annotation_initializer (this, element_type, initializers);
}

void
model_annotation_initializer::set_actual_type (model_type *t)
{
  set_type (t);
}