Skip to main content
summaryrefslogtreecommitdiffstats
blob: de8049eb2ba72ea38c2892ff882014b60b0c0569 (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
/*******************************************************************************
 * Copyright (c) 2013 Nathan Ridge.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Nathan Ridge
 *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;

import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
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.ICPPTemplateNonTypeParameter;

/**
 * A specialization of a non-type template parameter. This is needed when a nested template
 * has a non-type template parameter whose type or default value is dependent on a template
 * parameter of an enclosing template.
 *
 * This class can represent a specialization of either an AST or a PDOM template parameter.
 */
public class CPPTemplateNonTypeParameterSpecialization extends CPPTemplateParameterSpecialization
		implements ICPPTemplateNonTypeParameter {
	private final IType fType;

	public CPPTemplateNonTypeParameterSpecialization(ICPPSpecialization owner, ICPPScope scope,
			ICPPTemplateNonTypeParameter specialized, ICPPTemplateArgument defaultValue, IType type) {
		super(owner, scope, specialized, defaultValue);

		this.fType = type;
	}

	@Override
	public ICPPTemplateNonTypeParameter getSpecializedBinding() {
		return (ICPPTemplateNonTypeParameter) super.getSpecializedBinding();
	}

	@Override
	public boolean isMutable() {
		return false;
	}

	@Override
	public boolean isConstexpr() {
		return false;
	}

	@Override
	public boolean isExternC() {
		return false;
	}

	@Override
	public boolean isStatic() {
		return false;
	}

	@Override
	public boolean isExtern() {
		return false;
	}

	@Override
	public boolean isRegister() {
		return false;
	}

	@Override
	public boolean isAuto() {
		return false;
	}

	@Override
	public IType getType() {
		return fType;
	}

	@Override
	public IValue getInitialValue() {
		return getDefaultValue().getNonTypeValue();
	}

	@Override
	@Deprecated
	public IASTExpression getDefault() {
		return null;
	}

	@Override
	public ICPPScope asScope() throws DOMException {
		// A non-type template parameter can never appear on the left hand side
		// of a scope resolution operator.
		return null;
	}
}

Back to the top