summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-02-21 20:46:08 (EST)
committerSergey Prigogin2013-02-27 14:51:06 (EST)
commit96a4a227aa4228ac03813407eb112c6cc8f5ef14 (patch)
tree1eaf6d1767c10cb98fc68513445838747157fde7
parent773aa77a2ac589f15951363faa7159b93f9b77f9 (diff)
downloadorg.eclipse.cdt-96a4a227aa4228ac03813407eb112c6cc8f5ef14.zip
org.eclipse.cdt-96a4a227aa4228ac03813407eb112c6cc8f5ef14.tar.gz
org.eclipse.cdt-96a4a227aa4228ac03813407eb112c6cc8f5ef14.tar.bz2
Bug 401479 - Error involving variadic templates and function objectsrefs/changes/78/10578/7
Change-Id: Ie4fcbc1a14d9a3b034789b3dd5c2b24dd05c196d Reviewed-on: https://git.eclipse.org/r/10578 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java17
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java95
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemType.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java24
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java44
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java20
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterPackType.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerToMemberType.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClassInstance.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMember.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPDependentEvaluation.java60
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java24
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java17
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java17
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalParameterPack.java131
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SignatureBuilder.java29
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java85
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java88
49 files changed, 637 insertions, 423 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
index 54feea4..31a9337 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
@@ -7205,6 +7205,23 @@ public class AST2TemplateTests extends AST2TestBase {
parseAndCheckBindings();
}
+ // int fn(int);
+ // struct S {
+ // template <typename... Args>
+ // auto operator()(Args... args) -> decltype(fn(args...));
+ // };
+ // template <typename F>
+ // int foo(F);
+ // template <typename T>
+ // void bar(T);
+ // int main() {
+ // S s;
+ // bar(foo(s(0)));
+ // }
+ public void testVariadicTemplatesAndFunctionObjects_401479() throws Exception {
+ parseAndCheckBindings();
+ }
+
// struct S {
// void kind();
// };
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java
index 470ea5f..c163a7d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 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
@@ -9,6 +9,7 @@
* Markus Schorn - initial API and implementation
* Thomas Corbat
* Sergey Prigogin (Google)
+ * Nathan Ridge
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
@@ -22,45 +23,56 @@ import org.eclipse.core.runtime.CoreException;
* Buffer for marshalling and unmarshalling types.
*/
public interface ITypeMarshalBuffer {
- final static byte BASIC_TYPE= 1;
- final static byte POINTER_TYPE= 2;
- final static byte ARRAY_TYPE= 3;
- final static byte CVQUALIFIER_TYPE= 4;
- final static byte FUNCTION_TYPE= 5;
- final static byte REFERENCE_TYPE= 6;
- final static byte POINTER_TO_MEMBER_TYPE= 7;
- final static byte PACK_EXPANSION_TYPE= 8;
- final static byte PROBLEM_TYPE= 9;
- final static byte VALUE= 10;
- final static byte DEPENDENT_EXPRESSION_TYPE= 11;
- final static byte UNKNOWN_MEMBER= 12;
- final static byte UNKNOWN_MEMBER_CLASS_INSTANCE= 13;
- final static byte DEFERRED_CLASS_INSTANCE= 14;
- final static byte ALIAS_TEMPLATE = 15;
+ final static byte BASIC_TYPE = 0x01;
+ final static byte POINTER_TYPE = 0x02;
+ final static byte ARRAY_TYPE = 0x03;
+ final static byte CVQUALIFIER_TYPE = 0x04;
+ final static byte FUNCTION_TYPE = 0x05;
+ final static byte REFERENCE_TYPE = 0x06;
+ final static byte POINTER_TO_MEMBER_TYPE = 0x07;
+ final static byte PACK_EXPANSION_TYPE = 0x08;
+ final static byte PROBLEM_TYPE = 0x09;
+ final static byte VALUE = 0x0A;
+ final static byte DEPENDENT_EXPRESSION_TYPE = 0x0B;
+ final static byte UNKNOWN_MEMBER = 0x0C;
+ final static byte UNKNOWN_MEMBER_CLASS_INSTANCE = 0x0D;
+ final static byte DEFERRED_CLASS_INSTANCE = 0x0E;
+ final static byte ALIAS_TEMPLATE = 0x0F;
+ // Can add more types up to 0x1C, after that it will collide with TypeMarshalBuffer.UNSTORABLE_TYPE.
final static byte
- EVAL_BINARY= 1,
- EVAL_BINARY_TYPE_ID = 2,
- EVAL_BINDING = 3,
- EVAL_COMMA = 4,
- EVAL_COMPOUND = 5,
- EVAL_CONDITIONAL = 6,
- EVAL_FIXED= 7,
- EVAL_FUNCTION_CALL= 8,
- EVAL_FUNCTION_SET= 9,
- EVAL_ID= 10,
- EVAL_INIT_LIST= 11,
- EVAL_MEMBER_ACCESS= 12,
- EVAL_TYPE_ID= 13,
- EVAL_UNARY= 14,
- EVAL_UNARY_TYPE_ID = 15;
+ EVAL_BINARY = 0x01,
+ EVAL_BINARY_TYPE_ID = 0x02,
+ EVAL_BINDING = 0x03,
+ EVAL_COMMA = 0x04,
+ EVAL_COMPOUND = 0x05,
+ EVAL_CONDITIONAL = 0x06,
+ EVAL_FIXED = 0x07,
+ EVAL_FUNCTION_CALL = 0x08,
+ EVAL_FUNCTION_SET = 0x09,
+ EVAL_ID = 0x0A,
+ EVAL_INIT_LIST = 0x0B,
+ EVAL_MEMBER_ACCESS = 0x0C,
+ EVAL_PARAMETER_PACK = 0x0D,
+ EVAL_TYPE_ID = 0x0E,
+ EVAL_UNARY = 0x0F,
+ EVAL_UNARY_TYPE_ID = 0x10;
+ // Can add more evaluations up to 0x1C, after that it will collide with TypeMarshalBuffer.UNSTORABLE_TYPE.
- static final byte KIND_MASK= 15;
+ static final short KIND_MASK = 0x001F;
- final static int FLAG1 = 0x10;
- final static int FLAG2 = 0x20;
- final static int FLAG3 = 0x40;
- final static int FLAG4 = 0x80;
+ final static short FIRST_FLAG = 0x0020;
+
+ final static short FLAG1 = 0x0020;
+ final static short FLAG2 = 0x0040;
+ final static short FLAG3 = 0x0080;
+ final static short FLAG4 = 0x0100;
+ final static short FLAG5 = 0x0200;
+ final static short FLAG6 = 0x0400;
+ final static short FLAG7 = 0x0800;
+ // Can add more flags up to LAST_FLAG.
+
+ final static short LAST_FLAG = 0x2000;
CoreException unmarshallingError();
@@ -73,6 +85,11 @@ public interface ITypeMarshalBuffer {
int getFixedInt() throws CoreException;
/**
+ * Reads a 16-bit integer stored in the variable length base-128 encoding.
+ */
+ public short getShort() throws CoreException;
+
+ /**
* Reads a 32-bit integer stored in the variable length base-128 encoding.
*/
public int getInt() throws CoreException;
@@ -93,6 +110,12 @@ public interface ITypeMarshalBuffer {
void putFixedInt(int data);
/**
+ * Writes a 16-bit integer in the variable length base-128 encoding.
+ * @param value the value to write
+ */
+ public void putShort(short value);
+
+ /**
* Writes a 32-bit integer in the variable length base-128 encoding. Each byte, except the last
* byte, has the most significant bit set – this indicates that there are further bytes to come.
* The lower 7 bits of each byte are used to store the two-complement representation of
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java
index fdeddcf..797bf92 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemFunctionType.java
@@ -28,11 +28,11 @@ public class ProblemFunctionType extends ProblemType implements ICPPFunctionType
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- buffer.putByte((byte) (ITypeMarshalBuffer.PROBLEM_TYPE | ITypeMarshalBuffer.FLAG1));
+ buffer.putShort((short) (ITypeMarshalBuffer.PROBLEM_TYPE | ITypeMarshalBuffer.FLAG1));
buffer.putInt(getID());
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
return new ProblemFunctionType(buffer.getInt());
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemType.java
index 8c6852c..48d9b49 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemType.java
@@ -56,13 +56,13 @@ public class ProblemType implements IProblemType, ISerializableType {
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- buffer.putByte(ITypeMarshalBuffer.PROBLEM_TYPE);
+ buffer.putShort(ITypeMarshalBuffer.PROBLEM_TYPE);
buffer.putInt(getID());
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
- if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0)
- return ProblemFunctionType.unmarshal(firstByte, buffer);
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
+ if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0)
+ return ProblemFunctionType.unmarshal(firstBytes, buffer);
return new ProblemType(buffer.getInt());
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java
index 21bf02a..49dfa21 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java
@@ -154,41 +154,41 @@ public class Value implements IValue {
return IBinding.EMPTY_BINDING_ARRAY;
}
- public void marshall(ITypeMarshalBuffer buf) throws CoreException {
+ public void marshal(ITypeMarshalBuffer buf) throws CoreException {
if (UNKNOWN == this) {
- buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG1));
+ buf.putShort((short) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG1));
} else {
Long num= numericalValue();
if (num != null) {
long lv= num;
if (lv >= 0) {
- buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG2));
+ buf.putShort((short) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG2));
buf.putLong(lv);
} else {
- buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG3));
+ buf.putShort((short) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG3));
buf.putLong(-lv);
}
} else if (fFixedValue != null) {
- buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG4));
+ buf.putShort((short) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG4));
buf.putCharArray(fFixedValue);
} else {
- buf.putByte((ITypeMarshalBuffer.VALUE));
+ buf.putShort(ITypeMarshalBuffer.VALUE);
fEvaluation.marshal(buf, true);
}
}
}
public static IValue unmarshal(ITypeMarshalBuffer buf) throws CoreException {
- int firstByte= buf.getByte();
- if (firstByte == TypeMarshalBuffer.NULL_TYPE)
+ short firstBytes= buf.getShort();
+ if (firstBytes == TypeMarshalBuffer.NULL_TYPE)
return null;
- if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0)
+ if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0)
return Value.UNKNOWN;
- if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0)
+ if ((firstBytes & ITypeMarshalBuffer.FLAG2) != 0)
return Value.create(buf.getLong());
- if ((firstByte & ITypeMarshalBuffer.FLAG3) != 0)
+ if ((firstBytes & ITypeMarshalBuffer.FLAG3) != 0)
return Value.create(-buf.getLong());
- if ((firstByte & ITypeMarshalBuffer.FLAG4) != 0)
+ if ((firstBytes & ITypeMarshalBuffer.FLAG4) != 0)
return new Value(buf.getCharArray(), null);
ISerializableEvaluation eval= buf.unmarshalEvaluation();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java
index 42a3be3..e18c572 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CArrayType.java
@@ -160,35 +160,28 @@ public class CArrayType implements ICArrayType, ITypeContainer, ISerializableTyp
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= ITypeMarshalBuffer.ARRAY_TYPE;
- int flags= 0;
+ short firstBytes = ITypeMarshalBuffer.ARRAY_TYPE;
long nval= -1;
IValue val= null;
- if (isConst()) flags |= 0x01;
- if (isVolatile()) flags |= 0x02;
- if (isRestrict()) flags |= 0x04;
- if (isStatic()) flags |= 0x08;
- if (isVariableLength()) flags |= 0x10;
- if (flags != 0) {
- firstByte |= ITypeMarshalBuffer.FLAG1;
- }
+ if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
+ if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
+ if (isRestrict()) firstBytes |= ITypeMarshalBuffer.FLAG3;
+ if (isStatic()) firstBytes |= ITypeMarshalBuffer.FLAG4;
+ if (isVariableLength()) firstBytes |= ITypeMarshalBuffer.FLAG5;
val= getSize();
if (val != null) {
- firstByte |= ITypeMarshalBuffer.FLAG2;
+ firstBytes |= ITypeMarshalBuffer.FLAG6;
Long num= val.numericalValue();
if (num != null) {
nval= num;
if (nval >= 0) {
- firstByte |= ITypeMarshalBuffer.FLAG3;
+ firstBytes |= ITypeMarshalBuffer.FLAG7;
}
}
}
- buffer.putByte((byte) firstByte);
- if (flags != 0) {
- buffer.putByte((byte) flags);
- }
+ buffer.putShort(firstBytes);
if (nval >= 0) {
buffer.putLong(nval);
} else if (val != null) {
@@ -197,21 +190,20 @@ public class CArrayType implements ICArrayType, ITypeContainer, ISerializableTyp
buffer.marshalType(getType());
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
- int flags= 0;
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IValue value= null;
- if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) {
- flags= buffer.getByte();
- }
- if ((firstByte & ITypeMarshalBuffer.FLAG3) != 0) {
+ if ((firstBytes & ITypeMarshalBuffer.FLAG7) != 0) {
value = Value.create(buffer.getLong());
- } else if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) {
+ } else if ((firstBytes & ITypeMarshalBuffer.FLAG6) != 0) {
value = buffer.unmarshalValue();
}
IType nested= buffer.unmarshalType();
- CArrayType result= new CArrayType(nested, (flags & 0x01) != 0, (flags & 0x02) != 0, (flags & 0x04) != 0, value);
- result.setIsStatic((flags & 0x08) != 0);
- result.setIsVariableLength((flags & 0x10) != 0);
+ CArrayType result= new CArrayType(nested,
+ (firstBytes & ITypeMarshalBuffer.FLAG1) != 0,
+ (firstBytes & ITypeMarshalBuffer.FLAG2) != 0,
+ (firstBytes & ITypeMarshalBuffer.FLAG3) != 0, value);
+ result.setIsStatic((firstBytes & ITypeMarshalBuffer.FLAG4) != 0);
+ result.setIsVariableLength((firstBytes & ITypeMarshalBuffer.FLAG5) != 0);
return result;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java
index bd3d0b2..0ac2f77 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java
@@ -60,6 +60,7 @@ public class CBasicType implements ICBasicType, ISerializableType {
}
private static Kind getKind(ICASTSimpleDeclSpecifier sds) {
+ // Note: when adding a new kind, marshal() and unnmarshal() may need to be revised.
switch (sds.getType()) {
case IASTSimpleDeclSpecifier.t_bool:
return Kind.eBoolean;
@@ -170,25 +171,21 @@ public class CBasicType implements ICBasicType, ISerializableType {
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
final int kind= getKind().ordinal();
- final int shiftedKind= kind * ITypeMarshalBuffer.FLAG1;
+ final int shiftedKind= kind * ITypeMarshalBuffer.FIRST_FLAG;
final int modifiers= getModifiers();
- if (shiftedKind < ITypeMarshalBuffer.FLAG4 && modifiers == 0) {
- buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind));
+ if (modifiers == 0) {
+ buffer.putShort((short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind));
} else {
- buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | ITypeMarshalBuffer.FLAG4));
- buffer.putByte((byte) kind);
+ buffer.putShort((short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind | ITypeMarshalBuffer.LAST_FLAG));
buffer.putByte((byte) modifiers);
}
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
- final boolean dense= (firstByte & ITypeMarshalBuffer.FLAG4) == 0;
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
+ final boolean haveModifiers= (firstBytes & ITypeMarshalBuffer.LAST_FLAG) != 0;
int modifiers= 0;
- int kind;
- if (dense) {
- kind= (firstByte & (ITypeMarshalBuffer.FLAG4-1))/ITypeMarshalBuffer.FLAG1;
- } else {
- kind= buffer.getByte();
+ int kind= (firstBytes & (ITypeMarshalBuffer.LAST_FLAG-1))/ITypeMarshalBuffer.FIRST_FLAG;
+ if (haveModifiers) {
modifiers= buffer.getByte();
}
return new CBasicType(Kind.values()[kind], modifiers);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java
index 7eda549..986e24f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunctionType.java
@@ -78,16 +78,16 @@ public class CFunctionType implements IFunctionType, ISerializableType {
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= ITypeMarshalBuffer.FUNCTION_TYPE;
+ short firstBytes = ITypeMarshalBuffer.FUNCTION_TYPE;
int len= parameters.length & 0xffff;
- int codedLen= len * ITypeMarshalBuffer.FLAG1;
- if (codedLen < ITypeMarshalBuffer.FLAG4) {
- firstByte |= codedLen;
- buffer.putByte((byte) firstByte);
+ int codedLen= len * ITypeMarshalBuffer.FIRST_FLAG;
+ if (codedLen < ITypeMarshalBuffer.LAST_FLAG) {
+ firstBytes |= codedLen;
+ buffer.putShort(firstBytes);
} else {
- firstByte |= ITypeMarshalBuffer.FLAG4;
- buffer.putByte((byte) firstByte);
+ firstBytes |= ITypeMarshalBuffer.LAST_FLAG;
+ buffer.putShort(firstBytes);
buffer.putInt(len);
}
@@ -97,12 +97,12 @@ public class CFunctionType implements IFunctionType, ISerializableType {
}
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int len;
- if (((firstByte & ITypeMarshalBuffer.FLAG4) != 0)) {
+ if (((firstBytes & ITypeMarshalBuffer.LAST_FLAG) != 0)) {
len= buffer.getInt();
} else {
- len= (firstByte & (ITypeMarshalBuffer.FLAG4-1))/ITypeMarshalBuffer.FLAG1;
+ len= (firstBytes & (ITypeMarshalBuffer.LAST_FLAG-1))/ITypeMarshalBuffer.FIRST_FLAG;
}
IType rt= buffer.unmarshalType();
IType[] pars= new IType[len];
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java
index 61b7605..89477b0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CPointerType.java
@@ -94,17 +94,17 @@ public class CPointerType implements ICPointerType, ITypeContainer, ISerializabl
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= ITypeMarshalBuffer.POINTER_TYPE;
- if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
- if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2;
- if (isRestrict()) firstByte |= ITypeMarshalBuffer.FLAG3;
- buffer.putByte((byte) firstByte);
+ short firstBytes = ITypeMarshalBuffer.POINTER_TYPE;
+ if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
+ if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
+ if (isRestrict()) firstBytes |= ITypeMarshalBuffer.FLAG3;
+ buffer.putShort(firstBytes);
buffer.marshalType(getType());
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType();
- return new CPointerType(nested, firstByte/ITypeMarshalBuffer.FLAG1);
+ return new CPointerType(nested, firstBytes/ITypeMarshalBuffer.FLAG1);
}
@Override
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java
index 23ff677..604be21 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java
@@ -144,17 +144,17 @@ public class CQualifierType implements ICQualifierType, ITypeContainer, ISeriali
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= ITypeMarshalBuffer.CVQUALIFIER_TYPE;
- if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
- if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2;
- if (isRestrict()) firstByte |= ITypeMarshalBuffer.FLAG3;
- buffer.putByte((byte) firstByte);
+ short firstBytes= ITypeMarshalBuffer.CVQUALIFIER_TYPE;
+ if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
+ if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
+ if (isRestrict()) firstBytes |= ITypeMarshalBuffer.FLAG3;
+ buffer.putShort(firstBytes);
buffer.marshalType(getType());
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType();
- return new CQualifierType(nested, (firstByte & ITypeMarshalBuffer.FLAG1) != 0,
- (firstByte & ITypeMarshalBuffer.FLAG2) != 0, (firstByte & ITypeMarshalBuffer.FLAG3) != 0);
+ return new CQualifierType(nested, (firstBytes & ITypeMarshalBuffer.FLAG1) != 0,
+ (firstBytes & ITypeMarshalBuffer.FLAG2) != 0, (firstBytes & ITypeMarshalBuffer.FLAG3) != 0);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java
index 5669529..58747fd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTPackExpansionExpression.java
@@ -11,8 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
-import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
-
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@@ -21,9 +19,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
-import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
-import org.eclipse.cdt.internal.core.dom.parser.Value;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalParameterPack;
/**
* Implementation of pack expansion expression.
@@ -70,13 +66,7 @@ public class CPPASTPackExpansionExpression extends ASTNode implements ICPPASTPac
@Override
public ICPPEvaluation getEvaluation() {
if (fEvaluation == null) {
- IType type = fPattern.getExpressionType();
- if (type == null) {
- type= ProblemType.UNKNOWN_FOR_EXPRESSION;
- } else {
- type= new CPPParameterPackType(type);
- }
- fEvaluation= new EvalFixed(type, PRVALUE, Value.create(((ICPPASTExpression) fPattern).getEvaluation()));
+ fEvaluation = new EvalParameterPack(((ICPPASTExpression) fPattern).getEvaluation(), this);
}
return fEvaluation;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java
index bae0b08..b0bf15e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplateInstance.java
@@ -111,14 +111,14 @@ public class CPPAliasTemplateInstance extends PlatformObject
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte = ITypeMarshalBuffer.ALIAS_TEMPLATE;
- buffer.putByte((byte) firstByte);
+ short firstBytes = ITypeMarshalBuffer.ALIAS_TEMPLATE;
+ buffer.putShort(firstBytes);
buffer.putCharArray(name);
buffer.marshalType(aliasedType);
buffer.marshalBinding(aliasTemplate);
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
char[] name = buffer.getCharArray();
IType unmarshalledAliasedTypeInstance = buffer.unmarshalType();
ICPPAliasTemplate unmarshalledAlias = (ICPPAliasTemplate)buffer.unmarshalBinding();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java
index 32555a2..bcef9a1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArrayType.java
@@ -111,11 +111,11 @@ public class CPPArrayType implements IArrayType, ITypeContainer, ISerializableTy
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- final byte firstByte = ITypeMarshalBuffer.ARRAY_TYPE;
+ final short firstBytes = ITypeMarshalBuffer.ARRAY_TYPE;
IValue val= getSize();
if (val == null) {
- buffer.putByte(firstByte);
+ buffer.putShort(firstBytes);
buffer.marshalType(getType());
return;
}
@@ -124,22 +124,22 @@ public class CPPArrayType implements IArrayType, ITypeContainer, ISerializableTy
if (num != null) {
long lnum= num;
if (lnum >= 0) {
- buffer.putByte((byte) (firstByte | ITypeMarshalBuffer.FLAG1));
+ buffer.putShort((short) (firstBytes | ITypeMarshalBuffer.FLAG1));
buffer.putLong(lnum);
buffer.marshalType(getType());
return;
}
}
- buffer.putByte((byte) (firstByte | ITypeMarshalBuffer.FLAG2));
+ buffer.putShort((short) (firstBytes | ITypeMarshalBuffer.FLAG2));
buffer.marshalValue(val);
buffer.marshalType(getType());
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IValue value= null;
- if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) {
+ if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0) {
value = Value.create(buffer.getLong());
- } else if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) {
+ } else if ((firstBytes & ITypeMarshalBuffer.FLAG2) != 0) {
value = buffer.unmarshalValue();
}
IType nested= buffer.unmarshalType();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java
index 146430c..625c1bd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java
@@ -85,6 +85,7 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
}
static Kind getKind(final int simpleDeclSpecType) {
+ // Note: when adding a new kind, marshal() and unnmarshal() may need to be revised.
switch (simpleDeclSpecType) {
case IASTSimpleDeclSpecifier.t_bool:
return Kind.eBoolean;
@@ -224,25 +225,21 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
final int kind= getKind().ordinal();
- final int shiftedKind= kind * ITypeMarshalBuffer.FLAG1;
+ final int shiftedKind= kind * ITypeMarshalBuffer.FIRST_FLAG;
final int modifiers= getModifiers();
- if (shiftedKind < ITypeMarshalBuffer.FLAG4 && modifiers == 0) {
- buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind));
+ if (modifiers == 0) {
+ buffer.putShort((short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind));
} else {
- buffer.putByte((byte) (ITypeMarshalBuffer.BASIC_TYPE | ITypeMarshalBuffer.FLAG4));
- buffer.putByte((byte) kind);
+ buffer.putShort((short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind | ITypeMarshalBuffer.LAST_FLAG));
buffer.putByte((byte) modifiers);
}
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
- final boolean dense= (firstByte & ITypeMarshalBuffer.FLAG4) == 0;
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
+ final boolean haveModifiers= (firstBytes & ITypeMarshalBuffer.LAST_FLAG) != 0;
int modifiers= 0;
- int kind;
- if (dense) {
- kind= (firstByte & (ITypeMarshalBuffer.FLAG4 - 1)) / ITypeMarshalBuffer.FLAG1;
- } else {
- kind= buffer.getByte();
+ int kind= (firstBytes & (ITypeMarshalBuffer.LAST_FLAG - 1)) / ITypeMarshalBuffer.FIRST_FLAG;
+ if (haveModifiers) {
modifiers= buffer.getByte();
}
return new CPPBasicType(Kind.values()[kind], modifiers);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java
index 5b4cc47..605f887 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java
@@ -227,8 +227,8 @@ public class CPPDeferredClassInstance extends CPPUnknownBinding implements ICPPD
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE;
- buffer.putByte((byte) firstByte);
+ short firstBytes= ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE;
+ buffer.putShort(firstBytes);
buffer.marshalBinding(fClassTemplate);
buffer.putInt(fArguments.length);
for (ICPPTemplateArgument arg : fArguments) {
@@ -236,7 +236,7 @@ public class CPPDeferredClassInstance extends CPPUnknownBinding implements ICPPD
}
}
- public static ICPPDeferredClassInstance unmarshal(IIndexFragment fragment, int firstByte,
+ public static ICPPDeferredClassInstance unmarshal(IIndexFragment fragment, short firstBytes,
ITypeMarshalBuffer buffer) throws CoreException {
IBinding template= buffer.unmarshalBinding();
int argcount= buffer.getInt();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java
index 1655e0b..f39a368 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionType.java
@@ -136,12 +136,12 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= ITypeMarshalBuffer.FUNCTION_TYPE;
- if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
- if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2;
- if (takesVarArgs()) firstByte |= ITypeMarshalBuffer.FLAG3;
+ short firstBytes= ITypeMarshalBuffer.FUNCTION_TYPE;
+ if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
+ if (takesVarArgs()) firstBytes |= ITypeMarshalBuffer.FLAG2;
+ if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG3;
- buffer.putByte((byte) firstByte);
+ buffer.putShort(firstBytes);
buffer.putInt(parameters.length);
buffer.marshalType(returnType);
@@ -150,14 +150,16 @@ public class CPPFunctionType implements ICPPFunctionType, ISerializableType {
}
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int len= buffer.getInt();
IType rt= buffer.unmarshalType();
IType[] pars= new IType[len];
for (int i = 0; i < pars.length; i++) {
pars[i]= buffer.unmarshalType();
}
- return new CPPFunctionType(rt, pars, (firstByte & ITypeMarshalBuffer.FLAG1) != 0,
- (firstByte & ITypeMarshalBuffer.FLAG2) != 0, (firstByte & ITypeMarshalBuffer.FLAG3) != 0);
+ return new CPPFunctionType(rt, pars,
+ (firstBytes & ITypeMarshalBuffer.FLAG1) != 0, // const
+ (firstBytes & ITypeMarshalBuffer.FLAG3) != 0, // volatile
+ (firstBytes & ITypeMarshalBuffer.FLAG2) != 0); // takes varargs
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterPackType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterPackType.java
index 03bfac2..708ae34 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterPackType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterPackType.java
@@ -72,12 +72,12 @@ public class CPPParameterPackType implements ICPPParameterPackType, ITypeContain
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= ITypeMarshalBuffer.PACK_EXPANSION_TYPE;
- buffer.putByte((byte) firstByte);
+ short firstBytes= ITypeMarshalBuffer.PACK_EXPANSION_TYPE;
+ buffer.putShort(firstBytes);
buffer.marshalType(getType());
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType();
if (nested == null)
return new ProblemBinding(null, IProblemBinding.SEMANTIC_INVALID_TYPE);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerToMemberType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerToMemberType.java
index 57ba722..2c253c0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerToMemberType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerToMemberType.java
@@ -97,20 +97,20 @@ public class CPPPointerToMemberType extends CPPPointerType implements ICPPPointe
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= ITypeMarshalBuffer.POINTER_TO_MEMBER_TYPE;
- if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
- if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2;
- if (isRestrict()) firstByte |= ITypeMarshalBuffer.FLAG3;
- buffer.putByte((byte) firstByte);
+ short firstBytes= ITypeMarshalBuffer.POINTER_TO_MEMBER_TYPE;
+ if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
+ if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
+ if (isRestrict()) firstBytes |= ITypeMarshalBuffer.FLAG3;
+ buffer.putShort(firstBytes);
buffer.marshalType(getType());
buffer.marshalType(getMemberOfClass());
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType();
IType memberOf= buffer.unmarshalType();
- return new CPPPointerToMemberType(nested, memberOf, (firstByte & ITypeMarshalBuffer.FLAG1) != 0,
- (firstByte & ITypeMarshalBuffer.FLAG2) != 0,
- (firstByte & ITypeMarshalBuffer.FLAG3) != 0);
+ return new CPPPointerToMemberType(nested, memberOf, (firstBytes & ITypeMarshalBuffer.FLAG1) != 0,
+ (firstBytes & ITypeMarshalBuffer.FLAG2) != 0,
+ (firstBytes & ITypeMarshalBuffer.FLAG3) != 0);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java
index 47fcc5d..7993228 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java
@@ -108,20 +108,20 @@ public class CPPPointerType implements IPointerType, ITypeContainer, ISerializab
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= ITypeMarshalBuffer.POINTER_TYPE;
- if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
- if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2;
- if (isRestrict()) firstByte |= ITypeMarshalBuffer.FLAG3;
- buffer.putByte((byte) firstByte);
+ short firstBytes= ITypeMarshalBuffer.POINTER_TYPE;
+ if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
+ if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
+ if (isRestrict()) firstBytes |= ITypeMarshalBuffer.FLAG3;
+ buffer.putShort(firstBytes);
final IType nestedType = getType();
buffer.marshalType(nestedType);
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType();
- return new CPPPointerType(nested, (firstByte & ITypeMarshalBuffer.FLAG1) != 0,
- (firstByte & ITypeMarshalBuffer.FLAG2) != 0,
- (firstByte & ITypeMarshalBuffer.FLAG3) != 0);
+ return new CPPPointerType(nested, (firstBytes & ITypeMarshalBuffer.FLAG1) != 0,
+ (firstBytes & ITypeMarshalBuffer.FLAG2) != 0,
+ (firstBytes & ITypeMarshalBuffer.FLAG3) != 0);
}
@Override
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java
index 28fad2b..df4c920 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java
@@ -92,16 +92,16 @@ public class CPPQualifierType implements IQualifierType, ITypeContainer, ISerial
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= ITypeMarshalBuffer.CVQUALIFIER_TYPE;
- if (isConst()) firstByte |= ITypeMarshalBuffer.FLAG1;
- if (isVolatile()) firstByte |= ITypeMarshalBuffer.FLAG2;
- buffer.putByte((byte) firstByte);
+ short firstBytes= ITypeMarshalBuffer.CVQUALIFIER_TYPE;
+ if (isConst()) firstBytes |= ITypeMarshalBuffer.FLAG1;
+ if (isVolatile()) firstBytes |= ITypeMarshalBuffer.FLAG2;
+ buffer.putShort(firstBytes);
buffer.marshalType(getType());
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType();
- return new CPPQualifierType(nested, (firstByte & ITypeMarshalBuffer.FLAG1) != 0,
- (firstByte & ITypeMarshalBuffer.FLAG2) != 0);
+ return new CPPQualifierType(nested, (firstBytes & ITypeMarshalBuffer.FLAG1) != 0,
+ (firstBytes & ITypeMarshalBuffer.FLAG2) != 0);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java
index a8a64ea..abcf69b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPReferenceType.java
@@ -109,16 +109,16 @@ public class CPPReferenceType implements ICPPReferenceType, ITypeContainer, ISer
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= ITypeMarshalBuffer.REFERENCE_TYPE;
+ short firstBytes= ITypeMarshalBuffer.REFERENCE_TYPE;
if (isRValueReference()) {
- firstByte |= ITypeMarshalBuffer.FLAG1;
+ firstBytes |= ITypeMarshalBuffer.FLAG1;
}
- buffer.putByte((byte) firstByte);
+ buffer.putShort(firstBytes);
buffer.marshalType(getType());
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType nested= buffer.unmarshalType();
- return new CPPReferenceType(nested, (firstByte & ITypeMarshalBuffer.FLAG1) != 0);
+ return new CPPReferenceType(nested, (firstBytes & ITypeMarshalBuffer.FLAG1) != 0);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java
index d18ff89..866ecda 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeArgument.java
@@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalParameterPack;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId;
import org.eclipse.core.runtime.Assert;
@@ -90,9 +91,8 @@ public class CPPTemplateNonTypeArgument implements ICPPTemplateArgument {
IType t= ((ICPPParameterPackType) type).getType();
if (t != null) {
ICPPEvaluation evaluation;
- if (fEvaluation instanceof EvalFixed) {
- EvalFixed fixed = (EvalFixed) fEvaluation;
- evaluation = new EvalFixed(t, fixed.getValueCategory(), fixed.getValue());
+ if (fEvaluation instanceof EvalParameterPack) {
+ evaluation = ((EvalParameterPack) fEvaluation).getExpansionPattern();
} else {
evaluation = new EvalTypeId(t, fEvaluation.getTemplateDefinition(), fEvaluation);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClassInstance.java
index a48d638..d65aa05 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClassInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClassInstance.java
@@ -82,8 +82,8 @@ public class CPPUnknownClassInstance extends CPPUnknownMemberClass implements IC
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE;
- buffer.putByte((byte) firstByte);
+ short firstBytes= ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE;
+ buffer.putShort(firstBytes);
buffer.marshalType(getOwnerType());
buffer.putCharArray(getNameCharArray());
buffer.putInt(arguments.length);
@@ -92,7 +92,7 @@ public class CPPUnknownClassInstance extends CPPUnknownMemberClass implements IC
}
}
- public static ICPPUnknownMemberClassInstance unmarshal(IIndexFragment fragment, int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static ICPPUnknownMemberClassInstance unmarshal(IIndexFragment fragment, short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType owner= buffer.unmarshalType();
char[] name = buffer.getCharArray();
int argcount= buffer.getInt();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMember.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMember.java
index 0866fd3..db6db9d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMember.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMember.java
@@ -49,24 +49,24 @@ public class CPPUnknownMember extends CPPUnknownBinding implements ICPPUnknownMe
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= ITypeMarshalBuffer.UNKNOWN_MEMBER;
+ short firstBytes= ITypeMarshalBuffer.UNKNOWN_MEMBER;
if (this instanceof ICPPField) {
- firstByte |= ITypeMarshalBuffer.FLAG1;
+ firstBytes |= ITypeMarshalBuffer.FLAG1;
} else if (this instanceof ICPPMethod) {
- firstByte |= ITypeMarshalBuffer.FLAG2;
+ firstBytes |= ITypeMarshalBuffer.FLAG2;
}
- buffer.putByte((byte) firstByte);
+ buffer.putShort(firstBytes);
buffer.marshalType(getOwnerType());
buffer.putCharArray(getNameCharArray());
}
- public static IBinding unmarshal(IIndexFragment fragment, int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IBinding unmarshal(IIndexFragment fragment, short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType owner= buffer.unmarshalType();
char[] name = buffer.getCharArray();
- if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) {
+ if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0) {
return new PDOMCPPUnknownField(fragment, owner, name);
- } else if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) {
+ } else if ((firstBytes & ITypeMarshalBuffer.FLAG2) != 0) {
return new PDOMCPPUnknownMethod(fragment, owner, name);
}
return new PDOMCPPUnknownMemberClass(fragment, owner, name);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPDependentEvaluation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPDependentEvaluation.java
index 650a36c..d90736f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPDependentEvaluation.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPDependentEvaluation.java
@@ -17,8 +17,11 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;
@@ -95,6 +98,63 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
}
/**
+ * Instantiate evaluations that represent subexpressions separated by commas.
+ * If a subexpression is a pack expansion expression, and the template parameter map
+ * contains a mapping for the parameter pack(s) that occur in its expansion pattern,
+ * the expansion pattern is instantiated once for each mapped template argument,
+ * and the resulting evaluations are returned in place of the pack expansion.
+ *
+ * This code is similar to CPPTemplates.instantiateArguments(), but applies to evaluations
+ * rather than template arguments.
+ */
+ protected static ICPPEvaluation[] instantiateCommaSeparatedSubexpressions(
+ ICPPEvaluation[] subexpressions, ICPPTemplateParameterMap tpMap, int packOffset,
+ ICPPClassSpecialization within, int maxdepth, IASTNode point) {
+ ICPPEvaluation[] result = subexpressions;
+ int resultShift = 0;
+ for (int i = 0; i < subexpressions.length; i++) {
+ ICPPEvaluation origEval = subexpressions[i];
+ ICPPEvaluation newEval;
+ if (origEval instanceof EvalParameterPack) {
+ origEval = ((EvalParameterPack) origEval).getExpansionPattern();
+ if (origEval == null) {
+ newEval = EvalFixed.INCOMPLETE;
+ } else {
+ int packSize = origEval.determinePackSize(tpMap);
+ if (packSize == CPPTemplates.PACK_SIZE_FAIL || packSize == CPPTemplates.PACK_SIZE_NOT_FOUND) {
+ newEval = EvalFixed.INCOMPLETE;
+ } else if (packSize == CPPTemplates.PACK_SIZE_DEFER) {
+ newEval = origEval;
+ } else {
+ int shift = packSize - 1;
+ ICPPEvaluation[] newResult = new ICPPEvaluation[subexpressions.length + resultShift + shift];
+ System.arraycopy(result, 0, newResult, 0, i + resultShift);
+ for (int j = 0; j < packSize; ++j) {
+ newEval = origEval.instantiate(tpMap, j, within, maxdepth, point);
+ newResult[i + resultShift + j] = newEval;
+ }
+ result = newResult;
+ resultShift += shift;
+ continue;
+ }
+ }
+ } else {
+ newEval = origEval.instantiate(tpMap, packOffset, within, maxdepth, point);
+ }
+
+ if (result != subexpressions)
+ result[i + resultShift] = newEval;
+ else if (newEval != origEval) {
+ assert resultShift == 0;
+ result = new ICPPEvaluation[subexpressions.length];
+ System.arraycopy(subexpressions, 0, result, 0, i);
+ result[i] = newEval;
+ }
+ }
+ return result;
+ }
+
+ /**
* Used to defer the resolution of a template definition until it is needed,
* to avoid recursion. The only valid operation on this binding is resolve().
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java
index bb919a9..79bd8aa 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java
@@ -331,14 +331,14 @@ public class EvalBinary extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
- buffer.putByte(ITypeMarshalBuffer.EVAL_BINARY);
+ buffer.putShort(ITypeMarshalBuffer.EVAL_BINARY);
buffer.putByte((byte) fOperator);
buffer.marshalEvaluation(fArg1, includeValue);
buffer.marshalEvaluation(fArg2, includeValue);
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int op= buffer.getByte();
ICPPEvaluation arg1= (ICPPEvaluation) buffer.unmarshalEvaluation();
ICPPEvaluation arg2= (ICPPEvaluation) buffer.unmarshalEvaluation();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java
index 8521bfa..ef523a7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java
@@ -109,14 +109,14 @@ public class EvalBinaryTypeId extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
- buffer.putByte(ITypeMarshalBuffer.EVAL_BINARY_TYPE_ID);
+ buffer.putShort(ITypeMarshalBuffer.EVAL_BINARY_TYPE_ID);
buffer.putByte((byte) fOperator.ordinal());
buffer.marshalType(fType1);
buffer.marshalType(fType2);
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int op= buffer.getByte();
IType arg1= buffer.unmarshalType();
IType arg2= buffer.unmarshalType();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
index 1f5101a..ab94744 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
@@ -305,24 +305,24 @@ public class EvalBinding extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
- byte firstByte = ITypeMarshalBuffer.EVAL_BINDING;
+ short firstBytes = ITypeMarshalBuffer.EVAL_BINDING;
ICPPFunction parameterOwner = getParameterOwner();
if (parameterOwner != null) {
// A function parameter cannot be marshalled directly. We are storing the owning
// function and the parameter position instead.
- buffer.putByte((byte) (ITypeMarshalBuffer.EVAL_BINDING | ITypeMarshalBuffer.FLAG1));
+ buffer.putShort((short) (ITypeMarshalBuffer.EVAL_BINDING | ITypeMarshalBuffer.FLAG1));
buffer.marshalBinding(parameterOwner);
buffer.putInt(getFunctionParameterPosition());
} else {
- buffer.putByte(firstByte);
+ buffer.putShort(firstBytes);
buffer.marshalBinding(fBinding);
}
buffer.marshalType(fFixedType ? fType : null);
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
- if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) {
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
+ if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0) {
ICPPFunction parameterOwner= (ICPPFunction) buffer.unmarshalBinding();
int parameterPosition= buffer.getInt();
IType type= buffer.unmarshalType();
@@ -347,10 +347,12 @@ public class EvalBinding extends CPPDependentEvaluation {
return argument.getNonTypeEvaluation();
}
}
- // TODO(sprigogin): Do we need something similar for pack expansion?
} else if (origBinding instanceof ICPPParameter) {
ICPPParameter parameter = (ICPPParameter) origBinding;
IType origType = parameter.getType();
+ if (origType instanceof ICPPParameterPackType && packOffset != -1) {
+ origType = ((ICPPParameterPackType) origType).getType();
+ }
IType instantiatedType = CPPTemplates.instantiateType(origType, tpMap, packOffset, within, point);
if (origType != instantiatedType) {
return new EvalFixed(instantiatedType, ValueCategory.LVALUE, Value.create(this));
@@ -387,6 +389,10 @@ public class EvalBinding extends CPPDependentEvaluation {
if (binding instanceof ICPPUnknownBinding) {
return CPPTemplates.determinePackSize((ICPPUnknownBinding) binding, tpMap);
}
+ if (binding instanceof ICPPParameter && ((ICPPParameter) binding).isParameterPack()) {
+ ICPPParameterPackType type = (ICPPParameterPackType) ((ICPPParameter) binding).getType();
+ return CPPTemplates.determinePackSize(type.getType(), tpMap);
+ }
if (binding instanceof ICPPSpecialization) {
binding = ((ICPPSpecialization) binding).getSpecializedBinding();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java
index 889a2f0..8567848 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java
@@ -159,7 +159,7 @@ public class EvalComma extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
- buffer.putByte(ITypeMarshalBuffer.EVAL_COMMA);
+ buffer.putShort(ITypeMarshalBuffer.EVAL_COMMA);
buffer.putInt(fArguments.length);
for (ICPPEvaluation arg : fArguments) {
buffer.marshalEvaluation(arg, includeValue);
@@ -167,7 +167,7 @@ public class EvalComma extends CPPDependentEvaluation {
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int len= buffer.getInt();
ICPPEvaluation[] args = new ICPPEvaluation[len];
for (int i = 0; i < args.length; i++) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java
index 6e8f048..571dd36 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java
@@ -81,12 +81,12 @@ public class EvalCompound extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
- buffer.putByte(ITypeMarshalBuffer.EVAL_COMPOUND);
+ buffer.putShort(ITypeMarshalBuffer.EVAL_COMPOUND);
buffer.marshalEvaluation(fDelegate, includeValue);
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
ICPPEvaluation arg= (ICPPEvaluation) buffer.unmarshalEvaluation();
IBinding templateDefinition= buffer.unmarshalBinding();
return new EvalCompound(arg, templateDefinition);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java
index c130d0f..77e6693 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java
@@ -309,22 +309,22 @@ public class EvalConditional extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
- int firstByte = ITypeMarshalBuffer.EVAL_CONDITIONAL;
+ short firstBytes = ITypeMarshalBuffer.EVAL_CONDITIONAL;
if (fPositiveThrows)
- firstByte |= ITypeMarshalBuffer.FLAG1;
+ firstBytes |= ITypeMarshalBuffer.FLAG1;
if (fNegativeThrows)
- firstByte |= ITypeMarshalBuffer.FLAG2;
+ firstBytes |= ITypeMarshalBuffer.FLAG2;
- buffer.putByte((byte) firstByte);
+ buffer.putShort(firstBytes);
buffer.marshalEvaluation(fCondition, includeValue);
buffer.marshalEvaluation(fPositive, includeValue);
buffer.marshalEvaluation(fNegative, includeValue);
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
- boolean pth= (firstByte & ITypeMarshalBuffer.FLAG1) != 0;
- boolean nth= (firstByte & ITypeMarshalBuffer.FLAG2) != 0;
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
+ boolean pth= (firstBytes & ITypeMarshalBuffer.FLAG1) != 0;
+ boolean nth= (firstBytes & ITypeMarshalBuffer.FLAG2) != 0;
ICPPEvaluation cond= (ICPPEvaluation) buffer.unmarshalEvaluation();
ICPPEvaluation pos= (ICPPEvaluation) buffer.unmarshalEvaluation();
ICPPEvaluation neg= (ICPPEvaluation) buffer.unmarshalEvaluation();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java
index 343a762..9041faf 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java
@@ -116,37 +116,37 @@ public class EvalFixed extends CPPEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
includeValue= includeValue && fValue != Value.UNKNOWN;
- int firstByte = ITypeMarshalBuffer.EVAL_FIXED;
+ short firstBytes = ITypeMarshalBuffer.EVAL_FIXED;
if (includeValue)
- firstByte |= ITypeMarshalBuffer.FLAG1;
+ firstBytes |= ITypeMarshalBuffer.FLAG1;
switch (fValueCategory) {
- case LVALUE:
- firstByte |= ITypeMarshalBuffer.FLAG2;
- break;
case PRVALUE:
- firstByte |= ITypeMarshalBuffer.FLAG3;
+ firstBytes |= ITypeMarshalBuffer.FLAG2;
+ break;
+ case LVALUE:
+ firstBytes |= ITypeMarshalBuffer.FLAG3;
break;
default:
break;
}
- buffer.putByte((byte) firstByte);
+ buffer.putShort(firstBytes);
buffer.marshalType(fType);
if (includeValue) {
buffer.marshalValue(fValue);
}
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
- final boolean readValue= (firstByte & ITypeMarshalBuffer.FLAG1) != 0;
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
+ final boolean readValue= (firstBytes & ITypeMarshalBuffer.FLAG1) != 0;
IValue value;
ValueCategory cat;
- switch (firstByte & (ITypeMarshalBuffer.FLAG2 | ITypeMarshalBuffer.FLAG3)) {
+ switch (firstBytes & (ITypeMarshalBuffer.FLAG2 | ITypeMarshalBuffer.FLAG3)) {
case ITypeMarshalBuffer.FLAG2:
- cat= LVALUE;
+ cat= PRVALUE;
break;
case ITypeMarshalBuffer.FLAG3:
- cat= PRVALUE;
+ cat= LVALUE;
break;
default:
cat= XVALUE;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java
index 7df4e72..d6660de 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java
@@ -174,7 +174,7 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
- buffer.putByte(ITypeMarshalBuffer.EVAL_FUNCTION_CALL);
+ buffer.putShort(ITypeMarshalBuffer.EVAL_FUNCTION_CALL);
buffer.putInt(fArguments.length);
for (ICPPEvaluation arg : fArguments) {
buffer.marshalEvaluation(arg, includeValue);
@@ -182,7 +182,7 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int len= buffer.getInt();
ICPPEvaluation[] args = new ICPPEvaluation[len];
for (int i = 0; i < args.length; i++) {
@@ -195,17 +195,8 @@ public class EvalFunctionCall extends CPPDependentEvaluation {
@Override
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
- ICPPEvaluation[] args = fArguments;
- for (int i = 0; i < fArguments.length; i++) {
- ICPPEvaluation arg = fArguments[i].instantiate(tpMap, packOffset, within, maxdepth, point);
- if (arg != fArguments[i]) {
- if (args == fArguments) {
- args = new ICPPEvaluation[fArguments.length];
- System.arraycopy(fArguments, 0, args, 0, fArguments.length);
- }
- args[i] = arg;
- }
- }
+ ICPPEvaluation[] args = instantiateCommaSeparatedSubexpressions(fArguments, tpMap,
+ packOffset, within, maxdepth, point);
if (args == fArguments)
return this;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java
index a267dd3..c262058 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java
@@ -109,13 +109,13 @@ public class EvalFunctionSet extends CPPDependentEvaluation {
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
final ICPPFunction[] bindings = fFunctionSet.getBindings();
final ICPPTemplateArgument[] args = fFunctionSet.getTemplateArguments();
- int firstByte = ITypeMarshalBuffer.EVAL_FUNCTION_SET;
+ short firstBytes = ITypeMarshalBuffer.EVAL_FUNCTION_SET;
if (fAddressOf)
- firstByte |= ITypeMarshalBuffer.FLAG1;
+ firstBytes |= ITypeMarshalBuffer.FLAG1;
if (args != null)
- firstByte |= ITypeMarshalBuffer.FLAG2;
+ firstBytes |= ITypeMarshalBuffer.FLAG2;
- buffer.putByte((byte) firstByte);
+ buffer.putShort(firstBytes);
buffer.putInt(bindings.length);
for (ICPPFunction binding : bindings) {
buffer.marshalBinding(binding);
@@ -129,15 +129,15 @@ public class EvalFunctionSet extends CPPDependentEvaluation {
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
- final boolean addressOf= (firstByte & ITypeMarshalBuffer.FLAG1) != 0;
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
+ final boolean addressOf= (firstBytes & ITypeMarshalBuffer.FLAG1) != 0;
int bindingCount= buffer.getInt();
ICPPFunction[] bindings= new ICPPFunction[bindingCount];
for (int i = 0; i < bindings.length; i++) {
bindings[i]= (ICPPFunction) buffer.unmarshalBinding();
}
ICPPTemplateArgument[] args= null;
- if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) {
+ if ((firstBytes & ITypeMarshalBuffer.FLAG2) != 0) {
int len= buffer.getInt();
args = new ICPPTemplateArgument[len];
for (int i = 0; i < args.length; i++) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java
index 1b50bb7..73ce239 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java
@@ -145,15 +145,15 @@ public class EvalID extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
- int firstByte = ITypeMarshalBuffer.EVAL_ID;
+ short firstBytes = ITypeMarshalBuffer.EVAL_ID;
if (fAddressOf)
- firstByte |= ITypeMarshalBuffer.FLAG1;
+ firstBytes |= ITypeMarshalBuffer.FLAG1;
if (fQualified)
- firstByte |= ITypeMarshalBuffer.FLAG2;
+ firstBytes |= ITypeMarshalBuffer.FLAG2;
if (fTemplateArgs != null)
- firstByte |= ITypeMarshalBuffer.FLAG3;
+ firstBytes |= ITypeMarshalBuffer.FLAG3;
- buffer.putByte((byte) firstByte);
+ buffer.putShort(firstBytes);
buffer.marshalEvaluation(fFieldOwner, false);
buffer.putCharArray(fName);
buffer.marshalBinding(fNameOwner);
@@ -166,14 +166,14 @@ public class EvalID extends CPPDependentEvaluation {
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
- final boolean addressOf= (firstByte & ITypeMarshalBuffer.FLAG1) != 0;
- final boolean qualified= (firstByte & ITypeMarshalBuffer.FLAG2) != 0;
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
+ final boolean addressOf= (firstBytes & ITypeMarshalBuffer.FLAG1) != 0;
+ final boolean qualified= (firstBytes & ITypeMarshalBuffer.FLAG2) != 0;
ICPPEvaluation fieldOwner= (ICPPEvaluation) buffer.unmarshalEvaluation();
char[] name= buffer.getCharArray();
IBinding nameOwner= buffer.unmarshalBinding();
ICPPTemplateArgument[] args= null;
- if ((firstByte & ITypeMarshalBuffer.FLAG3) != 0) {
+ if ((firstBytes & ITypeMarshalBuffer.FLAG3) != 0) {
int len= buffer.getInt();
args = new ICPPTemplateArgument[len];
for (int i = 0; i < args.length; i++) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java
index 8364ff4..3da037e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java
@@ -91,7 +91,7 @@ public class EvalInitList extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
- buffer.putByte(ITypeMarshalBuffer.EVAL_INIT_LIST);
+ buffer.putShort(ITypeMarshalBuffer.EVAL_INIT_LIST);
buffer.putInt(fClauses.length);
for (ICPPEvaluation arg : fClauses) {
buffer.marshalEvaluation(arg, includeValue);
@@ -99,7 +99,7 @@ public class EvalInitList extends CPPDependentEvaluation {
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int len= buffer.getInt();
ICPPEvaluation[] args = new ICPPEvaluation[len];
for (int i = 0; i < args.length; i++) {
@@ -112,17 +112,8 @@ public class EvalInitList extends CPPDependentEvaluation {
@Override
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
- ICPPEvaluation[] clauses = fClauses;
- for (int i = 0; i < fClauses.length; i++) {
- ICPPEvaluation clause = fClauses[i].instantiate(tpMap, packOffset, within, maxdepth, point);
- if (clause != fClauses[i]) {
- if (clauses == fClauses) {
- clauses = new ICPPEvaluation[fClauses.length];
- System.arraycopy(fClauses, 0, clauses, 0, fClauses.length);
- }
- clauses[i] = clause;
- }
- }
+ ICPPEvaluation[] clauses = instantiateCommaSeparatedSubexpressions(fClauses, tpMap,
+ packOffset, within, maxdepth, point);
if (clauses == fClauses)
return this;
return new EvalInitList(clauses, getTemplateDefinition());
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java
index 240ab16..90149b8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java
@@ -295,27 +295,27 @@ public class EvalMemberAccess extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
- int firstByte = ITypeMarshalBuffer.EVAL_MEMBER_ACCESS;
+ short firstBytes = ITypeMarshalBuffer.EVAL_MEMBER_ACCESS;
if (fIsPointerDeref)
- firstByte |= ITypeMarshalBuffer.FLAG1;
+ firstBytes |= ITypeMarshalBuffer.FLAG1;
if (fOwnerValueCategory == LVALUE) {
- firstByte |= ITypeMarshalBuffer.FLAG2;
+ firstBytes |= ITypeMarshalBuffer.FLAG2;
} else if (fOwnerValueCategory == XVALUE) {
- firstByte |= ITypeMarshalBuffer.FLAG3;
+ firstBytes |= ITypeMarshalBuffer.FLAG3;
}
- buffer.putByte((byte) firstByte);
+ buffer.putShort(firstBytes);
buffer.marshalType(fOwnerType);
buffer.marshalBinding(fMember);
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
- boolean isDeref= (firstByte & ITypeMarshalBuffer.FLAG1) != 0;
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
+ boolean isDeref= (firstBytes & ITypeMarshalBuffer.FLAG1) != 0;
ValueCategory ownerValueCat;
- if ((firstByte & ITypeMarshalBuffer.FLAG2) != 0) {
+ if ((firstBytes & ITypeMarshalBuffer.FLAG2) != 0) {
ownerValueCat= LVALUE;
- } else if ((firstByte & ITypeMarshalBuffer.FLAG3) != 0) {
+ } else if ((firstBytes & ITypeMarshalBuffer.FLAG3) != 0) {
ownerValueCat= XVALUE;
} else {
ownerValueCat= PRVALUE;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalParameterPack.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalParameterPack.java
new file mode 100644
index 0000000..4b6d921
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalParameterPack.java
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * 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 - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
+
+import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.IValue;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
+import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
+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.Value;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Evaluation for a pack expansion expression.
+ */
+public class EvalParameterPack extends CPPDependentEvaluation {
+
+ private ICPPEvaluation fExpansionPattern;
+ private IType fType;
+
+ public EvalParameterPack(ICPPEvaluation expansionPattern, IASTNode pointOfDefinition) {
+ this(expansionPattern, findEnclosingTemplate(pointOfDefinition));
+ }
+ public EvalParameterPack(ICPPEvaluation expansionPattern, IBinding templateDefinition) {
+ super(templateDefinition);
+ fExpansionPattern = expansionPattern;
+ }
+
+ public ICPPEvaluation getExpansionPattern() {
+ return fExpansionPattern;
+ }
+
+ @Override
+ public boolean isInitializerList() {
+ return fExpansionPattern.isInitializerList();
+ }
+
+ @Override
+ public boolean isFunctionSet() {
+ return fExpansionPattern.isFunctionSet();
+ }
+
+ @Override
+ public boolean isTypeDependent() {
+ return fExpansionPattern.isTypeDependent();
+ }
+
+ @Override
+ public boolean isValueDependent() {
+ return fExpansionPattern.isValueDependent();
+ }
+
+ @Override
+ public IType getTypeOrFunctionSet(IASTNode point) {
+ if (fType == null) {
+ IType type = fExpansionPattern.getTypeOrFunctionSet(point);
+ if (type == null) {
+ fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
+ } else {
+ fType= new CPPParameterPackType(type);
+ }
+ }
+ return fType;
+ }
+
+ @Override
+ public IValue getValue(IASTNode point) {
+ return Value.create(fExpansionPattern);
+ }
+
+ @Override
+ public ValueCategory getValueCategory(IASTNode point) {
+ return ValueCategory.PRVALUE;
+ }
+
+ @Override
+ public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
+ ICPPClassSpecialization within, int maxdepth, IASTNode point) {
+ ICPPEvaluation expansionPattern = fExpansionPattern.instantiate(tpMap, packOffset, within, maxdepth, point);
+ if (expansionPattern == fExpansionPattern)
+ return this;
+ return new EvalParameterPack(expansionPattern, getTemplateDefinition());
+ }
+
+ @Override
+ public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
+ int maxdepth, IASTNode point) {
+ ICPPEvaluation expansionPattern = fExpansionPattern.computeForFunctionCall(parameterMap, maxdepth, point);
+ if (expansionPattern == fExpansionPattern)
+ return this;
+ return new EvalParameterPack(expansionPattern, getTemplateDefinition());
+ }
+
+ @Override
+ public int determinePackSize(ICPPTemplateParameterMap tpMap) {
+ return CPPTemplates.PACK_SIZE_NOT_FOUND;
+ }
+
+ @Override
+ public boolean referencesTemplateParameter() {
+ return fExpansionPattern.referencesTemplateParameter();
+ }
+
+ @Override
+ public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
+ buffer.putShort(ITypeMarshalBuffer.EVAL_PARAMETER_PACK);
+ buffer.marshalEvaluation(fExpansionPattern, includeValue);
+ marshalTemplateDefinition(buffer);
+ }
+
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
+ ICPPEvaluation expansionPattern = (ICPPEvaluation) buffer.unmarshalEvaluation();
+ IBinding templateDefinition = buffer.unmarshalBinding();
+ return new EvalParameterPack(expansionPattern, templateDefinition);
+ }
+} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
index 60b0602..59cccee 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
@@ -121,11 +121,11 @@ public class EvalTypeId extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
- int firstByte = ITypeMarshalBuffer.EVAL_TYPE_ID;
+ short firstBytes = ITypeMarshalBuffer.EVAL_TYPE_ID;
if (includeValue)
- firstByte |= ITypeMarshalBuffer.FLAG1;
+ firstBytes |= ITypeMarshalBuffer.FLAG1;
- buffer.putByte((byte) firstByte);
+ buffer.putShort(firstBytes);
buffer.marshalType(fInputType);
if (includeValue) {
buffer.putInt(fArguments.length);
@@ -136,10 +136,10 @@ public class EvalTypeId extends CPPDependentEvaluation {
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
IType type= buffer.unmarshalType();
ICPPEvaluation[] args= null;
- if ((firstByte & ITypeMarshalBuffer.FLAG1) != 0) {
+ if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0) {
int len= buffer.getInt();
args = new ICPPEvaluation[len];
for (int i = 0; i < args.length; i++) {
@@ -153,19 +153,9 @@ public class EvalTypeId extends CPPDependentEvaluation {
@Override
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
- ICPPEvaluation[] args = fArguments;
- if (fArguments != null) {
- for (int i = 0; i < fArguments.length; i++) {
- ICPPEvaluation arg = fArguments[i].instantiate(tpMap, packOffset, within, maxdepth, point);
- if (arg != fArguments[i]) {
- if (args == fArguments) {
- args = new ICPPEvaluation[fArguments.length];
- System.arraycopy(fArguments, 0, args, 0, fArguments.length);
- }
- args[i] = arg;
- }
- }
- }
+ ICPPEvaluation[] args = null;
+ if (fArguments != null)
+ args = instantiateCommaSeparatedSubexpressions(fArguments, tpMap, packOffset, within, maxdepth, point);
IType type = CPPTemplates.instantiateType(fInputType, tpMap, packOffset, within, point);
if (args == fArguments && type == fInputType)
return this;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java
index f3dc221..147d903 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java
@@ -300,14 +300,14 @@ public class EvalUnary extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
- buffer.putByte(ITypeMarshalBuffer.EVAL_UNARY);
+ buffer.putShort(ITypeMarshalBuffer.EVAL_UNARY);
buffer.putByte((byte) fOperator);
buffer.marshalEvaluation(fArgument, includeValue);
buffer.marshalBinding(fAddressOfQualifiedNameBinding);
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int op= buffer.getByte();
ICPPEvaluation arg= (ICPPEvaluation) buffer.unmarshalEvaluation();
IBinding binding= buffer.unmarshalBinding();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java
index c7ade03..417c079 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java
@@ -175,13 +175,13 @@ public class EvalUnaryTypeID extends CPPDependentEvaluation {
@Override
public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException {
- buffer.putByte(ITypeMarshalBuffer.EVAL_UNARY_TYPE_ID);
+ buffer.putShort(ITypeMarshalBuffer.EVAL_UNARY_TYPE_ID);
buffer.putByte((byte) fOperator);
buffer.marshalType(fOrigType);
marshalTemplateDefinition(buffer);
}
- public static ISerializableEvaluation unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
int op= buffer.getByte();
IType arg= buffer.unmarshalType();
IBinding templateDefinition= buffer.unmarshalBinding();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java
index eb52bce..d3f5602 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java
@@ -64,7 +64,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
@@ -518,7 +517,7 @@ public class LookupData extends ScopeLookupData {
int count= 0;
if (functionArgs != null) {
for (ICPPEvaluation arg : functionArgs) {
- if (arg instanceof EvalFixed && arg.getTypeOrFunctionSet(null) instanceof ICPPParameterPackType)
+ if (arg instanceof EvalParameterPack)
count++;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SignatureBuilder.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SignatureBuilder.java
index 7ec523e..684dbec 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SignatureBuilder.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/SignatureBuilder.java
@@ -25,8 +25,8 @@ import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.core.runtime.CoreException;
class SignatureBuilder implements ITypeMarshalBuffer {
- private static final byte NULL_TYPE= 0;
- private static final byte UNSTORABLE_TYPE= (byte) -1;
+ private static final short NULL_TYPE = 0x0000;
+ private static final short UNSTORABLE_TYPE = 0x001D;
private final StringBuilder fBuffer;
@@ -51,7 +51,7 @@ class SignatureBuilder implements ITypeMarshalBuffer {
if (binding instanceof ISerializableType) {
((ISerializableType) binding).marshal(this);
} else if (binding == null) {
- putByte(NULL_TYPE);
+ putShort(NULL_TYPE);
} else {
appendSeparator();
if (binding instanceof ICPPBinding) {
@@ -73,19 +73,19 @@ class SignatureBuilder implements ITypeMarshalBuffer {
if (type instanceof ISerializableType) {
((ISerializableType) type).marshal(this);
} else if (type == null) {
- putByte(NULL_TYPE);
+ putShort(NULL_TYPE);
} else if (type instanceof IBinding) {
marshalBinding((IBinding) type);
} else {
assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + " (" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- putByte(UNSTORABLE_TYPE);
+ putShort(UNSTORABLE_TYPE);
}
}
@Override
public void marshalEvaluation(ISerializableEvaluation eval, boolean includeValues) throws CoreException {
if (eval == null) {
- putByte(NULL_TYPE);
+ putShort(NULL_TYPE);
} else {
eval.marshal(this, includeValues);
}
@@ -94,16 +94,16 @@ class SignatureBuilder implements ITypeMarshalBuffer {
@Override
public void marshalValue(IValue value) throws CoreException {
if (value instanceof Value) {
- ((Value) value).marshall(this);
+ ((Value) value).marshal(this);
} else {
- putByte(NULL_TYPE);
+ putShort(NULL_TYPE);
}
}
@Override
public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException {
if (arg.isNonTypeValue()) {
- putByte(VALUE);
+ putShort(VALUE);
arg.getNonTypeEvaluation().marshal(this, true);
} else {
marshalType(arg.getTypeValue());
@@ -123,6 +123,12 @@ class SignatureBuilder implements ITypeMarshalBuffer {
}
@Override
+ public void putShort(short value) {
+ appendSeparator();
+ fBuffer.append(value);
+ }
+
+ @Override
public void putInt(int value) {
appendSeparator();
fBuffer.append(value);
@@ -188,6 +194,11 @@ class SignatureBuilder implements ITypeMarshalBuffer {
}
@Override
+ public short getShort() throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public int getInt() throws CoreException {
throw new UnsupportedOperationException();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java
index d77e3e9..c1bccc5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java
@@ -63,11 +63,11 @@ public class TypeOfDependentExpression implements ICPPUnknownType, ISerializable
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
- buffer.putByte(ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE);
+ buffer.putShort(ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE);
buffer.marshalEvaluation(fEvaluation, false);
}
- public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
+ public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
ISerializableEvaluation eval= buffer.unmarshalEvaluation();
if (eval instanceof ICPPEvaluation)
return new TypeOfDependentExpression((ICPPEvaluation) eval);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
index 476aa1d..aa0d6e9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
@@ -85,6 +85,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFunctionSet;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalID;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalInitList;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalMemberAccess;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalParameterPack;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnary;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnaryTypeID;
@@ -375,6 +376,14 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
e= new EvalMemberAccess(a2, e.getOwnerValueCategory(), b2, e.isPointerDeref(), templateDefinition2);
return e;
}
+ if (eval instanceof EvalParameterPack) {
+ EvalParameterPack e = (EvalParameterPack) eval;
+ ICPPEvaluation a = e.getExpansionPattern();
+ ICPPEvaluation a2 = getCompositeEvaluation(a);
+ if (a != a2 || templateDefinition != templateDefinition2)
+ e = new EvalParameterPack(a2, templateDefinition2);
+ return e;
+ }
if (eval instanceof EvalTypeId) {
EvalTypeId e= (EvalTypeId) eval;
IType a = e.getInputType();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
index b56e4eb..e10beb8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
@@ -232,11 +232,12 @@ public class PDOM extends PlatformObject implements IPDOM {
* 139.0 - More efficient and robust storage of types and template arguments, bug 395243.
* 140.0 - Enumerators with dependent values, bug 389009.
* 140.1 - Mechanism for tagging nodes with extended data, bug 400020
- * 141.0 - Storing enclosing template bindings for evaluations, bug 399829
+ * 141.0 - Storing enclosing template bindings for evaluations, bug 399829.
+ * 142.0 - Changed marshalling of evaluations to allow more than 15 evaluation kinds, bug 401479.
*/
- private static final int MIN_SUPPORTED_VERSION= version(141, 0);
- private static final int MAX_SUPPORTED_VERSION= version(141, Short.MAX_VALUE);
- private static final int DEFAULT_VERSION = version(141, 0);
+ private static final int MIN_SUPPORTED_VERSION= version(142, 0);
+ private static final int MAX_SUPPORTED_VERSION= version(142, Short.MAX_VALUE);
+ private static final int DEFAULT_VERSION = version(142, 0);
private static int version(int major, int minor) {
return (major << 16) + minor;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java
index 99d99e8..bb3af31 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java
@@ -35,10 +35,10 @@ import org.eclipse.core.runtime.CoreException;
*/
public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
public static final byte[] EMPTY= { 0, 0, 0, 0, 0, 0 };
- public static final byte NULL_TYPE= 0;
- public static final byte INDIRECT_TYPE= (byte) -1;
- public static final byte BINDING_TYPE= (byte) -2;
- public static final byte UNSTORABLE_TYPE= (byte) -3;
+ public static final byte NULL_TYPE = 0x00;
+ public static final byte INDIRECT_TYPE = 0x1F;
+ public static final byte BINDING_TYPE = 0x1E;
+ public static final byte UNSTORABLE_TYPE = 0x1D;
public static final IType UNSTORABLE_TYPE_PROBLEM = new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED);
@@ -83,13 +83,13 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
if (binding instanceof ISerializableType) {
((ISerializableType) binding).marshal(this);
} else if (binding == null) {
- putByte(NULL_TYPE);
+ putShort(NULL_TYPE);
} else {
PDOMNode pb= fLinkage.addTypeBinding(binding);
if (pb == null) {
- putByte(UNSTORABLE_TYPE);
+ putShort(UNSTORABLE_TYPE);
} else {
- putByte(BINDING_TYPE);
+ putShort(BINDING_TYPE);
putByte((byte) 0);
putRecordPointer(pb.getRecord());
}
@@ -98,19 +98,17 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
@Override
public IBinding unmarshalBinding() throws CoreException {
- if (fPos >= fBuffer.length)
- throw unmarshallingError();
-
- byte firstByte= fBuffer[fPos];
- if (firstByte == BINDING_TYPE) {
- fPos += 2;
+ int oldPos = fPos;
+ short firstBytes = getShort();
+ if (firstBytes == BINDING_TYPE) {
+ fPos += 1;
long rec= getRecordPointer();
return (IBinding) fLinkage.getNode(rec);
- } else if (firstByte == NULL_TYPE || firstByte == UNSTORABLE_TYPE) {
- fPos++;
+ } else if (firstBytes == NULL_TYPE || firstBytes == UNSTORABLE_TYPE) {
return null;
}
+ fPos = oldPos; // fLinkage.unmarshalBinding() will read firstBytes again
return fLinkage.unmarshalBinding(this);
}
@@ -119,40 +117,37 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
if (type instanceof ISerializableType) {
((ISerializableType) type).marshal(this);
} else if (type == null) {
- putByte(NULL_TYPE);
+ putShort(NULL_TYPE);
} else if (type instanceof IBinding) {
marshalBinding((IBinding) type);
} else {
assert false : "Cannot serialize " + ASTTypeUtil.getType(type) + " (" + type.getClass().getName() + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- putByte(UNSTORABLE_TYPE);
+ putShort(UNSTORABLE_TYPE);
}
}
@Override
public IType unmarshalType() throws CoreException {
- if (fPos >= fBuffer.length)
- throw unmarshallingError();
-
- byte firstByte= fBuffer[fPos];
- if (firstByte == BINDING_TYPE) {
- fPos += 2;
+ int oldPos = fPos;
+ short firstBytes = getShort();
+ if (firstBytes == BINDING_TYPE) {
+ fPos += 1;
long rec= getRecordPointer();
return (IType) fLinkage.getNode(rec);
- } else if (firstByte == NULL_TYPE) {
- fPos++;
+ } else if (firstBytes == NULL_TYPE) {
return null;
- } else if (firstByte == UNSTORABLE_TYPE) {
- fPos++;
+ } else if (firstBytes == UNSTORABLE_TYPE) {
return UNSTORABLE_TYPE_PROBLEM;
}
+ fPos = oldPos; // fLinkage.unmarshalType() will read firstBytes again
return fLinkage.unmarshalType(this);
}
@Override
public void marshalEvaluation(ISerializableEvaluation eval, boolean includeValues) throws CoreException {
if (eval == null) {
- putByte(NULL_TYPE);
+ putShort(NULL_TYPE);
} else {
eval.marshal(this, includeValues);
}
@@ -160,23 +155,15 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
@Override
public ISerializableEvaluation unmarshalEvaluation() throws CoreException {
- if (fPos >= fBuffer.length)
- throw unmarshallingError();
-
- byte firstByte= fBuffer[fPos];
- if (firstByte == NULL_TYPE) {
- fPos++;
- return null;
- }
return fLinkage.unmarshalEvaluation(this);
}
@Override
public void marshalValue(IValue value) throws CoreException {
if (value instanceof Value) {
- ((Value) value).marshall(this);
+ ((Value) value).marshal(this);
} else {
- putByte(NULL_TYPE);
+ putShort(NULL_TYPE);
}
}
@@ -191,7 +178,7 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
@Override
public void marshalTemplateArgument(ICPPTemplateArgument arg) throws CoreException {
if (arg.isNonTypeValue()) {
- putByte(VALUE);
+ putShort(VALUE);
arg.getNonTypeEvaluation().marshal(this, true);
} else {
final IType typeValue = arg.getTypeValue();
@@ -207,11 +194,12 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
@Override
public ICPPTemplateArgument unmarshalTemplateArgument() throws CoreException {
- int firstByte= getByte();
- if (firstByte == VALUE) {
+ int oldPos = fPos;
+ short firstBytes = getShort();
+ if (firstBytes == VALUE) {
return new CPPTemplateNonTypeArgument((ICPPEvaluation) unmarshalEvaluation(), null);
} else {
- fPos--;
+ fPos = oldPos;
IType type = unmarshalType();
IType originalType = unmarshalType();
if (originalType == null || originalType == UNSTORABLE_TYPE_PROBLEM)
@@ -285,6 +273,11 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
}
@Override
+ public void putShort(short value) {
+ putInt(value);
+ }
+
+ @Override
public void putInt(int value) {
do {
int b = value & 0x7F;
@@ -307,6 +300,14 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
}
@Override
+ public short getShort() throws CoreException {
+ int result = getInt();
+ if (result > Short.MAX_VALUE)
+ unmarshallingError();
+ return (short) result;
+ }
+
+ @Override
public int getInt() throws CoreException {
int b = getByte();
int value = b & 0x7F;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java
index 77608c1..1105005 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCLinkage.java
@@ -344,23 +344,23 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
@Override
public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= buffer.getByte();
- switch((firstByte & ITypeMarshalBuffer.KIND_MASK)) {
+ short firstBytes= buffer.getShort();
+ switch((firstBytes & ITypeMarshalBuffer.KIND_MASK)) {
case ITypeMarshalBuffer.ARRAY_TYPE:
- return CArrayType.unmarshal(firstByte, buffer);
+ return CArrayType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.BASIC_TYPE:
- return CBasicType.unmarshal(firstByte, buffer);
+ return CBasicType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.CVQUALIFIER_TYPE:
- return CQualifierType.unmarshal(firstByte, buffer);
+ return CQualifierType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.FUNCTION_TYPE:
- return CFunctionType.unmarshal(firstByte, buffer);
+ return CFunctionType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.POINTER_TYPE:
- return CPointerType.unmarshal(firstByte, buffer);
+ return CPointerType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.PROBLEM_TYPE:
- return ProblemType.unmarshal(firstByte, buffer);
+ return ProblemType.unmarshal(firstBytes, buffer);
}
- throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$
+ throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first bytes=" + firstBytes)); //$NON-NLS-1$
}
@Override
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
index b07afe5..a9a3b1d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
@@ -111,6 +111,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFunctionSet;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalID;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalInitList;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalMemberAccess;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalParameterPack;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnary;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalUnaryTypeID;
@@ -122,6 +123,7 @@ import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
import org.eclipse.cdt.internal.core.pdom.db.BTree;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
+import org.eclipse.cdt.internal.core.pdom.db.TypeMarshalBuffer;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
@@ -1105,94 +1107,98 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
@Override
public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= buffer.getByte();
- switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) {
+ short firstBytes= buffer.getShort();
+ switch ((firstBytes & ITypeMarshalBuffer.KIND_MASK)) {
case ITypeMarshalBuffer.ARRAY_TYPE:
- return CPPArrayType.unmarshal(firstByte, buffer);
+ return CPPArrayType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.BASIC_TYPE:
- return CPPBasicType.unmarshal(firstByte, buffer);
+ return CPPBasicType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.CVQUALIFIER_TYPE:
- return CPPQualifierType.unmarshal(firstByte, buffer);
+ return CPPQualifierType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.FUNCTION_TYPE:
- return CPPFunctionType.unmarshal(firstByte, buffer);
+ return CPPFunctionType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.POINTER_TYPE:
- return CPPPointerType.unmarshal(firstByte, buffer);
+ return CPPPointerType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.PROBLEM_TYPE:
- return ProblemType.unmarshal(firstByte, buffer);
+ return ProblemType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.REFERENCE_TYPE:
- return CPPReferenceType.unmarshal(firstByte, buffer);
+ return CPPReferenceType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.PACK_EXPANSION_TYPE:
- return CPPParameterPackType.unmarshal(firstByte, buffer);
+ return CPPParameterPackType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.POINTER_TO_MEMBER_TYPE:
- return CPPPointerToMemberType.unmarshal(firstByte, buffer);
+ return CPPPointerToMemberType.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.DEPENDENT_EXPRESSION_TYPE:
- return TypeOfDependentExpression.unmarshal(firstByte, buffer);
+ return TypeOfDependentExpression.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.UNKNOWN_MEMBER:
- IBinding binding= CPPUnknownMember.unmarshal(getPDOM(), firstByte, buffer);
+ IBinding binding= CPPUnknownMember.unmarshal(getPDOM(), firstBytes, buffer);
if (binding instanceof IType)
return (IType) binding;
break;
case ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE:
- return CPPUnknownClassInstance.unmarshal(getPDOM(), firstByte, buffer);
+ return CPPUnknownClassInstance.unmarshal(getPDOM(), firstBytes, buffer);
case ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE:
- return CPPDeferredClassInstance.unmarshal(getPDOM(), firstByte, buffer);
+ return CPPDeferredClassInstance.unmarshal(getPDOM(), firstBytes, buffer);
case ITypeMarshalBuffer.ALIAS_TEMPLATE:
- return CPPAliasTemplateInstance.unmarshal(firstByte, buffer);
+ return CPPAliasTemplateInstance.unmarshal(firstBytes, buffer);
}
- throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$
+ throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first bytes=" + firstBytes)); //$NON-NLS-1$
}
@Override
public IBinding unmarshalBinding(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= buffer.getByte();
- switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) {
+ short firstBytes= buffer.getShort();
+ switch ((firstBytes & ITypeMarshalBuffer.KIND_MASK)) {
case ITypeMarshalBuffer.UNKNOWN_MEMBER:
- return CPPUnknownMember.unmarshal(getPDOM(), firstByte, buffer);
+ return CPPUnknownMember.unmarshal(getPDOM(), firstBytes, buffer);
case ITypeMarshalBuffer.UNKNOWN_MEMBER_CLASS_INSTANCE:
- return CPPUnknownClassInstance.unmarshal(getPDOM(), firstByte, buffer);
+ return CPPUnknownClassInstance.unmarshal(getPDOM(), firstBytes, buffer);
case ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE:
- return CPPDeferredClassInstance.unmarshal(getPDOM(), firstByte, buffer);
+ return CPPDeferredClassInstance.unmarshal(getPDOM(), firstBytes, buffer);
}
- throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$
+ throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first bytes=" + firstBytes)); //$NON-NLS-1$
}
@Override
public ISerializableEvaluation unmarshalEvaluation(ITypeMarshalBuffer buffer) throws CoreException {
- int firstByte= buffer.getByte();
- switch ((firstByte & ITypeMarshalBuffer.KIND_MASK)) {
+ short firstBytes= buffer.getShort();
+ if (firstBytes == TypeMarshalBuffer.NULL_TYPE)
+ return null;
+ switch ((firstBytes & ITypeMarshalBuffer.KIND_MASK)) {
case ITypeMarshalBuffer.EVAL_BINARY:
- return EvalBinary.unmarshal(firstByte, buffer);
+ return EvalBinary.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_BINARY_TYPE_ID:
- return EvalBinaryTypeId.unmarshal(firstByte, buffer);
+ return EvalBinaryTypeId.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_BINDING:
- return EvalBinding.unmarshal(firstByte, buffer);
+ return EvalBinding.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_COMMA:
- return EvalComma.unmarshal(firstByte, buffer);
+ return EvalComma.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_COMPOUND:
- return EvalCompound.unmarshal(firstByte, buffer);
+ return EvalCompound.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_CONDITIONAL:
- return EvalConditional.unmarshal(firstByte, buffer);
+ return EvalConditional.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_FIXED:
- return EvalFixed.unmarshal(firstByte, buffer);
+ return EvalFixed.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_FUNCTION_CALL:
- return EvalFunctionCall.unmarshal(firstByte, buffer);
+ return EvalFunctionCall.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_FUNCTION_SET:
- return EvalFunctionSet.unmarshal(firstByte, buffer);
+ return EvalFunctionSet.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_ID:
- return EvalID.unmarshal(firstByte, buffer);
+ return EvalID.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_INIT_LIST:
- return EvalInitList.unmarshal(firstByte, buffer);
+ return EvalInitList.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_MEMBER_ACCESS:
- return EvalMemberAccess.unmarshal(firstByte, buffer);
+ return EvalMemberAccess.unmarshal(firstBytes, buffer);
+ case ITypeMarshalBuffer.EVAL_PARAMETER_PACK:
+ return EvalParameterPack.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_TYPE_ID:
- return EvalTypeId.unmarshal(firstByte, buffer);
+ return EvalTypeId.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_UNARY:
- return EvalUnary.unmarshal(firstByte, buffer);
+ return EvalUnary.unmarshal(firstBytes, buffer);
case ITypeMarshalBuffer.EVAL_UNARY_TYPE_ID:
- return EvalUnaryTypeID.unmarshal(firstByte, buffer);
+ return EvalUnaryTypeID.unmarshal(firstBytes, buffer);
}
- throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal an evaluation, first byte=" + firstByte)); //$NON-NLS-1$
+ throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal an evaluation, first bytes=" + firstBytes)); //$NON-NLS-1$
}
}