public class MacroDefinition extends java.lang.Object implements java.io.Serializable
TextRegionLocation
of the define.Modifier and Type | Field and Description |
---|---|
boolean |
hasVariadicParameter
Whether the last parameter in this macro definition is a variadic parameter.
|
boolean |
isFunctionMacro
Whether this is a function macro (otherwise an object macro).
|
TextRegionLocation |
macroDeclarationLocation
Location where this macro was declared in the source code.
|
java.lang.String |
macroName
The identifier used to invoke this macro.
|
UnmodifiableList<java.lang.String> |
parameterNames
The names of the parameters of this function.
|
java.util.List<IToken> |
replacementList
The "content" of the macro.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
java.util.List<java.lang.String> |
getParametersThatRequireExpansion()
Returns all parameter names that need to be expanded recursively during
expansion of this macro.
|
int |
hashCode() |
static boolean |
isStringificationToken(IToken token)
Returns whether the given token's text starts with # and is not one of the
"common" preprocessor directives.
|
static MacroDefinition |
parseMacroDefinition(java.lang.String macroDefinition,
TextRegionLocation location)
Parses the given macro definition and generates a
MacroDefinition
object from it. |
java.lang.String |
toString() |
public final java.lang.String macroName
#define CAT(x,y) x##y
, this is "CAT"
.public final java.util.List<IToken> replacementList
For the macro definition #define CAT(x,y) x##y
, this is
"x##y"
.
public final boolean isFunctionMacro
public final UnmodifiableList<java.lang.String> parameterNames
isFunctionMacro
is false.
If the last parameter in the macro declaration is "..." (variadic parameter), its name is "__VA_ARGS__" in this list. If the last parameter in the macro declaration is "xy..." (named variadic parameter, common gcc extension), its name is "xy" in this list. In both cases we store the id with which the parameter value can be referred to in the replacement list.
public final boolean hasVariadicParameter
isFunctionMacro
is false.public final TextRegionLocation macroDeclarationLocation
public static MacroDefinition parseMacroDefinition(java.lang.String macroDefinition, TextRegionLocation location)
MacroDefinition
object from it. The parameter should be the definition string except for the
leading "#define ".
For example parseMacroDefinition("FOO(x) x")
. The parameter must
not be null. This never returns null.
public static boolean isStringificationToken(IToken token)
public java.util.List<java.lang.String> getParametersThatRequireExpansion()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object