1
/*******************************************************************************
2
* Copyright (c) 2010 Wind River Systems, Inc. and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Markus Schorn - initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
13
import org.eclipse.cdt.core.dom.ast.IASTExpression;
14
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
15
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
16
import org.eclipse.cdt.core.dom.ast.IType;
17
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
20
* Wrapper for initializer lists to allow for participation in the overload resolution.
22
class InitializerListType implements IType {
24
private final ICPPASTInitializerList fInitializerList;
25
private IType[] fExpressionTypes;
26
private ValueCategory[] fLValues;
28
public InitializerListType(ICPPASTInitializerList list) {
29
fInitializerList= list;
32
public boolean isSameType(IType type) {
37
public Object clone() {
40
} catch (CloneNotSupportedException e) {
41
// Will not happen, we IType extends Clonable.
46
public ICPPASTInitializerList getInitializerList() {
47
return fInitializerList;
50
public IType[] getExpressionTypes() {
51
if (fExpressionTypes == null) {
52
final IASTInitializerClause[] clauses = fInitializerList.getClauses();
53
fExpressionTypes= new IType[clauses.length];
54
for (int i = 0; i < clauses.length; i++) {
55
IASTInitializerClause clause = clauses[i];
56
if (clause instanceof IASTExpression) {
57
fExpressionTypes[i]= ((IASTExpression) clause).getExpressionType();
58
} else if (clause instanceof ICPPASTInitializerList) {
59
fExpressionTypes[i]= new InitializerListType((ICPPASTInitializerList) clause);
65
return fExpressionTypes;
68
public ValueCategory[] getValueCategories() {
69
if (fLValues == null) {
70
final IASTInitializerClause[] clauses = fInitializerList.getClauses();
71
fLValues= new ValueCategory[clauses.length];
72
for (int i = 0; i < clauses.length; i++) {
73
IASTInitializerClause clause = clauses[i];
74
if (clause instanceof IASTExpression) {
75
fLValues[i]= ((IASTExpression) clause).getValueCategory();