mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
replaced constants in ICPPASTOperatorName with new OverloadableOperator enum
This commit is contained in:
parent
65ff00c607
commit
8342cee582
11 changed files with 211 additions and 330 deletions
|
@ -107,6 +107,7 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1450,7 +1451,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertNotNull(methods);
|
assertNotNull(methods);
|
||||||
int count=0;
|
int count=0;
|
||||||
for(int i=0; i<methods.length; i++) {
|
for(int i=0; i<methods.length; i++) {
|
||||||
boolean eq= Arrays.equals(methods[i].getName().toCharArray(), ICPPASTOperatorName.OPERATOR_ASSIGN);
|
boolean eq= Arrays.equals(methods[i].getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
|
||||||
count+= eq ? 1 : 0;
|
count+= eq ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1460,7 +1461,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertNotNull(methods);
|
assertNotNull(methods);
|
||||||
count=0;
|
count=0;
|
||||||
for(int i=0; i<methods.length; i++) {
|
for(int i=0; i<methods.length; i++) {
|
||||||
boolean eq= Arrays.equals(methods[i].getName().toCharArray(), ICPPASTOperatorName.OPERATOR_ASSIGN);
|
boolean eq= Arrays.equals(methods[i].getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
|
||||||
count+= eq ? 1 : 0;
|
count+= eq ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1483,7 +1484,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertNotNull(methods);
|
assertNotNull(methods);
|
||||||
int count=0;
|
int count=0;
|
||||||
for(int i=0; i<methods.length; i++) {
|
for(int i=0; i<methods.length; i++) {
|
||||||
boolean eq= Arrays.equals(methods[i].getName().toCharArray(), ICPPASTOperatorName.OPERATOR_ASSIGN);
|
boolean eq= Arrays.equals(methods[i].getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
|
||||||
count+= eq ? 1 : 0;
|
count+= eq ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1493,7 +1494,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertNotNull(methods);
|
assertNotNull(methods);
|
||||||
count=0;
|
count=0;
|
||||||
for(int i=0; i<methods.length; i++) {
|
for(int i=0; i<methods.length; i++) {
|
||||||
boolean eq= Arrays.equals(methods[i].getName().toCharArray(), ICPPASTOperatorName.OPERATOR_ASSIGN);
|
boolean eq= Arrays.equals(methods[i].getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray());
|
||||||
count+= eq ? 1 : 0;
|
count+= eq ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005 IBM Corporation and others.
|
* Copyright (c) 2005 - 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,101 +7,14 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Mike Kucera - simplification
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface represents a C++ overloaded operator member function.
|
* This interface represents a C++ overloaded operator member function name.
|
||||||
*
|
|
||||||
* @author dsteffle
|
|
||||||
*/
|
*/
|
||||||
public interface ICPPASTOperatorName extends IASTName {
|
public interface ICPPASTOperatorName extends IASTName {
|
||||||
public static final String OPERATOR = "operator "; //$NON-NLS-1$
|
|
||||||
|
|
||||||
public static final String OP_GT = ">"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_GT = new String(OPERATOR + OP_GT).toCharArray();
|
|
||||||
public static final String OP_LT = "<"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_LT = new String(OPERATOR + OP_LT).toCharArray();
|
|
||||||
public static final String OP_NOT = "!"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_NOT = new String(OPERATOR + OP_NOT).toCharArray();
|
|
||||||
public static final String OP_COMPL = "~"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_COMPL = new String(OPERATOR + OP_COMPL).toCharArray();
|
|
||||||
public static final String OP_BITOR = "|"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_BITOR = new String(OPERATOR + OP_BITOR).toCharArray();
|
|
||||||
public static final String OP_AMPER = "&"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_AMPER = new String(OPERATOR + OP_AMPER).toCharArray();
|
|
||||||
public static final String OP_XOR = "^"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_XOR = new String(OPERATOR + OP_XOR).toCharArray();
|
|
||||||
public static final String OP_MOD = "%"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_MOD = new String(OPERATOR + OP_MOD).toCharArray();
|
|
||||||
public static final String OP_DIV = "/"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_DIV = new String(OPERATOR + OP_DIV).toCharArray();
|
|
||||||
public static final String OP_STAR = "*"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_STAR = new String(OPERATOR + OP_STAR).toCharArray();
|
|
||||||
public static final String OP_PLUS = "+"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_PLUS = new String(OPERATOR + OP_PLUS).toCharArray();
|
|
||||||
public static final String OP_BRACKET = "[]"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_BRACKET = new String(OPERATOR + OP_BRACKET).toCharArray();
|
|
||||||
public static final String OP_PAREN = "()"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_PAREN = new String(OPERATOR + OP_PAREN).toCharArray();
|
|
||||||
public static final String OP_ARROW = "->"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_ARROW = new String(OPERATOR + OP_ARROW).toCharArray();
|
|
||||||
public static final String OP_ARROWSTAR = "->*"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_ARROWSTAR = new String(OPERATOR + OP_ARROWSTAR).toCharArray();
|
|
||||||
public static final String OP_COMMA = ","; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_COMMA = new String(OPERATOR + OP_COMMA).toCharArray();
|
|
||||||
public static final String OP_MINUS = "-"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_MINUS = new String(OPERATOR + OP_MINUS).toCharArray();
|
|
||||||
public static final String OP_DECR = "--"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_DECR = new String(OPERATOR + OP_DECR).toCharArray();
|
|
||||||
public static final String OP_INCR = "++"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_INCR = new String(OPERATOR + OP_INCR).toCharArray();
|
|
||||||
public static final String OP_OR = "||"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_OR = new String(OPERATOR + OP_OR).toCharArray();
|
|
||||||
public static final String OP_AND = "&&"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_AND = new String(OPERATOR + OP_AND).toCharArray();
|
|
||||||
public static final String OP_ASSIGN = "="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_ASSIGN = new String(OPERATOR + OP_ASSIGN).toCharArray();
|
|
||||||
public static final String OP_GTEQUAL = ">="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_GTEQUAL = new String(OPERATOR + OP_GTEQUAL).toCharArray();
|
|
||||||
public static final String OP_LTEQUAL = "<="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_LTEQUAL = new String(OPERATOR + OP_LTEQUAL).toCharArray();
|
|
||||||
public static final String OP_NOTEQUAL = "!="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_NOTEQUAL = new String(OPERATOR + OP_NOTEQUAL).toCharArray();
|
|
||||||
public static final String OP_EQUAL = "=="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_EQUAL = new String(OPERATOR + OP_EQUAL).toCharArray();
|
|
||||||
public static final String OP_SHIFTR = ">>"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_SHIFTR = new String(OPERATOR + OP_SHIFTR).toCharArray();
|
|
||||||
public static final String OP_SHIFTL = "<<"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_SHIFTL = new String(OPERATOR + OP_SHIFTL).toCharArray();
|
|
||||||
public static final String OP_SHIFTL_ASSIGN = "<<="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_SHIFTL_ASSIGN = new String(OPERATOR + OP_SHIFTL_ASSIGN).toCharArray();
|
|
||||||
public static final String OP_SHIFTR_ASSIGN = ">>="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_SHIFTR_ASSIGN = new String(OPERATOR + OP_SHIFTR_ASSIGN).toCharArray();
|
|
||||||
public static final String OP_BITOR_ASSIGN = "|="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_BITOR_ASSIGN = new String(OPERATOR + OP_BITOR_ASSIGN).toCharArray();
|
|
||||||
public static final String OP_AMPER_ASSIGN = "&="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_AMPER_ASSIGN = new String(OPERATOR + OP_AMPER_ASSIGN).toCharArray();
|
|
||||||
public static final String OP_XOR_ASSIGN = "^="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_XOR_ASSIGN = new String(OPERATOR + OP_XOR_ASSIGN).toCharArray();
|
|
||||||
public static final String OP_MOD_ASSIGN = "%="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_MOD_ASSIGN = new String(OPERATOR + OP_MOD_ASSIGN).toCharArray();
|
|
||||||
public static final String OP_DIV_ASSIGN = "/="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_DIV_ASSIGN = new String(OPERATOR + OP_DIV_ASSIGN).toCharArray();
|
|
||||||
public static final String OP_STAR_ASSIGN = "*="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_STAR_ASSIGN = new String(OPERATOR + OP_STAR_ASSIGN).toCharArray();
|
|
||||||
public static final String OP_MINUS_ASSIGN = "-="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_MINUS_ASSIGN = new String(OPERATOR + OP_MINUS_ASSIGN).toCharArray();
|
|
||||||
public static final String OP_PLUS_ASSIGN = "+="; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_PLUS_ASSIGN = new String(OPERATOR + OP_PLUS_ASSIGN).toCharArray();
|
|
||||||
public static final String OP_NEW = "new"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_NEW = new String(OPERATOR + OP_NEW).toCharArray();
|
|
||||||
public static final String OP_DELETE_ARRAY = "delete[]"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_DELETE_ARRAY = new String(OPERATOR + OP_DELETE_ARRAY).toCharArray();
|
|
||||||
public static final String OP_DELETE = "delete"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_DELETE = new String(OPERATOR + OP_DELETE).toCharArray();
|
|
||||||
public static final String OP_NEW_ARRAY = "new[]"; //$NON-NLS-1$
|
|
||||||
public static final char[] OPERATOR_NEW_ARRAY = new String(OPERATOR + OP_NEW_ARRAY).toCharArray();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,10 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerASTVisitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -82,11 +84,11 @@ public class CPPASTCompositeTypeSpecifier extends CPPASTBaseDeclSpecifier
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMemberDeclaration(IASTDeclaration declaration) {
|
public void addMemberDeclaration(IASTDeclaration decl) {
|
||||||
declarations = (IASTDeclaration[]) ArrayUtil.append( IASTDeclaration.class, declarations, declaration );
|
declarations = (IASTDeclaration[]) ArrayUtil.append( IASTDeclaration.class, declarations, decl );
|
||||||
if(declaration != null) {
|
if(decl != null) {
|
||||||
declaration.setParent(this);
|
decl.setParent(this);
|
||||||
declaration.setPropertyInParent(MEMBER_DECLARATION);
|
decl.setPropertyInParent(decl instanceof ICPPASTVisiblityLabel ? VISIBILITY_LABEL : MEMBER_DECLARATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,7 @@ public class CPPASTFieldReference extends CPPASTNode implements
|
||||||
public CPPASTFieldReference() {
|
public CPPASTFieldReference() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPPASTFieldReference(IASTName name, IASTExpression owner, boolean isTemplate,
|
public CPPASTFieldReference(IASTName name, IASTExpression owner, boolean isDeref, boolean isTemplate) {
|
||||||
boolean isDeref) {
|
|
||||||
setFieldName(name);
|
setFieldName(name);
|
||||||
setFieldOwner(owner);
|
setFieldOwner(owner);
|
||||||
this.isTemplate = isTemplate;
|
this.isTemplate = isTemplate;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005 IBM Corporation and others.
|
* Copyright (c) 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,165 +12,15 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
|
||||||
|
|
||||||
/**
|
|
||||||
* The imlemented ICPPASTOperatorName.
|
|
||||||
*
|
|
||||||
* @author dsteffle
|
|
||||||
*/
|
|
||||||
public class CPPASTOperatorName extends CPPASTName implements ICPPASTOperatorName {
|
public class CPPASTOperatorName extends CPPASTName implements ICPPASTOperatorName {
|
||||||
private static final int FIRST_CHAR_AFTER_OPERATOR = 8;
|
|
||||||
|
|
||||||
private static final String LBRACKET = "["; //$NON-NLS-1$
|
|
||||||
private static final String RBRACKET = "]"; //$NON-NLS-1$
|
|
||||||
private static final String LPAREN = "("; //$NON-NLS-1$
|
|
||||||
private static final String RPAREN = ")"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private boolean wasSet=false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Primary constructor that should be used to initialize the CPPASTOperatorName.
|
||||||
*
|
* @throws NullPointerException if operator is null
|
||||||
*/
|
*/
|
||||||
public CPPASTOperatorName() {
|
public CPPASTOperatorName(OverloadableOperator operator) {
|
||||||
super();
|
super(operator.toCharArray());
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Primary consturctor that should be used to initialize the CPPASTOperatorName.
|
|
||||||
* @param name the char[] name to initialize to
|
|
||||||
*/
|
|
||||||
public CPPASTOperatorName(char[] name) {
|
|
||||||
super(name);
|
|
||||||
wasSet=true;
|
|
||||||
super.setName(enforceOpStandard(super.toString()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the char[] of the name and ensures that the name will be standardized
|
|
||||||
* so that it will be of the form "operator op".
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public char[] toCharArray() {
|
|
||||||
if (!wasSet) {
|
|
||||||
super.setName(enforceOpStandard(super.toString()));
|
|
||||||
wasSet=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.toCharArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the String of the name and ensures that the name will be standardized
|
|
||||||
* so that it will be of the form "operator op".
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String toString() {
|
|
||||||
if (!wasSet) {
|
|
||||||
super.setName(enforceOpStandard(super.toString()));
|
|
||||||
wasSet=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the name of this CPPASTOperatorName and ensures that the name follows
|
|
||||||
* the standard "operator op".
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
public void setName(char[] name) {
|
|
||||||
super.setName(enforceOpStandard(new String(name)));
|
|
||||||
wasSet=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private char[] enforceOpStandard(String name) {
|
|
||||||
// need to use indexOf (could optimize by skipping the first 8 chars?)
|
|
||||||
if (name.indexOf(OP_NEW, FIRST_CHAR_AFTER_OPERATOR) >=FIRST_CHAR_AFTER_OPERATOR && name.indexOf(LBRACKET, FIRST_CHAR_AFTER_OPERATOR) >=FIRST_CHAR_AFTER_OPERATOR && name.indexOf(RBRACKET, FIRST_CHAR_AFTER_OPERATOR) >=FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_NEW_ARRAY;
|
|
||||||
} else if (name.indexOf(OP_DELETE, FIRST_CHAR_AFTER_OPERATOR) >=FIRST_CHAR_AFTER_OPERATOR && name.indexOf(LBRACKET, FIRST_CHAR_AFTER_OPERATOR) >=FIRST_CHAR_AFTER_OPERATOR && name.indexOf(RBRACKET, FIRST_CHAR_AFTER_OPERATOR) >=FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_DELETE_ARRAY;
|
|
||||||
} else if (name.indexOf(OP_NEW, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_NEW;
|
|
||||||
} else if (name.indexOf(OP_DELETE, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_DELETE;
|
|
||||||
} else if (name.indexOf(OP_PLUS_ASSIGN, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_PLUS_ASSIGN;
|
|
||||||
} else if (name.indexOf(OP_MINUS_ASSIGN, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_MINUS_ASSIGN;
|
|
||||||
} else if (name.indexOf(OP_STAR_ASSIGN, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_STAR_ASSIGN;
|
|
||||||
} else if (name.indexOf(OP_DIV_ASSIGN, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_DIV_ASSIGN;
|
|
||||||
} else if (name.indexOf(OP_MOD_ASSIGN, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_MOD_ASSIGN;
|
|
||||||
} else if (name.indexOf(OP_XOR_ASSIGN, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_XOR_ASSIGN;
|
|
||||||
} else if (name.indexOf(OP_AMPER_ASSIGN, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_AMPER_ASSIGN;
|
|
||||||
} else if (name.indexOf(OP_BITOR_ASSIGN, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_BITOR_ASSIGN;
|
|
||||||
} else if (name.indexOf(OP_SHIFTR_ASSIGN, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_SHIFTR_ASSIGN;
|
|
||||||
} else if (name.indexOf(OP_SHIFTL_ASSIGN, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_SHIFTL_ASSIGN;
|
|
||||||
} else if (name.indexOf(OP_SHIFTL, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_SHIFTL;
|
|
||||||
} else if (name.indexOf(OP_SHIFTR, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_SHIFTR;
|
|
||||||
} else if (name.indexOf(OP_EQUAL, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_EQUAL;
|
|
||||||
} else if (name.indexOf(OP_NOTEQUAL, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_NOTEQUAL;
|
|
||||||
} else if (name.indexOf(OP_LTEQUAL, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_LTEQUAL;
|
|
||||||
} else if (name.indexOf(OP_GTEQUAL, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_GTEQUAL;
|
|
||||||
} else if (name.indexOf(OP_ASSIGN, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_ASSIGN;
|
|
||||||
} else if (name.indexOf(OP_AND, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_AND;
|
|
||||||
} else if (name.indexOf(OP_OR, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_OR;
|
|
||||||
} else if (name.indexOf(OP_INCR, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_INCR;
|
|
||||||
} else if (name.indexOf(OP_DECR, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_DECR;
|
|
||||||
} else if (name.indexOf(OP_COMMA, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_COMMA;
|
|
||||||
} else if (name.indexOf(OP_ARROWSTAR, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_ARROWSTAR;
|
|
||||||
} else if (name.indexOf(OP_ARROW, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_ARROW;
|
|
||||||
} else if (name.indexOf(LPAREN, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR && name.indexOf(RPAREN, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_PAREN;
|
|
||||||
} else if (name.indexOf(LBRACKET, FIRST_CHAR_AFTER_OPERATOR) >=FIRST_CHAR_AFTER_OPERATOR && name.indexOf(RBRACKET, FIRST_CHAR_AFTER_OPERATOR) >=FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_BRACKET;
|
|
||||||
} else if (name.indexOf(OP_PLUS, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_PLUS;
|
|
||||||
} else if (name.indexOf(OP_MINUS, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_MINUS;
|
|
||||||
} else if (name.indexOf(OP_STAR, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_STAR;
|
|
||||||
} else if (name.indexOf(OP_DIV, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_DIV;
|
|
||||||
} else if (name.indexOf(OP_MOD, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_MOD;
|
|
||||||
} else if (name.indexOf(OP_XOR, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_XOR;
|
|
||||||
} else if (name.indexOf(OP_AMPER, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_AMPER;
|
|
||||||
} else if (name.indexOf(OP_BITOR, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_BITOR;
|
|
||||||
} else if (name.indexOf(OP_COMPL, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_COMPL;
|
|
||||||
} else if (name.indexOf(OP_NOT, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_NOT;
|
|
||||||
} else if (name.indexOf(OP_LT, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_LT;
|
|
||||||
} else if (name.indexOf(OP_GT, FIRST_CHAR_AFTER_OPERATOR) >= FIRST_CHAR_AFTER_OPERATOR) {
|
|
||||||
return OPERATOR_GT;
|
|
||||||
}
|
|
||||||
|
|
||||||
return name.toCharArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
|
@ -142,14 +141,14 @@ public class CPPASTTranslationUnit extends CPPASTNode implements ICPPASTTranslat
|
||||||
IFunctionType newFunctionType = new CPPFunctionType(cpp_void_p, newParms);
|
IFunctionType newFunctionType = new CPPFunctionType(cpp_void_p, newParms);
|
||||||
IParameter[] newTheParms = new IParameter[1];
|
IParameter[] newTheParms = new IParameter[1];
|
||||||
newTheParms[0] = new CPPBuiltinParameter(newParms[0]);
|
newTheParms[0] = new CPPBuiltinParameter(newParms[0]);
|
||||||
temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_NEW, theScope, newFunctionType, newTheParms, false);
|
temp = new CPPImplicitFunction(OverloadableOperator.NEW.toCharArray(), theScope, newFunctionType, newTheParms, false);
|
||||||
try {
|
try {
|
||||||
ASTInternal.addBinding(theScope, temp);
|
ASTInternal.addBinding(theScope, temp);
|
||||||
} catch (DOMException de) {}
|
} catch (DOMException de) {}
|
||||||
|
|
||||||
// void * operator new[] (std::size_t);
|
// void * operator new[] (std::size_t);
|
||||||
temp = null;
|
temp = null;
|
||||||
temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_NEW_ARRAY, theScope, newFunctionType, newTheParms, false);
|
temp = new CPPImplicitFunction(OverloadableOperator.NEW_ARRAY.toCharArray(), theScope, newFunctionType, newTheParms, false);
|
||||||
try {
|
try {
|
||||||
ASTInternal.addBinding(theScope, temp);
|
ASTInternal.addBinding(theScope, temp);
|
||||||
} catch (DOMException de) {}
|
} catch (DOMException de) {}
|
||||||
|
@ -161,14 +160,14 @@ public class CPPASTTranslationUnit extends CPPASTNode implements ICPPASTTranslat
|
||||||
IFunctionType deleteFunctionType = new CPPFunctionType(cpp_void, deleteParms);
|
IFunctionType deleteFunctionType = new CPPFunctionType(cpp_void, deleteParms);
|
||||||
IParameter[] deleteTheParms = new IParameter[1];
|
IParameter[] deleteTheParms = new IParameter[1];
|
||||||
deleteTheParms[0] = new CPPBuiltinParameter(deleteParms[0]);
|
deleteTheParms[0] = new CPPBuiltinParameter(deleteParms[0]);
|
||||||
temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_DELETE, theScope, deleteFunctionType, deleteTheParms, false);
|
temp = new CPPImplicitFunction(OverloadableOperator.DELETE.toCharArray(), theScope, deleteFunctionType, deleteTheParms, false);
|
||||||
try {
|
try {
|
||||||
ASTInternal.addBinding(theScope, temp);
|
ASTInternal.addBinding(theScope, temp);
|
||||||
} catch (DOMException de) {}
|
} catch (DOMException de) {}
|
||||||
|
|
||||||
// void operator delete[](void*);
|
// void operator delete[](void*);
|
||||||
temp = null;
|
temp = null;
|
||||||
temp = new CPPImplicitFunction(ICPPASTOperatorName.OPERATOR_DELETE_ARRAY, theScope, deleteFunctionType, deleteTheParms, false);
|
temp = new CPPImplicitFunction(OverloadableOperator.DELETE_ARRAY.toCharArray(), theScope, deleteFunctionType, deleteTheParms, false);
|
||||||
try {
|
try {
|
||||||
ASTInternal.addBinding(theScope, temp);
|
ASTInternal.addBinding(theScope, temp);
|
||||||
} catch (DOMException de) {}
|
} catch (DOMException de) {}
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
if( !ia.hasUserDeclaredCopyAssignmentOperator() ) {
|
if( !ia.hasUserDeclaredCopyAssignmentOperator() ) {
|
||||||
//copy assignment operator: A& operator = ( const A & )
|
//copy assignment operator: A& operator = ( const A & )
|
||||||
IType refType = new CPPReferenceType( clsType );
|
IType refType = new CPPReferenceType( clsType );
|
||||||
ICPPMethod m = new CPPImplicitMethod( this, ICPPASTOperatorName.OPERATOR_ASSIGN, refType, ps );
|
ICPPMethod m = new CPPImplicitMethod( this, OverloadableOperator.ASSIGN.toCharArray(), refType, ps );
|
||||||
implicits[i++]=m;
|
implicits[i++]=m;
|
||||||
addBinding( m );
|
addBinding( m );
|
||||||
}
|
}
|
||||||
|
@ -483,7 +483,7 @@ class ImplicitsAnalysis {
|
||||||
dcltor = ((IASTFunctionDefinition)members[i]).getDeclarator();
|
dcltor = ((IASTFunctionDefinition)members[i]).getDeclarator();
|
||||||
}
|
}
|
||||||
if( !(dcltor instanceof ICPPASTFunctionDeclarator) ||
|
if( !(dcltor instanceof ICPPASTFunctionDeclarator) ||
|
||||||
!CharArrayUtils.equals( dcltor.getName().toCharArray(), ICPPASTOperatorName.OPERATOR_ASSIGN ) )
|
!CharArrayUtils.equals( dcltor.getName().toCharArray(), OverloadableOperator.ASSIGN.toCharArray() ) )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3368,17 +3368,17 @@ public class CPPSemantics {
|
||||||
LookupData data = null;
|
LookupData data = null;
|
||||||
|
|
||||||
if( exp instanceof IASTUnaryExpression) {
|
if( exp instanceof IASTUnaryExpression) {
|
||||||
astName.setName( ICPPASTOperatorName.OPERATOR_STAR );
|
astName.setName( OverloadableOperator.STAR.toCharArray() );
|
||||||
data = new LookupData( astName );
|
data = new LookupData( astName );
|
||||||
data.forceQualified = true;
|
data.forceQualified = true;
|
||||||
data.functionParameters = IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
data.functionParameters = IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
||||||
} else if( exp instanceof IASTArraySubscriptExpression ){
|
} else if( exp instanceof IASTArraySubscriptExpression ){
|
||||||
astName.setName( ICPPASTOperatorName.OPERATOR_BRACKET );
|
astName.setName( OverloadableOperator.BRACKET.toCharArray() );
|
||||||
data = new LookupData( astName );
|
data = new LookupData( astName );
|
||||||
data.forceQualified = true;
|
data.forceQualified = true;
|
||||||
data.functionParameters = new IASTExpression [] { ((IASTArraySubscriptExpression)exp).getSubscriptExpression() };
|
data.functionParameters = new IASTExpression [] { ((IASTArraySubscriptExpression)exp).getSubscriptExpression() };
|
||||||
} else if( exp instanceof IASTFieldReference ){
|
} else if( exp instanceof IASTFieldReference ){
|
||||||
astName.setName( ICPPASTOperatorName.OPERATOR_ARROW );
|
astName.setName( OverloadableOperator.ARROW.toCharArray() );
|
||||||
data = new LookupData( astName );
|
data = new LookupData( astName );
|
||||||
data.forceQualified = true;
|
data.forceQualified = true;
|
||||||
data.functionParameters = IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
data.functionParameters = IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
||||||
|
|
|
@ -396,8 +396,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
case IToken.t_operator:
|
case IToken.t_operator:
|
||||||
IToken l = LA(1);
|
IToken l = LA(1);
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throwBacktrack(first.getOffset(), l.getEndOffset()
|
throwBacktrack(first.getOffset(), l.getEndOffset() - first.getOffset());
|
||||||
- first.getOffset());
|
|
||||||
case IToken.tIDENTIFIER:
|
case IToken.tIDENTIFIER:
|
||||||
case IToken.tCOMPLETION:
|
case IToken.tCOMPLETION:
|
||||||
case IToken.tEOC:
|
case IToken.tEOC:
|
||||||
|
@ -461,14 +460,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
TemplateParameterManager templateArgs) throws BacktrackException,
|
TemplateParameterManager templateArgs) throws BacktrackException,
|
||||||
EndOfFileException {
|
EndOfFileException {
|
||||||
// we know this is an operator
|
// we know this is an operator
|
||||||
|
|
||||||
IToken operatorToken = consume();
|
IToken operatorToken = consume();
|
||||||
IToken toSend = null;
|
IToken toSend = null;
|
||||||
IASTTypeId typeId = null;
|
IASTTypeId typeId = null;
|
||||||
if (LA(1).isOperator() || LT(1) == IToken.tLPAREN
|
OverloadableOperator op = null;
|
||||||
|| LT(1) == IToken.tLBRACKET) {
|
if (LA(1).isOperator() || LT(1) == IToken.tLPAREN || LT(1) == IToken.tLBRACKET) {
|
||||||
if ((LT(1) == IToken.t_new || LT(1) == IToken.t_delete)
|
if ((LT(1) == IToken.t_new || LT(1) == IToken.t_delete) &&
|
||||||
&& LT(2) == IToken.tLBRACKET && LT(3) == IToken.tRBRACKET) {
|
LT(2) == IToken.tLBRACKET && LT(3) == IToken.tRBRACKET) {
|
||||||
consume(); // new or delete
|
op = LT(1) == IToken.t_new ? OverloadableOperator.NEW_ARRAY : OverloadableOperator.DELETE_ARRAY;
|
||||||
|
consume(); // new or delete
|
||||||
consume(); // lbracket
|
consume(); // lbracket
|
||||||
toSend = consume(); // rbracket
|
toSend = consume(); // rbracket
|
||||||
// vector new and delete operators
|
// vector new and delete operators
|
||||||
|
@ -476,15 +477,17 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
// operator ()
|
// operator ()
|
||||||
consume(); // "("
|
consume(); // "("
|
||||||
toSend = consume(); // ")"
|
toSend = consume(); // ")"
|
||||||
|
op = OverloadableOperator.PAREN;
|
||||||
} else if (LT(1) == IToken.tLBRACKET && LT(2) == IToken.tRBRACKET) {
|
} else if (LT(1) == IToken.tLBRACKET && LT(2) == IToken.tRBRACKET) {
|
||||||
consume(); // "["
|
consume(); // "["
|
||||||
toSend = consume(); // "]"
|
toSend = consume(); // "]"
|
||||||
} else if (LA(1).isOperator())
|
op = OverloadableOperator.BRACKET;
|
||||||
toSend = consume();
|
} else if (LA(1).isOperator()) {
|
||||||
|
toSend = consume();
|
||||||
|
op = OverloadableOperator.valueOf(toSend);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throwBacktrack(operatorToken.getOffset(),
|
throwBacktrack(operatorToken.getOffset(), 0); // toSend must be null
|
||||||
toSend != null ? toSend.getEndOffset()
|
|
||||||
- operatorToken.getOffset() : 0);
|
|
||||||
} else {
|
} else {
|
||||||
// must be a conversion function
|
// must be a conversion function
|
||||||
IToken t = LA(1);
|
IToken t = LA(1);
|
||||||
|
@ -516,13 +519,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
toSend, (hasTemplateId ? templateArgs
|
toSend, (hasTemplateId ? templateArgs
|
||||||
.getTemplateArgumentsList() : null));
|
.getTemplateArgumentsList() : null));
|
||||||
|
|
||||||
OperatorTokenDuple operator = new OperatorTokenDuple(duple);
|
OperatorTokenDuple operatorDuple = new OperatorTokenDuple(duple, op);
|
||||||
if (typeId != null) { // if it's a conversion operator
|
if (typeId != null) { // if it's a conversion operator
|
||||||
operator.setConversionOperator(true);
|
operatorDuple.setConversionOperator(true);
|
||||||
operator.setTypeId(typeId);
|
operatorDuple.setTypeId(typeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return createName(operator);
|
return createName(operatorDuple);
|
||||||
} finally {
|
} finally {
|
||||||
if (grabbedNewInstance)
|
if (grabbedNewInstance)
|
||||||
TemplateParameterManager.returnInstance(templateArgs);
|
TemplateParameterManager.returnInstance(templateArgs);
|
||||||
|
@ -2653,7 +2656,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTTypeId typeId = duple.getTypeId();
|
IASTTypeId typeId = duple.getTypeId();
|
||||||
((CPPASTConversionName) aName).setTypeId(typeId);
|
((CPPASTConversionName) aName).setTypeId(typeId);
|
||||||
} else {
|
} else {
|
||||||
aName = new CPPASTOperatorName(name.toCharArray());
|
aName = new CPPASTOperatorName(duple.getOperator());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name instanceof ICPPASTTemplateId) {
|
if (name instanceof ICPPASTTemplateId) {
|
||||||
|
|
|
@ -0,0 +1,138 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Corporation - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enumeration of all the overloadable operators in C++.
|
||||||
|
*
|
||||||
|
* Note: toString() has not been overridden, use toCharArray() to get
|
||||||
|
* a character representation of the operator.
|
||||||
|
*
|
||||||
|
* @author Mike Kucera
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("nls")
|
||||||
|
public enum OverloadableOperator {
|
||||||
|
|
||||||
|
GT(">"),
|
||||||
|
LT("<"),
|
||||||
|
NOT("!"),
|
||||||
|
BITCOMPLEMENT("~"),
|
||||||
|
BITOR("|"),
|
||||||
|
AMPER("&"),
|
||||||
|
XOR("^"),
|
||||||
|
MOD("%"),
|
||||||
|
DIV("/"),
|
||||||
|
STAR("*"),
|
||||||
|
PLUS("+"),
|
||||||
|
BRACKET("[]"),
|
||||||
|
PAREN("()"),
|
||||||
|
ARROW("->"),
|
||||||
|
ARROWSTAR("->*"),
|
||||||
|
COMMA(","),
|
||||||
|
MINUS("-"),
|
||||||
|
DECR("--"),
|
||||||
|
INCR("++"),
|
||||||
|
OR("||"),
|
||||||
|
AND("&&"),
|
||||||
|
ASSIGN("="),
|
||||||
|
GTEQUAL(">="),
|
||||||
|
LTEQUAL("<="),
|
||||||
|
NOTEQUAL("!="),
|
||||||
|
EQUAL("=="),
|
||||||
|
SHIFTR(">>"),
|
||||||
|
SHIFTL("<<"),
|
||||||
|
SHIFTLASSIGN("<<="),
|
||||||
|
SHIFTR_ASSIGN(">>="),
|
||||||
|
BITORASSIGN("|="),
|
||||||
|
AMPERASSIGN("&="),
|
||||||
|
XORASSIGN("^="),
|
||||||
|
MODASSIGN("%="),
|
||||||
|
DIVASSIGN("/="),
|
||||||
|
STARASSIGN("*="),
|
||||||
|
MINUSASSIGN("-="),
|
||||||
|
PLUSASSIGN("+="),
|
||||||
|
NEW("new"),
|
||||||
|
DELETE_ARRAY("delete[]"),
|
||||||
|
DELETE("delete"),
|
||||||
|
NEW_ARRAY("new[]");
|
||||||
|
|
||||||
|
|
||||||
|
private final char[] rep;
|
||||||
|
|
||||||
|
private OverloadableOperator(String rep) {
|
||||||
|
this.rep = ("operator " + rep).toCharArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public char[] toCharArray() {
|
||||||
|
return rep;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the OverloadableOperator constant that corresponds to the
|
||||||
|
* given token. Only works for operators that consist of one token.
|
||||||
|
*
|
||||||
|
* @throws NullPointerException if token is null
|
||||||
|
*/
|
||||||
|
public static OverloadableOperator valueOf(IToken token) {
|
||||||
|
switch(token.getType()) {
|
||||||
|
case IToken.t_delete: return DELETE;
|
||||||
|
case IToken.t_new: return NEW;
|
||||||
|
case IToken.tAMPER: return AMPER;
|
||||||
|
case IToken.tAMPERASSIGN: return AMPERASSIGN;
|
||||||
|
case IToken.tARROW: return ARROW;
|
||||||
|
case IToken.tARROWSTAR: return ARROWSTAR;
|
||||||
|
case IToken.tBITOR: return BITOR;
|
||||||
|
case IToken.tBITORASSIGN: return BITORASSIGN;
|
||||||
|
case IToken.tBITCOMPLEMENT: return BITCOMPLEMENT;
|
||||||
|
case IToken.tSHIFTL: return SHIFTL;
|
||||||
|
case IToken.tSHIFTLASSIGN: return SHIFTLASSIGN;
|
||||||
|
case IToken.tSHIFTR: return SHIFTR;
|
||||||
|
case IToken.tSHIFTRASSIGN: return SHIFTR_ASSIGN;
|
||||||
|
case IToken.tXOR: return XOR;
|
||||||
|
case IToken.tXORASSIGN: return XORASSIGN;
|
||||||
|
|
||||||
|
// logical operations
|
||||||
|
case IToken.tNOT: return NOT;
|
||||||
|
case IToken.tAND: return AND;
|
||||||
|
case IToken.tOR: return OR;
|
||||||
|
|
||||||
|
// arithmetic
|
||||||
|
case IToken.tDECR: return DECR;
|
||||||
|
case IToken.tINCR: return INCR;
|
||||||
|
case IToken.tDIV: return DIV;
|
||||||
|
case IToken.tDIVASSIGN: return DIVASSIGN;
|
||||||
|
case IToken.tMINUS: return MINUS;
|
||||||
|
case IToken.tMINUSASSIGN: return MINUSASSIGN;
|
||||||
|
case IToken.tMOD: return MOD;
|
||||||
|
case IToken.tMODASSIGN: return MODASSIGN;
|
||||||
|
case IToken.tPLUS: return PLUS;
|
||||||
|
case IToken.tPLUSASSIGN: return PLUSASSIGN;
|
||||||
|
case IToken.tSTAR: return STAR;
|
||||||
|
case IToken.tSTARASSIGN: return STARASSIGN;
|
||||||
|
|
||||||
|
// comparison
|
||||||
|
case IToken.tEQUAL: return EQUAL;
|
||||||
|
case IToken.tNOTEQUAL: return NOTEQUAL;
|
||||||
|
case IToken.tGT: return GT;
|
||||||
|
case IToken.tGTEQUAL: return GTEQUAL;
|
||||||
|
case IToken.tLT: return LT;
|
||||||
|
case IToken.tLTEQUAL: return LTEQUAL;
|
||||||
|
|
||||||
|
// other
|
||||||
|
case IToken.tASSIGN: return ASSIGN;
|
||||||
|
case IToken.tCOMMA: return COMMA;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used by the GNUCPPSourceParser as an intermediate determinant of whether a
|
* This class is used by the GNUCPPSourceParser as an intermediate determinant of whether a
|
||||||
|
@ -28,13 +29,15 @@ public class OperatorTokenDuple implements ITokenDuple {
|
||||||
private ITokenDuple token = null;
|
private ITokenDuple token = null;
|
||||||
private IASTTypeId typeId = null;
|
private IASTTypeId typeId = null;
|
||||||
private boolean isConversionOperator=false;
|
private boolean isConversionOperator=false;
|
||||||
|
private OverloadableOperator op = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple constructor. token is wrapped by this class.
|
* Simple constructor. token is wrapped by this class.
|
||||||
* @param token
|
* @param token
|
||||||
*/
|
*/
|
||||||
public OperatorTokenDuple(ITokenDuple token) {
|
public OperatorTokenDuple(ITokenDuple token, OverloadableOperator op) {
|
||||||
this.token=token;
|
this.token=token;
|
||||||
|
this.op = op;
|
||||||
}
|
}
|
||||||
|
|
||||||
// below are functions used by GNUCPPSourceParser, see IOperatorTokenDuple
|
// below are functions used by GNUCPPSourceParser, see IOperatorTokenDuple
|
||||||
|
@ -64,94 +67,67 @@ public class OperatorTokenDuple implements ITokenDuple {
|
||||||
this.typeId = typeId;
|
this.typeId = typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OverloadableOperator getOperator() {
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
|
||||||
// below are ITokenDuple functions
|
// below are ITokenDuple functions
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getFirstToken()
|
|
||||||
*/
|
|
||||||
public IToken getFirstToken() {
|
public IToken getFirstToken() {
|
||||||
return token.getFirstToken();
|
return token.getFirstToken();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getLastToken()
|
|
||||||
*/
|
|
||||||
public IToken getLastToken() {
|
public IToken getLastToken() {
|
||||||
return token.getLastToken();
|
return token.getLastToken();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getTemplateIdArgLists()
|
|
||||||
*/
|
|
||||||
public List[] getTemplateIdArgLists() {
|
public List[] getTemplateIdArgLists() {
|
||||||
return token.getTemplateIdArgLists();
|
return token.getTemplateIdArgLists();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getLastSegment()
|
|
||||||
*/
|
|
||||||
public ITokenDuple getLastSegment() {
|
public ITokenDuple getLastSegment() {
|
||||||
return token.getLastSegment();
|
return token.getLastSegment();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getLeadingSegments()
|
|
||||||
*/
|
|
||||||
public ITokenDuple getLeadingSegments() {
|
public ITokenDuple getLeadingSegments() {
|
||||||
return token.getLeadingSegments();
|
return token.getLeadingSegments();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getSegmentCount()
|
|
||||||
*/
|
|
||||||
public int getSegmentCount() {
|
public int getSegmentCount() {
|
||||||
return token.getSegmentCount();
|
return token.getSegmentCount();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#iterator()
|
|
||||||
*/
|
|
||||||
public Iterator iterator() {
|
public Iterator iterator() {
|
||||||
return token.iterator();
|
return token.iterator();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#toCharArray()
|
|
||||||
*/
|
|
||||||
public char[] toCharArray() {
|
public char[] toCharArray() {
|
||||||
return token.toCharArray();
|
return token.toCharArray();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#length()
|
|
||||||
*/
|
|
||||||
public int length() {
|
public int length() {
|
||||||
return token.length();
|
return token.length();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getToken(int)
|
|
||||||
*/
|
|
||||||
public IToken getToken(int index) {
|
public IToken getToken(int index) {
|
||||||
return token.getToken(index);
|
return token.getToken(index);
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getSegments()
|
|
||||||
*/
|
|
||||||
public ITokenDuple[] getSegments() {
|
public ITokenDuple[] getSegments() {
|
||||||
return token.getSegments();
|
return token.getSegments();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getStartOffset()
|
|
||||||
*/
|
|
||||||
public int getStartOffset() {
|
public int getStartOffset() {
|
||||||
return token.getStartOffset();
|
return token.getStartOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#getEndOffset()
|
|
||||||
*/
|
|
||||||
public int getEndOffset() {
|
public int getEndOffset() {
|
||||||
return token.getEndOffset();
|
return token.getEndOffset();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.core.parser.ITokenDuple#extractNameFromTemplateId()
|
|
||||||
*/
|
|
||||||
public char[] extractNameFromTemplateId() {
|
public char[] extractNameFromTemplateId() {
|
||||||
return token.extractNameFromTemplateId();
|
return token.extractNameFromTemplateId();
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return token.toString();
|
return token.toString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue