Skip to main content
summaryrefslogtreecommitdiffstats
blob: 5c41bb31f28744e8bac0f724dfa728785bd43a27 (plain) (blame)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*******************************************************************************
 * Copyright (c) 2013 Nathan Ridge.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Nathan Ridge
 *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;

import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.core.runtime.PlatformObject;

/**
 * A specialization of a template parameter.
 *
 * This class provides common implementation for CPPTemplateNonTypeParameterSpecialization,
 * CPPTemplateTypeParameterSpecialization, and CPPTemplateTemplateParameterSpecialization.
 */
public abstract class CPPTemplateParameterSpecialization extends PlatformObject
		implements ICPPTemplateParameter, ICPPSpecialization {
	private final ICPPSpecialization fOwner;
	private final ICPPScope fScope;
	private final ICPPTemplateParameter fSpecialized;
	private final ICPPTemplateParameterMap fTemplateParameterMap;
	private final ICPPTemplateArgument fDefaultValue;

	public CPPTemplateParameterSpecialization(ICPPSpecialization owner, ICPPScope scope, ICPPTemplateParameter specialized,
			ICPPTemplateArgument defaultValue) {
		fOwner = owner;
		fScope = scope;
		fSpecialized = specialized;
		fTemplateParameterMap = owner.getTemplateParameterMap();
		fDefaultValue = defaultValue;
	}

	@Override
	public String[] getQualifiedName() throws DOMException {
		return fSpecialized.getQualifiedName();
	}

	@Override
	public char[][] getQualifiedNameCharArray() throws DOMException {
		return fSpecialized.getQualifiedNameCharArray();
	}

	@Override
	public boolean isGloballyQualified() throws DOMException {
		return false;
	}

	@Override
	public String getName() {
		return fSpecialized.getName();
	}

	@Override
	public char[] getNameCharArray() {
		return fSpecialized.getNameCharArray();
	}

	@Override
	public ILinkage getLinkage() {
		return Linkage.CPP_LINKAGE;
	}

	@Override
	public ICPPSpecialization getOwner() {
		return fOwner;
	}

	@Override
	public ICPPScope getScope() throws DOMException {
		return fScope;
	}

	@Override
	public ICPPTemplateParameter getSpecializedBinding() {
		return fSpecialized;
	}

	@Override
	public ICPPTemplateParameterMap getTemplateParameterMap() {
		return fTemplateParameterMap;
	}

	@Override
	@Deprecated
	public ObjectMap getArgumentMap() {
		return CPPTemplates.getArgumentMap(this, getTemplateParameterMap());
	}

	@Override
	public short getParameterPosition() {
		return fSpecialized.getParameterPosition();
	}

	@Override
	public short getTemplateNestingLevel() {
		return fSpecialized.getTemplateNestingLevel();
	}

	@Override
	public int getParameterID() {
		return fSpecialized.getParameterID();
	}

	@Override
	public ICPPTemplateArgument getDefaultValue() {
		return fDefaultValue;
	}

	@Override
	public boolean isParameterPack() {
		return fSpecialized.isParameterPack();
	}
}

Back to the top