blob: d77e3e965952bbc4c616077507d09ef53deff174 (
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
|
/*******************************************************************************
* Copyright (c) 2012, 2013 Wind River Systems, Inc. and others.
* 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:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
import org.eclipse.core.runtime.CoreException;
/**
* Represents the type of a dependent expression.
*/
public class TypeOfDependentExpression implements ICPPUnknownType, ISerializableType {
private final ICPPEvaluation fEvaluation;
public TypeOfDependentExpression(ICPPEvaluation evaluation) {
fEvaluation= evaluation;
}
public ICPPEvaluation getEvaluation() {
return fEvaluation;
}
@Override
public boolean isSameType(IType type) {
return type instanceof TypeOfDependentExpression
&& fEvaluation == ((TypeOfDependentExpression) type).fEvaluation;
}
@Override
public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
return null;
}
}
public char[] getSignature() {
SignatureBuilder buf = new SignatureBuilder();
try {
marshal(buf);
} catch (CoreException e) {
CCorePlugin.log(e);
return new char[] { '?' };
}
return buf.getSignature();
}
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
buffer.putByte(ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE);
buffer.marshalEvaluation(fEvaluation, false);
}
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
ISerializableEvaluation eval= buffer.unmarshalEvaluation();
if (eval instanceof ICPPEvaluation)
return new TypeOfDependentExpression((ICPPEvaluation) eval);
return ProblemType.UNKNOWN_FOR_EXPRESSION;
}
}
|