mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 11:55:40 +02:00
decl spec node was missing info
This commit is contained in:
parent
8d37ffe060
commit
2e3fbf6c23
5 changed files with 40 additions and 29 deletions
|
@ -14,13 +14,15 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class CPPASTSimpleDeclaration extends CPPASTNode implements IASTSimpleDeclaration {
|
public class CPPASTSimpleDeclaration extends CPPASTNode implements IASTSimpleDeclaration, IASTAmbiguityParent {
|
||||||
|
|
||||||
public CPPASTSimpleDeclaration() {
|
public CPPASTSimpleDeclaration() {
|
||||||
}
|
}
|
||||||
|
@ -86,4 +88,16 @@ public class CPPASTSimpleDeclaration extends CPPASTNode implements IASTSimpleDec
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void replace(IASTNode child, IASTNode other) {
|
||||||
|
IASTDeclarator[] declarators = getDeclarators();
|
||||||
|
for(int i = 0; i < declarators.length; i++) {
|
||||||
|
if(declarators[i] == child) {
|
||||||
|
declarators[i] = (IASTDeclarator)other;
|
||||||
|
other.setParent(child.getParent());
|
||||||
|
other.setPropertyInParent(child.getPropertyInParent());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,19 +133,16 @@ public class C99BuildASTParserAction extends BuildASTParserAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IParser getExpressionStatementParser() {
|
protected IParser getExpressionStatementParser() {
|
||||||
DebugUtil.printMethodTrace();
|
|
||||||
return new C99ExpressionStatementParser(parser.getOrderedTerminalSymbols());
|
return new C99ExpressionStatementParser(parser.getOrderedTerminalSymbols());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IParser getNoCastExpressionParser() {
|
protected IParser getNoCastExpressionParser() {
|
||||||
DebugUtil.printMethodTrace();
|
|
||||||
return new C99NoCastExpressionParser(parser.getOrderedTerminalSymbols());
|
return new C99NoCastExpressionParser(parser.getOrderedTerminalSymbols());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IParser getSizeofExpressionParser() {
|
protected IParser getSizeofExpressionParser() {
|
||||||
DebugUtil.printMethodTrace();
|
|
||||||
return new C99SizeofExpressionParser(parser.getOrderedTerminalSymbols());
|
return new C99SizeofExpressionParser(parser.getOrderedTerminalSymbols());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -379,7 +379,7 @@ public class CPPASTNodeFactory implements ICPPASTNodeFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier) {
|
public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier) {
|
||||||
return new ISOCPPASTSimpleDeclaration(declSpecifier);
|
return new CPPASTSimpleDeclaration(declSpecifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTInitializerExpression newInitializerExpression(IASTExpression expression) {
|
public IASTInitializerExpression newInitializerExpression(IASTExpression expression) {
|
||||||
|
@ -403,8 +403,7 @@ public class CPPASTNodeFactory implements ICPPASTNodeFactory {
|
||||||
return new CPPASTFunctionDeclarator(name);
|
return new CPPASTFunctionDeclarator(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPASTSimpleTypeConstructorExpression newCPPSimpleTypeConstructorExpression(
|
public ICPPASTSimpleTypeConstructorExpression newCPPSimpleTypeConstructorExpression(int type, IASTExpression expression) {
|
||||||
int type, IASTExpression expression) {
|
|
||||||
return new CPPASTSimpleTypeConstructorExpression(type, expression);
|
return new CPPASTSimpleTypeConstructorExpression(type, expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,8 +515,7 @@ public class CPPASTNodeFactory implements ICPPASTNodeFactory {
|
||||||
return new CPPASTFunctionDeclarator(name);
|
return new CPPASTFunctionDeclarator(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTParameterDeclaration newParameterDeclaration(
|
public IASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
|
||||||
IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
|
|
||||||
return new CPPASTParameterDeclaration(declSpec, declarator);
|
return new CPPASTParameterDeclaration(declSpec, declarator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
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.ICPPASTConstructorInitializer;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||||
|
@ -970,12 +971,13 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
||||||
case TK_static: node.setStorageClass(IASTDeclSpecifier.sc_static); return;
|
case TK_static: node.setStorageClass(IASTDeclSpecifier.sc_static); return;
|
||||||
case TK_auto: node.setStorageClass(IASTDeclSpecifier.sc_auto); return;
|
case TK_auto: node.setStorageClass(IASTDeclSpecifier.sc_auto); return;
|
||||||
case TK_register: node.setStorageClass(IASTDeclSpecifier.sc_register); return;
|
case TK_register: node.setStorageClass(IASTDeclSpecifier.sc_register); return;
|
||||||
|
case TK_mutable: node.setStorageClass(ICPPASTDeclSpecifier.sc_mutable); return;
|
||||||
|
|
||||||
case TK_inline: node.setInline(true); return;
|
case TK_inline: node.setInline(true); return;
|
||||||
case TK_const: node.setConst(true); return;
|
case TK_const: node.setConst(true); return;
|
||||||
case TK_volatile: node.setVolatile(true); return;
|
case TK_volatile: node.setVolatile(true); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this isn't finished
|
|
||||||
if(node instanceof ICPPASTSimpleDeclSpecifier) {
|
if(node instanceof ICPPASTSimpleDeclSpecifier) {
|
||||||
ICPPASTSimpleDeclSpecifier n = (ICPPASTSimpleDeclSpecifier) node;
|
ICPPASTSimpleDeclSpecifier n = (ICPPASTSimpleDeclSpecifier) node;
|
||||||
switch(kind) {
|
switch(kind) {
|
||||||
|
@ -984,10 +986,17 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
||||||
case TK_int: n.setType(IASTSimpleDeclSpecifier.t_int); break;
|
case TK_int: n.setType(IASTSimpleDeclSpecifier.t_int); break;
|
||||||
case TK_float: n.setType(IASTSimpleDeclSpecifier.t_float); break;
|
case TK_float: n.setType(IASTSimpleDeclSpecifier.t_float); break;
|
||||||
case TK_double: n.setType(IASTSimpleDeclSpecifier.t_double); break;
|
case TK_double: n.setType(IASTSimpleDeclSpecifier.t_double); break;
|
||||||
|
case TK_bool: n.setType(ICPPASTSimpleDeclSpecifier.t_bool); break;
|
||||||
|
case TK_wchar_t: n.setType(ICPPASTSimpleDeclSpecifier.t_wchar_t); break;
|
||||||
|
|
||||||
case TK_signed: n.setSigned(true); break;
|
case TK_signed: n.setSigned(true); break;
|
||||||
case TK_unsigned: n.setUnsigned(true); break;
|
case TK_unsigned: n.setUnsigned(true); break;
|
||||||
case TK_long: n.setLong(true); break;
|
case TK_long: n.setLong(true); break;
|
||||||
case TK_short: n.setShort(true); break;
|
case TK_short: n.setShort(true); break;
|
||||||
|
case TK_friend: n.setFriend(true); break;
|
||||||
|
case TK_virtual: n.setVirtual(true); break;
|
||||||
|
case TK_volatile: n.setVolatile(true); break;
|
||||||
|
case TK_explicit: n.setExplicit(true); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1146,7 +1155,7 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
||||||
|
|
||||||
|
|
||||||
public void consumeInitDeclaratorComplete() {
|
public void consumeInitDeclaratorComplete() {
|
||||||
DebugUtil.printMethodTrace();
|
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
||||||
|
|
||||||
IASTDeclarator declarator = (IASTDeclarator) astStack.peek();
|
IASTDeclarator declarator = (IASTDeclarator) astStack.peek();
|
||||||
if(!(declarator instanceof IASTFunctionDeclarator))
|
if(!(declarator instanceof IASTFunctionDeclarator))
|
||||||
|
@ -1158,20 +1167,12 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
||||||
if(alternateDeclarator == null || alternateDeclarator instanceof IASTProblemDeclaration)
|
if(alternateDeclarator == null || alternateDeclarator instanceof IASTProblemDeclaration)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
astStack.pop();
|
astStack.pop();
|
||||||
IASTNode ambiguityNode = new CPPASTAmbiguousDeclarator(declarator, (IASTDeclarator)alternateDeclarator);
|
IASTNode ambiguityNode = new CPPASTAmbiguousDeclarator(declarator, (IASTDeclarator)alternateDeclarator);
|
||||||
|
|
||||||
System.out.println("AMBIGUOUS DECLARATOR!");
|
|
||||||
// ASTPrinter.print(declarator);
|
|
||||||
// System.out.println();
|
|
||||||
// ASTPrinter.print(alternateDeclarator);
|
|
||||||
// System.out.println();
|
|
||||||
|
|
||||||
setOffsetAndLength(ambiguityNode);
|
setOffsetAndLength(ambiguityNode);
|
||||||
astStack.push(ambiguityNode);
|
astStack.push(ambiguityNode);
|
||||||
|
|
||||||
|
|
||||||
if(TRACE_AST_STACK) System.out.println(astStack);
|
if(TRACE_AST_STACK) System.out.println(astStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
|
||||||
* @author Mike Kucera
|
* @author Mike Kucera
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class ISOCPPASTSimpleDeclaration extends CPPASTSimpleDeclaration implements IASTAmbiguityParent {
|
public class ISOCPPASTSimpleDeclaration extends CPPASTSimpleDeclaration implements IASTAmbiguityParent {
|
||||||
|
|
||||||
public ISOCPPASTSimpleDeclaration() {
|
public ISOCPPASTSimpleDeclaration() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue