mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +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.IASTDeclSpecifier;
|
||||
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.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class CPPASTSimpleDeclaration extends CPPASTNode implements IASTSimpleDeclaration {
|
||||
public class CPPASTSimpleDeclaration extends CPPASTNode implements IASTSimpleDeclaration, IASTAmbiguityParent {
|
||||
|
||||
public CPPASTSimpleDeclaration() {
|
||||
}
|
||||
|
@ -85,5 +87,17 @@ public class CPPASTSimpleDeclaration extends CPPASTNode implements IASTSimpleDec
|
|||
}
|
||||
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
|
||||
protected IParser getExpressionStatementParser() {
|
||||
DebugUtil.printMethodTrace();
|
||||
return new C99ExpressionStatementParser(parser.getOrderedTerminalSymbols());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IParser getNoCastExpressionParser() {
|
||||
DebugUtil.printMethodTrace();
|
||||
return new C99NoCastExpressionParser(parser.getOrderedTerminalSymbols());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IParser getSizeofExpressionParser() {
|
||||
DebugUtil.printMethodTrace();
|
||||
return new C99SizeofExpressionParser(parser.getOrderedTerminalSymbols());
|
||||
}
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ public class CPPASTNodeFactory implements ICPPASTNodeFactory {
|
|||
}
|
||||
|
||||
public IASTSimpleDeclaration newSimpleDeclaration(IASTDeclSpecifier declSpecifier) {
|
||||
return new ISOCPPASTSimpleDeclaration(declSpecifier);
|
||||
return new CPPASTSimpleDeclaration(declSpecifier);
|
||||
}
|
||||
|
||||
public IASTInitializerExpression newInitializerExpression(IASTExpression expression) {
|
||||
|
@ -403,8 +403,7 @@ public class CPPASTNodeFactory implements ICPPASTNodeFactory {
|
|||
return new CPPASTFunctionDeclarator(name);
|
||||
}
|
||||
|
||||
public ICPPASTSimpleTypeConstructorExpression newCPPSimpleTypeConstructorExpression(
|
||||
int type, IASTExpression expression) {
|
||||
public ICPPASTSimpleTypeConstructorExpression newCPPSimpleTypeConstructorExpression(int type, IASTExpression expression) {
|
||||
return new CPPASTSimpleTypeConstructorExpression(type, expression);
|
||||
}
|
||||
|
||||
|
@ -516,8 +515,7 @@ public class CPPASTNodeFactory implements ICPPASTNodeFactory {
|
|||
return new CPPASTFunctionDeclarator(name);
|
||||
}
|
||||
|
||||
public IASTParameterDeclaration newParameterDeclaration(
|
||||
IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
|
||||
public IASTParameterDeclaration newParameterDeclaration(IASTDeclSpecifier declSpec, IASTDeclarator 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.ICPPASTConstructorInitializer;
|
||||
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.ICPPASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||
|
@ -965,29 +966,37 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
//TODO int kind = asC99Kind(token)
|
||||
int kind = token.getKind();
|
||||
switch(kind){
|
||||
case TK_typedef: node.setStorageClass(IASTDeclSpecifier.sc_typedef); return;
|
||||
case TK_extern: node.setStorageClass(IASTDeclSpecifier.sc_extern); return;
|
||||
case TK_static: node.setStorageClass(IASTDeclSpecifier.sc_static); return;
|
||||
case TK_auto: node.setStorageClass(IASTDeclSpecifier.sc_auto); return;
|
||||
case TK_register: node.setStorageClass(IASTDeclSpecifier.sc_register); return;
|
||||
case TK_typedef: node.setStorageClass(IASTDeclSpecifier.sc_typedef); return;
|
||||
case TK_extern: node.setStorageClass(IASTDeclSpecifier.sc_extern); return;
|
||||
case TK_static: node.setStorageClass(IASTDeclSpecifier.sc_static); return;
|
||||
case TK_auto: node.setStorageClass(IASTDeclSpecifier.sc_auto); 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_const: node.setConst(true); return;
|
||||
case TK_volatile: node.setVolatile(true); return;
|
||||
}
|
||||
|
||||
// TODO: this isn't finished
|
||||
if(node instanceof ICPPASTSimpleDeclSpecifier) {
|
||||
ICPPASTSimpleDeclSpecifier n = (ICPPASTSimpleDeclSpecifier) node;
|
||||
switch(kind) {
|
||||
case TK_void: n.setType(IASTSimpleDeclSpecifier.t_void); break;
|
||||
case TK_char: n.setType(IASTSimpleDeclSpecifier.t_char); break;
|
||||
case TK_int: n.setType(IASTSimpleDeclSpecifier.t_int); break;
|
||||
case TK_float: n.setType(IASTSimpleDeclSpecifier.t_float); break;
|
||||
case TK_double: n.setType(IASTSimpleDeclSpecifier.t_double); break;
|
||||
case TK_void: n.setType(IASTSimpleDeclSpecifier.t_void); break;
|
||||
case TK_char: n.setType(IASTSimpleDeclSpecifier.t_char); break;
|
||||
case TK_int: n.setType(IASTSimpleDeclSpecifier.t_int); break;
|
||||
case TK_float: n.setType(IASTSimpleDeclSpecifier.t_float); 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_unsigned: n.setUnsigned(true); break;
|
||||
case TK_long: n.setLong(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() {
|
||||
DebugUtil.printMethodTrace();
|
||||
if(TRACE_ACTIONS) DebugUtil.printMethodTrace();
|
||||
|
||||
IASTDeclarator declarator = (IASTDeclarator) astStack.peek();
|
||||
if(!(declarator instanceof IASTFunctionDeclarator))
|
||||
|
@ -1158,20 +1167,12 @@ public class CPPBuildASTParserAction extends BuildASTParserAction {
|
|||
if(alternateDeclarator == null || alternateDeclarator instanceof IASTProblemDeclaration)
|
||||
return;
|
||||
|
||||
|
||||
astStack.pop();
|
||||
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);
|
||||
astStack.push(ambiguityNode);
|
||||
|
||||
|
||||
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
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class ISOCPPASTSimpleDeclaration extends CPPASTSimpleDeclaration implements IASTAmbiguityParent {
|
||||
|
||||
public ISOCPPASTSimpleDeclaration() {
|
||||
|
|
Loading…
Add table
Reference in a new issue