Author: gordonsmith
Date: Sat Dec 8 01:26:30 2012
New Revision: 1418588
URL: http://svn.apache.org/viewvc?rev=1418588&view=rev
Log:
Falcon: Made it easy to inspect the ABC produced by any compilation unit.
I've added a toString() method to ABCBytesRequestResult that produces an ABC
dump using ABCDumpVisitor. You can set a breakpoint in a compilation unit's
handleABCBytesRequest() (for example, in MXMLCompilationUnit if you are
compiling MXML) and just look at the ABCBytesRequestResult in the debugger to
see the dump. This is similar to how you can see entire ASTs and scopes in the
debugger.
Modified:
incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/units/MXMLCompilationUnit.java
incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/units/requests/ABCBytesRequestResult.java
Modified:
incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/units/MXMLCompilationUnit.java
URL:
http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/units/MXMLCompilationUnit.java?rev=1418588&r1=1418587&r2=1418588&view=diff
==============================================================================
---
incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/units/MXMLCompilationUnit.java
(original)
+++
incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/units/MXMLCompilationUnit.java
Sat Dec 8 01:26:30 2012
@@ -195,13 +195,15 @@ public class MXMLCompilationUnit extends
startProfile(Operation.GET_ABC_BYTES);
try
{
- return
CodeGeneratorManager.getCodeGenerator().generate(project.getWorkspace().getExecutorService(),
- project.getUseParallelCodeGeneration(),
- getFilenameNoPath(),
- fileNode,
- getProject(),
- isInvisible(),
- getEncodedDebugFiles());
+ IABCBytesRequestResult result =
CodeGeneratorManager.getCodeGenerator().generate(
+ project.getWorkspace().getExecutorService(),
+ project.getUseParallelCodeGeneration(),
+ getFilenameNoPath(),
+ fileNode,
+ getProject(),
+ isInvisible(),
+ getEncodedDebugFiles());
+ return result;
}
finally
{
Modified:
incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/units/requests/ABCBytesRequestResult.java
URL:
http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/units/requests/ABCBytesRequestResult.java?rev=1418588&r1=1418587&r2=1418588&view=diff
==============================================================================
---
incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/units/requests/ABCBytesRequestResult.java
(original)
+++
incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/units/requests/ABCBytesRequestResult.java
Sat Dec 8 01:26:30 2012
@@ -19,10 +19,16 @@
package org.apache.flex.compiler.internal.units.requests;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
+import org.apache.commons.io.output.StringBuilderWriter;
+import org.apache.flex.abc.ABCParser;
+import org.apache.flex.abc.print.ABCDumpVisitor;
import org.apache.flex.compiler.internal.embedding.EmbedData;
import org.apache.flex.compiler.problems.ICompilerProblem;
import org.apache.flex.compiler.units.requests.IABCBytesRequestResult;
@@ -115,4 +121,24 @@ public class ABCBytesRequestResult imple
private final byte[] bytes;
private final ICompilerProblem[] problems;
private final Set<EmbedData> embeds;
+
+
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ PrintWriter out = new PrintWriter(new StringBuilderWriter(sb));
+
+ ABCParser parser = null;
+ try
+ {
+ parser = new ABCParser(new ByteArrayInputStream(bytes));
+ }
+ catch (IOException e)
+ {
+ }
+ parser.parseABC(new ABCDumpVisitor(out));
+
+ return sb.toString();
+ }
}