import org.eclipse.linuxtools.ctf.core.event.types.StringDeclaration;
import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
import org.eclipse.linuxtools.ctf.core.event.types.VariantDeclaration;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
import org.eclipse.linuxtools.ctf.core.trace.Stream;
import org.eclipse.linuxtools.ctf.parser.CTFParser;
// Attributes
// ------------------------------------------------------------------------
- static private final boolean DEBUG_ = false;
+ private static final boolean DEBUG = false;
/**
* The trace
List<CommonTree> children = root.getChildren();
java.io.FileOutputStream fos = null;
java.io.OutputStreamWriter out = null;
- if (DEBUG_) {
+ if (DEBUG) {
try {
fos = new java.io.FileOutputStream("/tmp/astInfo.txt"); //$NON-NLS-1$
out = new java.io.OutputStreamWriter(fos, "UTF-8"); //$NON-NLS-1$
try {
for (CommonTree child : children) {
final int type = child.getType();
- if (DEBUG_) {
+ if (DEBUG) {
out.write(child.toString()
+ " -> " + type + '\n'); //$NON-NLS-1$
}
childTypeError(child);
}
}
- if (DEBUG_) {
+ if (DEBUG) {
out.write("Declarations\n"); //$NON-NLS-1$
}
for (CommonTree decl : declarations) {
- if (DEBUG_) {
+ if (DEBUG) {
out.write(decl.toString() + '\n');
}
parseRootDeclaration(decl);
parseTrace(traceNode);
- if (DEBUG_) {
+ if (DEBUG) {
out.write("Environments\n"); //$NON-NLS-1$
}
for (CommonTree environment : environments) {
parseEnvironment(environment);
}
- if (DEBUG_) {
+ if (DEBUG) {
out.write("Clocks\n"); //$NON-NLS-1$
}
for (CommonTree clock : clocks) {
parseClock(clock);
}
- if (DEBUG_) {
+ if (DEBUG) {
out.write("Callsites\n"); //$NON-NLS-1$
}
for (CommonTree callsite : callsites) {
parseCallsite(callsite);
}
- if (DEBUG_) {
+ if (DEBUG) {
out.write("Streams\n"); //$NON-NLS-1$
}
if (streams.size() > 0) {
for (CommonTree stream : streams) {
- if (DEBUG_) {
+ if (DEBUG) {
try {
out.write(stream.toString() + '\n');
} catch (IOException e) {
trace.addStream(new Stream(trace));
}
- if (DEBUG_) {
+ if (DEBUG) {
out.write("Events\n"); //$NON-NLS-1$
}
for (CommonTree event : events) {
parseEvent(event);
- if (DEBUG_) {
+ if (DEBUG) {
CommonTree name = (CommonTree) event.getChild(0).getChild(1).getChild(0).getChild(0);
CommonTree id = (CommonTree) event.getChild(1).getChild(1).getChild(0).getChild(0);
out.write("Name = " + name + " Id = " + id + '\n'); //$NON-NLS-1$ //$NON-NLS-2$
}
}
- if (DEBUG_) {
+ if (DEBUG) {
out.close();
fos.close();
}
List<CommonTree> children = callsite.getChildren();
String name = null;
- String func_name = null;
- long line_number = -1;
+ String funcName = null;
+ long lineNumber = -1;
long ip = -1;
- String file_name = null;
+ String fileName = null;
for (CommonTree child : children) {
String left;
if (left.equals("name")) { //$NON-NLS-1$
name = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString);
} else if (left.equals("func")) { //$NON-NLS-1$
- func_name = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString);
+ funcName = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString);
} else if (left.equals("ip")) { //$NON-NLS-1$
- ip = Long.parseLong(child.getChild(1).getChild(0).getChild(0).getText().substring(2),16); // trim the 0x
+ ip = Long.parseLong(child.getChild(1).getChild(0).getChild(0).getText().substring(2), 16); // trim the 0x
} else if (left.equals("file")) { //$NON-NLS-1$
- file_name = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString);
+ fileName = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString);
} else if (left.equals("line")) { //$NON-NLS-1$
- line_number = Long.parseLong(child.getChild(1).getChild(0).getChild(0).getText());
+ lineNumber = Long.parseLong(child.getChild(1).getChild(0).getChild(0).getText());
}
}
- trace.addCallsite(name, func_name, ip,file_name, line_number);
+ trace.addCallsite(name, funcName, ip,fileName, lineNumber);
}
private void parseEnvironment(CommonTree environment) {
}
}
- String NameValue = ctfClock.getName();
- trace.addClock(NameValue, ctfClock);
+ String nameValue = ctfClock.getName();
+ trace.addClock(nameValue, ctfClock);
}
private void parseTrace(CommonTree traceNode) throws ParseException {
* If uuid was already set by a metadata packet, compare it to see
* if it matches
*/
- if (trace.UUIDIsSet()) {
+ if (trace.uuidIsSet()) {
if (trace.getUUID().compareTo(uuid) != 0) {
throw new ParseException("UUID mismatch. Packet says " //$NON-NLS-1$
+ trace.getUUID() + " but metadata says " + uuid); //$NON-NLS-1$
IDeclaration targetDeclaration = parseTypealiasTarget(target);
- if (targetDeclaration instanceof VariantDeclaration) {
- if (((VariantDeclaration) targetDeclaration).isTagged()) {
- throw new ParseException(
- "Typealias of untagged variant is not permitted"); //$NON-NLS-1$
- }
+ if ((targetDeclaration instanceof VariantDeclaration)
+ && ((VariantDeclaration) targetDeclaration).isTagged()) {
+ throw new ParseException("Typealias of untagged variant is not permitted"); //$NON-NLS-1$
}
String aliasString = parseTypealiasAlias(alias);
case CTFParser.IDENTIFIER:
throw new ParseException("Identifier (" + child.getText() //$NON-NLS-1$
+ ") not expected in the typealias target"); //$NON-NLS-1$
- /* break; */
default:
childTypeError(child);
break;
for (CommonTree typeDeclaratorNode : typeDeclaratorList) {
StringBuilder identifierSB = new StringBuilder();
- IDeclaration type_declaration = parseTypeDeclarator(
+ IDeclaration typeDeclaration = parseTypeDeclarator(
typeDeclaratorNode, typeSpecifierListNode, identifierSB);
- if (type_declaration instanceof VariantDeclaration) {
- if (((VariantDeclaration) type_declaration).isTagged()) {
- throw new ParseException(
- "Typealias of untagged variant is not permitted"); //$NON-NLS-1$
- }
+ if ((typeDeclaration instanceof VariantDeclaration)
+ && ((VariantDeclaration) typeDeclaration).isTagged()) {
+ throw new ParseException(
+ "Typealias of untagged variant is not permitted"); //$NON-NLS-1$
}
getCurrentScope().registerType(identifierSB.toString(),
- type_declaration);
+ typeDeclaration);
}
}
/**
* Parses an enum declaration and returns the corresponding declaration.
*
- * @param _enum
+ * @param theEnum
* An ENUM node.
* @return The corresponding enum declaration.
* @throws ParseException
*/
- private EnumDeclaration parseEnum(CommonTree _enum) throws ParseException {
+ private EnumDeclaration parseEnum(CommonTree theEnum) throws ParseException {
- List<CommonTree> children = _enum.getChildren();
+ List<CommonTree> children = theEnum.getChildren();
/* The return value */
EnumDeclaration enumDeclaration = null;
switch (child.getType()) {
case CTFParser.ENUM_NAME: {
CommonTree enumNameIdentifier = (CommonTree) child.getChild(0);
-
enumName = enumNameIdentifier.getText();
-
break;
}
case CTFParser.ENUM_BODY: {
-
enumBody = child;
-
break;
}
case CTFParser.ENUM_CONTAINER_TYPE: {
-
containerTypeDeclaration = parseEnumContainerType(child);
-
break;
}
default:
case CTFParser.STRING:
throw new ParseException(
"CTF type found in createTypeSpecifierString"); //$NON-NLS-1$
- /* break; */
default:
childTypeError(typeSpecifier);
break;
String uuidstr = parseUnaryString(firstChild);
try {
- UUID uuid = UUID.fromString(uuidstr);
- return uuid;
+ return UUID.fromString(uuidstr);
} catch (IllegalArgumentException e) {
throw new ParseException("Invalid format for UUID"); //$NON-NLS-1$
}