1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-07 10:33:26 +02:00

Bug 401479 - Error involving variadic templates and function objects

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>
This commit is contained in:
Nathan Ridge 2013-02-21 20:46:08 -05:00 committed by Sergey Prigogin
parent 773aa77a2a
commit 96a4a227aa
49 changed files with 637 additions and 423 deletions

View file

@ -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();
// };

View file

@ -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();
@ -72,6 +84,11 @@ public interface ITypeMarshalBuffer {
int getByte() throws CoreException;
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.
*/
@ -92,6 +109,12 @@ public interface ITypeMarshalBuffer {
void putByte(byte data);
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.

View file

@ -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());
}

View file

@ -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());
}

View file

@ -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();

View file

@ -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;
}

View file

@ -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);

View file

@ -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];

View file

@ -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

View file

@ -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);
}
}

View file

@ -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;
}

View file

@ -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();

View file

@ -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();

View file

@ -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);

View file

@ -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();

View file

@ -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
}
}

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}

View file

@ -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();

View file

@ -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);

View file

@ -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;
@ -94,6 +97,63 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation {
buffer.marshalBinding(getTemplateDefinition());
}
/**
* 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().

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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++) {

View file

@ -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);

View file

@ -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();

View file

@ -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;

View file

@ -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;

View file

@ -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++) {

View file

@ -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++) {

View file

@ -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());

View file

@ -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;

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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();

View file

@ -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();

View file

@ -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++;
}
}

View file

@ -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());
@ -122,6 +122,12 @@ class SignatureBuilder implements ITypeMarshalBuffer {
fBuffer.append(value);
}
@Override
public void putShort(short value) {
appendSeparator();
fBuffer.append(value);
}
@Override
public void putInt(int value) {
appendSeparator();
@ -187,6 +193,11 @@ class SignatureBuilder implements ITypeMarshalBuffer {
throw new UnsupportedOperationException();
}
@Override
public short getShort() throws CoreException {
throw new UnsupportedOperationException();
}
@Override
public int getInt() throws CoreException {
throw new UnsupportedOperationException();

View file

@ -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);

View file

@ -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();

View file

@ -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;

View file

@ -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)
@ -284,6 +272,11 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
return result;
}
@Override
public void putShort(short value) {
putInt(value);
}
@Override
public void putInt(int value) {
do {
@ -306,6 +299,14 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer {
} while (value != 0);
}
@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();

View file

@ -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

View file

@ -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$
}
}