1 /*******************************************************************************
2 * Copyright (c) 2011-2012 Ericsson, Ecole Polytechnique de Montreal and others
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 * Contributors: Simon Marchi - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.ctf
.core
.event
.types
;
16 * A CTF array declaration
18 * Arrays are fixed-length. Their length is declared in the type
19 * declaration within the meta-data. They contain an array of "inner type"
20 * elements, which can refer to any type not containing the type of the
21 * array being declared (no circular dependency). The length is the number
22 * of elements in an array.
25 * @author Matthew Khouzam
26 * @author Simon Marchi
28 public class ArrayDeclaration
implements IDeclaration
{
30 // ------------------------------------------------------------------------
32 // ------------------------------------------------------------------------
34 private final int length
;
35 private final IDeclaration elemType
;
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
43 * @param length how many elements in the array
44 * @param elemType what type of element is in the array
46 public ArrayDeclaration(int length
, IDeclaration elemType
) {
48 this.elemType
= elemType
;
51 // ------------------------------------------------------------------------
52 // Getters/Setters/Predicates
53 // ------------------------------------------------------------------------
57 * @return the type of element in the array
59 public IDeclaration
getElementType() {
65 * @return how many elements in the array
67 public int getLength() {
72 public long getAlignment() {
73 return getElementType().getAlignment();
75 // ------------------------------------------------------------------------
77 // ------------------------------------------------------------------------
80 public ArrayDefinition
createDefinition(IDefinitionScope definitionScope
,
82 return new ArrayDefinition(this, definitionScope
, fieldName
);
86 public String
toString() {
87 /* Only used for debugging */
88 return "[declaration] array[" + Integer
.toHexString(hashCode()) + ']'; //$NON-NLS-1$