mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
78f863bc01
commit
76ddab24aa
9 changed files with 167 additions and 172 deletions
|
@ -266,18 +266,16 @@ public class MacroDefinitionParser {
|
|||
break loop;
|
||||
case IToken.tIDENTIFIER:
|
||||
if (paramList != null) {
|
||||
// convert the parameters to special tokens
|
||||
// Convert the parameters to special tokens.
|
||||
final char[] image = candidate.getCharImage();
|
||||
int idx= CharArrayUtils.indexOf(image, paramList);
|
||||
if (idx >= 0) {
|
||||
candidate= new TokenParameterReference(CPreprocessor.tMACRO_PARAMETER, idx, lexer.getSource(), candidate.getOffset(), candidate.getEndOffset(), paramList[idx]);
|
||||
needParam= false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (needParam) {
|
||||
log.handleProblem(IProblem.PREPROCESSOR_MACRO_PASTING_ERROR, name, fExpansionOffset, candidate.getEndOffset());
|
||||
}
|
||||
else if (CharArrayUtils.equals(Keywords.cVA_ARGS, image)) {
|
||||
} else if (CharArrayUtils.equals(Keywords.cVA_ARGS, image)) {
|
||||
log.handleProblem(IProblem.PREPROCESSOR_INVALID_VA_ARGS, null, fExpansionOffset, candidate.getEndOffset());
|
||||
}
|
||||
needParam= false;
|
||||
|
|
|
@ -112,7 +112,7 @@ public class MacroExpander {
|
|||
|
||||
if (fLexer != null) {
|
||||
t= fLexer.currentToken();
|
||||
while(t.getType() == Lexer.tNEWLINE) {
|
||||
while (t.getType() == Lexer.tNEWLINE) {
|
||||
t= fLexer.nextToken();
|
||||
}
|
||||
return t.getType() == IToken.tLPAREN;
|
||||
|
@ -271,7 +271,7 @@ public class MacroExpander {
|
|||
try {
|
||||
lastConsumed= parseArguments(input, (FunctionStyleMacro) macro, forbidden, argInputs, tracker);
|
||||
} catch (AbortMacroExpansionException e) {
|
||||
// ignore this macro expansion
|
||||
// Ignore this macro expansion.
|
||||
for (TokenSource argInput : argInputs) {
|
||||
executeScopeMarkers(argInput, forbidden);
|
||||
if (tracker != null) {
|
||||
|
@ -342,7 +342,7 @@ public class MacroExpander {
|
|||
|
||||
private void executeScopeMarkers(TokenSource input, IdentityHashMap<PreprocessorMacro, PreprocessorMacro> forbidden) {
|
||||
Token t= input.removeFirst();
|
||||
while(t != null) {
|
||||
while (t != null) {
|
||||
if (t.getType() == CPreprocessor.tSCOPE_MARKER) {
|
||||
((ExpansionBoundary) t).execute(forbidden);
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ public class MacroExpander {
|
|||
boolean protect= false;
|
||||
Token l= null;
|
||||
Token t= input.removeFirst();
|
||||
while(t != null) {
|
||||
while (t != null) {
|
||||
switch (t.getType()) {
|
||||
case CPreprocessor.tSCOPE_MARKER:
|
||||
((ExpansionBoundary) t).execute(forbidden);
|
||||
|
@ -460,7 +460,7 @@ public class MacroExpander {
|
|||
throws OffsetLimitReachedException, AbortMacroExpansionException {
|
||||
final int argCount= macro.getParameterPlaceholderList().length;
|
||||
final boolean hasVarargs= macro.hasVarArgs() != FunctionStyleMacro.NO_VAARGS;
|
||||
final int requiredArgs= hasVarargs ? argCount-1 : argCount;
|
||||
final int requiredArgs= hasVarargs ? argCount - 1 : argCount;
|
||||
int idx= 0;
|
||||
int nesting= -1;
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
|
@ -514,7 +514,7 @@ public class MacroExpander {
|
|||
continue loop;
|
||||
|
||||
case IToken.tLPAREN:
|
||||
// the first one sets nesting to zero.
|
||||
// The first one sets nesting to zero.
|
||||
if (++nesting == 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ public class MacroExpander {
|
|||
case IToken.tCOMMA:
|
||||
assert nesting >= 0;
|
||||
if (nesting == 0) {
|
||||
if (idx < argCount-1) { // next argument
|
||||
if (idx < argCount - 1) { // Next argument.
|
||||
isFirstOfArg= true;
|
||||
spaceMarkers.clear();
|
||||
idx++;
|
||||
|
@ -592,7 +592,7 @@ public class MacroExpander {
|
|||
Token l= null;
|
||||
Token n;
|
||||
Token pasteArg1= null;
|
||||
for (Token t= replacement.first(); t != null; l=t, t=n) {
|
||||
for (Token t= replacement.first(); t != null; l= t, t= n) {
|
||||
n= (Token) t.getNext();
|
||||
|
||||
switch (t.getType()) {
|
||||
|
@ -715,7 +715,7 @@ public class MacroExpander {
|
|||
idx= ((TokenParameterReference) nn).getIndex();
|
||||
|
||||
// check for gcc-extension preventing the paste operation
|
||||
if (idx == args.length-1 && macro.hasVarArgs() != FunctionStyleMacro.NO_VAARGS &&
|
||||
if (idx == args.length - 1 && macro.hasVarArgs() != FunctionStyleMacro.NO_VAARGS &&
|
||||
!isKind(nn.getNext(), IToken.tPOUNDPOUND)) {
|
||||
final Token nnn= (Token) nn.getNext();
|
||||
TokenList arg= clone(expandedArgs[idx]);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*
|
||||
* Based on lookup3.c, by Bob Jenkins {@link "http://burtleburtle.net/bob/c/lookup3.c"}
|
||||
*
|
||||
|
@ -44,7 +44,6 @@
|
|||
* mixing with 12*3 instructions on 3 integers than you can with 3 instructions
|
||||
* on 1 byte), but shoehorning those bytes into integers efficiently is messy.
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class Token implements IToken, Cloneable {
|
|||
|
||||
@Override
|
||||
final public int getLength() {
|
||||
return fEndOffset-fOffset;
|
||||
return fEndOffset - fOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,7 +56,6 @@ public class Token implements IToken, Cloneable {
|
|||
return fNextToken;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
final public void setType(int kind) {
|
||||
fKind= kind;
|
||||
|
@ -73,8 +72,8 @@ public class Token implements IToken, Cloneable {
|
|||
}
|
||||
|
||||
public void shiftOffset(int shift) {
|
||||
fOffset+= shift;
|
||||
fEndOffset+= shift;
|
||||
fOffset += shift;
|
||||
fEndOffset += shift;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||
|
||||
|
@ -17,7 +17,8 @@ class TokenList {
|
|||
final Token removeFirst() {
|
||||
final Token first= fFirst;
|
||||
if (first == fLast) {
|
||||
fFirst= fLast= null;
|
||||
fFirst= null;
|
||||
fLast= null;
|
||||
return first;
|
||||
}
|
||||
fFirst= (Token) first.getNext();
|
||||
|
@ -26,9 +27,9 @@ class TokenList {
|
|||
|
||||
public final void append(Token t) {
|
||||
if (fFirst == null) {
|
||||
fFirst= fLast= t;
|
||||
}
|
||||
else {
|
||||
fFirst= t;
|
||||
fLast= t;
|
||||
} else {
|
||||
fLast.setNext(t);
|
||||
fLast= t;
|
||||
}
|
||||
|
@ -40,19 +41,19 @@ class TokenList {
|
|||
if (t != null) {
|
||||
if (fFirst == null) {
|
||||
fFirst= tl.fFirst;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fLast.setNext(tl.fFirst);
|
||||
}
|
||||
fLast= tl.fLast;
|
||||
}
|
||||
tl.fFirst= tl.fLast= null;
|
||||
tl.fFirst= null;
|
||||
tl.fLast= null;
|
||||
}
|
||||
|
||||
public final void appendAllButLast(TokenList tl) {
|
||||
Token t= tl.first();
|
||||
if (t != null) {
|
||||
for (Token n= (Token) t.getNext(); n != null; t=n, n= (Token) n.getNext()) {
|
||||
for (Token n= (Token) t.getNext(); n != null; t= n, n= (Token) n.getNext()) {
|
||||
append(t);
|
||||
}
|
||||
}
|
||||
|
@ -110,8 +111,7 @@ class TokenList {
|
|||
fLast= null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
final Token r= (Token) l.getNext();
|
||||
if (r != null) {
|
||||
l.setNext(r.getNext());
|
||||
|
@ -124,19 +124,20 @@ class TokenList {
|
|||
|
||||
void cutAfter(Token l) {
|
||||
if (l == null) {
|
||||
fFirst= fLast= null;
|
||||
}
|
||||
else {
|
||||
fFirst= null;
|
||||
fLast= null;
|
||||
} else {
|
||||
l.setNext(null);
|
||||
fLast= l;
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
fFirst= fLast= null;
|
||||
fFirst= null;
|
||||
fLast= null;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return fFirst==null;
|
||||
return fFirst == null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||
|
||||
|
@ -147,7 +147,6 @@ public class TokenUtil {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the last token in the given token list.
|
||||
* @throws NullPointerException if the argument is null
|
||||
|
@ -156,8 +155,7 @@ public class TokenUtil {
|
|||
IToken last;
|
||||
do {
|
||||
last = tokenList;
|
||||
} while((tokenList = tokenList.getNext()) != null);
|
||||
} while ((tokenList = tokenList.getNext()) != null);
|
||||
return last;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue