CACAO
typecheck-multianewarray.inc
Go to the documentation of this file.
1 /* src/vm/jit/verify/typecheck-multianewarray.inc - type checking for MULTIANEWARRAY
2 
3  Copyright (C) 1996-2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23  Contact: cacao@cacaojvm.org
24 
25  Authors: Edwin Steiner
26 
27 
28 */
29 
30 
31 {
32  classinfo *arrayclass;
33  arraydescriptor *desc;
34  s4 i;
35 
36  /* check the array lengths on the stack */
37  i = state->iptr->s1.argcount;
38 
39 #if !defined(TYPECHECK_TYPEINFERER)
40  if (i < 1)
41  VERIFY_ERROR("Illegal dimension argument");
42 
43  while (i--) {
44  TYPECHECK_INT(state->iptr->sx.s23.s2.args[i]);
45  }
46 #endif /* !defined(TYPECHECK_TYPEINFERER) */
47 
48  /* check array descriptor */
49  if (INSTRUCTION_IS_RESOLVED(state->iptr)) {
50  /* the array class reference has already been resolved */
51  arrayclass = state->iptr->sx.s23.s3.c.cls;
52  if (!arrayclass)
53  VERIFY_ERROR("MULTIANEWARRAY with unlinked class");
54  if ((desc = arrayclass->vftbl->arraydesc) == NULL)
55  VERIFY_ERROR("MULTIANEWARRAY with non-array class");
56  if (desc->dimension < state->iptr->s1.argcount)
57  VERIFY_ERROR("MULTIANEWARRAY dimension to high");
58 
59  /* set the array type of the result */
60  dv->typeinfo.init_class(arrayclass);
61  }
62  else {
63  const char *p;
65 
66  /* the array class reference is still unresolved */
67  /* check that the reference indicates an array class of correct dimension */
68  cr = state->iptr->sx.s23.s3.c.ref;
69  i = 0;
70  p = cr->name.begin();
71  while (p[i] == '[')
72  i++;
73  /* { the dimension of the array class == i } */
74 #if !defined(TYPECHECK_TYPEINFERER)
75  if (i < 1)
76  VERIFY_ERROR("MULTIANEWARRAY with non-array class");
77  if (i < state->iptr->s1.argcount)
78  VERIFY_ERROR("MULTIANEWARRAY dimension to high");
79 #endif /* !defined(TYPECHECK_TYPEINFERER) */
80 
81  /* set the array type of the result */
82  if (!dv->typeinfo.init_class(cr))
83  return false;
84  }
85 
86  /* set return type */
87 
88  dv->type = TYPE_ADR;
89 }
90 
91 
92 /*
93  * These are local overrides for various environment variables in Emacs.
94  * Please do not remove this and leave it at the end of the file, where
95  * Emacs will automagically detect them.
96  * ---------------------------------------------------------------------
97  * Local variables:
98  * mode: c
99  * indent-tabs-mode: t
100  * c-basic-offset: 4
101  * tab-width: 4
102  * End:
103  * vim:noexpandtab:sw=4:ts=4:filetype=c:
104  */
#define VERIFY_ERROR(msg)
MIIterator i
int32_t s4
Definition: types.hpp:45
arraydescriptor * arraydesc
Definition: vftbl.hpp:101
vftbl_t * vftbl
Definition: class.hpp:121
byte_iterator begin() const
Definition: utf8.hpp:106
#define INSTRUCTION_IS_RESOLVED(iptr)
const Utf8String name
Definition: references.hpp:48
#define TYPECHECK_INT(s)