~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/InitializerListType.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
7
 *
 
8
 * Contributors:
 
9
 *    Markus Schorn - initial API and implementation
 
10
 *******************************************************************************/ 
 
11
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
 
12
 
 
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;
 
18
 
 
19
/**
 
20
 * Wrapper for initializer lists to allow for participation in the overload resolution.
 
21
 */
 
22
class InitializerListType implements IType {
 
23
 
 
24
        private final ICPPASTInitializerList fInitializerList;
 
25
        private IType[] fExpressionTypes;
 
26
        private ValueCategory[] fLValues;
 
27
 
 
28
        public InitializerListType(ICPPASTInitializerList list) {
 
29
                fInitializerList= list;
 
30
        }
 
31
 
 
32
        public boolean isSameType(IType type) {
 
33
                return false;
 
34
        }
 
35
 
 
36
        @Override
 
37
        public Object clone() {
 
38
                try {
 
39
                        return super.clone();
 
40
                } catch (CloneNotSupportedException e) {
 
41
                        // Will not happen, we IType extends Clonable.
 
42
                        return null;
 
43
                }
 
44
        }
 
45
 
 
46
        public ICPPASTInitializerList getInitializerList() {
 
47
                return fInitializerList;
 
48
        }
 
49
 
 
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);
 
60
                                } else {
 
61
                                        assert false;
 
62
                                }
 
63
                        }
 
64
                }
 
65
                return fExpressionTypes;
 
66
        }
 
67
 
 
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();
 
76
                                } 
 
77
                        }
 
78
                }
 
79
                return fLValues;
 
80
        }
 
81
}