Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: knutwalker/google-closure-compiler
base: 6f7c9917ec
...
head fork: knutwalker/google-closure-compiler
compare: bb9e02297a
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 24, 2012
nicksantos@google.com when handling a finally block like so,
try { alert(1) } finally { }
There needs to be 2 edges: an unconditional edge to the statement
after the 'finally', and an edge for the code path that continues
handling the exception. Label the second edge with ON_EX instead of UNCOND.
Fixes issue 779

R=acleung
DELTA=18  (14 added, 0 deleted, 4 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=5214


git-svn-id: http://closure-compiler.googlecode.com/svn/trunk@2101 b0f006be-c8cd-11de-a2e8-8d36a3108c74
ef2341a
Commits on Jul 25, 2012
nicksantos@google.com Deprecate some redundant compiler apis
R=dimvar
DELTA=46  (29 added, 4 deleted, 13 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=5215


git-svn-id: http://closure-compiler.googlecode.com/svn/trunk@2102 b0f006be-c8cd-11de-a2e8-8d36a3108c74
bb9e022
View
19 src/com/google/javascript/jscomp/Compiler.java
@@ -310,7 +310,9 @@ public void initOptions(CompilerOptions options) {
/**
* Initializes the instance state needed for a compile job.
+ * @deprecated Convert your arrays to lists and use the list-based API.
*/
+ @Deprecated
public void init(JSSourceFile[] externs, JSSourceFile[] inputs,
CompilerOptions options) {
init(Lists.<JSSourceFile>newArrayList(externs),
@@ -335,7 +337,9 @@ public void init(JSSourceFile[] externs, JSSourceFile[] inputs,
/**
* Initializes the instance state needed for a compile job if the sources
* are in modules.
+ * @deprecated Convert your arrays to lists and use the list-based API.
*/
+ @Deprecated
public void init(JSSourceFile[] externs, JSModule[] modules,
CompilerOptions options) {
initModules(Lists.<SourceFile>newArrayList(externs),
@@ -506,11 +510,20 @@ public Result compile(
return compile(Lists.newArrayList(extern), Lists.newArrayList(input), options);
}
+ /**
+ * @deprecated Convert your arrays to lists and use the list-based API.
+ */
+ @Deprecated
public Result compile(
SourceFile extern, JSSourceFile[] input, CompilerOptions options) {
return compile(Lists.newArrayList(extern), Lists.newArrayList(input), options);
}
+ /**
+ * @deprecated Convert your arrays to lists and use the list-based
+ * compileModules method.
+ */
+ @Deprecated
public Result compile(
JSSourceFile extern, JSModule[] modules, CompilerOptions options) {
return compileModules(
@@ -519,7 +532,10 @@ public Result compile(
/**
* Compiles a list of inputs.
+ * @deprecated Convert your arrays to lists and use the list-based compile
+ * method.
*/
+ @Deprecated
public Result compile(JSSourceFile[] externs,
JSSourceFile[] inputs,
CompilerOptions options) {
@@ -551,7 +567,10 @@ public Result compile(JSSourceFile[] externs,
/**
* Compiles a list of modules.
+ * @deprecated Convert your arrays to lists and use the list-based
+ * compileModules method.
*/
+ @Deprecated
public Result compile(JSSourceFile[] externs,
JSModule[] modules,
CompilerOptions options) {
View
2  src/com/google/javascript/jscomp/ControlFlowAnalysis.java
@@ -764,7 +764,7 @@ private static Node computeFollowNode(
} else if (parent.getLastChild() == node){
if (cfa != null) {
for (Node finallyNode : cfa.finallyMap.get(parent)) {
- cfa.createEdge(fromNode, Branch.UNCOND, finallyNode);
+ cfa.createEdge(fromNode, Branch.ON_EX, finallyNode);
}
}
return computeFollowNode(fromNode, parent, cfa);
View
10 src/com/google/javascript/jscomp/ControlFlowGraph.java
@@ -113,7 +113,15 @@ public void connectToImplicitReturn(N srcValue, Branch edgeValue) {
ON_FALSE,
/** Unconditional branch. */
UNCOND,
- /** Exception related. */
+ /**
+ * Exception-handling code paths.
+ * Conflates two kind of control flow passing:
+ * - An exception is thrown, and falls into a catch or finally block
+ * - During exception handling, a finally block finishes and control
+ * passes to the next finally block.
+ * In theory, we need 2 different edge types. In practice, we
+ * can just treat them as "the edges we can't really optimize".
+ */
ON_EX,
/** Possible folded-away template */
SYN_BLOCK;
View
3  src/com/google/javascript/jscomp/JSSourceFile.java
@@ -32,8 +32,11 @@
*
* @author nicksantos@google.com (Nick Santos)
* @author moedinger@google.com (Andrew Moedinger)
+ * @deprecated JSSourceFile is an empty wrapper around SourceFile. Just
+ * use SourceFile directly.
*/
// TODO(nicksantos): Delete this file.
+@Deprecated
public class JSSourceFile extends SourceFile implements Serializable {
private static final long serialVersionUID = 1L;
View
11 src/com/google/javascript/jscomp/jsonml/SecureCompiler.java
@@ -17,17 +17,18 @@
package com.google.javascript.jscomp.jsonml;
import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.javascript.jscomp.CheckLevel;
import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.CompilerInput;
import com.google.javascript.jscomp.CompilerOptions;
+import com.google.javascript.jscomp.CompilerOptions.Reach;
import com.google.javascript.jscomp.JSError;
import com.google.javascript.jscomp.JSModule;
-import com.google.javascript.jscomp.JSSourceFile;
import com.google.javascript.jscomp.Result;
+import com.google.javascript.jscomp.SourceFile;
import com.google.javascript.jscomp.VariableRenamingPolicy;
-import com.google.javascript.jscomp.CompilerOptions.Reach;
import java.util.ArrayList;
@@ -111,9 +112,9 @@ public void compile(JsonML source) {
JSModule module = new JSModule("[[jsonmlmodule]]");
module.add(input);
- Result result = compiler.compile(
- new JSSourceFile[] {},
- new JSModule[] { module },
+ Result result = compiler.compileModules(
+ ImmutableList.<SourceFile>of(),
+ ImmutableList.of(module),
options);
report = generateReport(result);
View
18 test/com/google/debugging/sourcemap/SourceMapTestCase.java
@@ -16,12 +16,13 @@
package com.google.debugging.sourcemap;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import com.google.debugging.sourcemap.proto.Mapping.OriginalMapping;
import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.CompilerOptions;
-import com.google.javascript.jscomp.JSSourceFile;
import com.google.javascript.jscomp.Result;
+import com.google.javascript.jscomp.SourceFile;
import com.google.javascript.jscomp.SourceMap;
import com.google.javascript.jscomp.SourceMap.DetailLevel;
@@ -29,6 +30,7 @@
import java.io.IOException;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -47,9 +49,8 @@ void disableColumnValidation() {
}
- static final JSSourceFile[] EXTERNS = {
- JSSourceFile.fromCode("externs", "")
- };
+ static final List<SourceFile> EXTERNS = ImmutableList.of(
+ SourceFile.fromCode("externs", ""));
protected DetailLevel detailLevel = SourceMap.DetailLevel.ALL;
@@ -287,12 +288,13 @@ protected RunResult compile(
// Turn on IDE mode to get rid of optimizations.
options.ideMode = true;
- JSSourceFile[] inputs = { JSSourceFile.fromCode(fileName1, js1) };
+ List<SourceFile> inputs =
+ ImmutableList.of(SourceFile.fromCode(fileName1, js1));
if (js2 != null && fileName2 != null) {
- JSSourceFile[] multiple = { JSSourceFile.fromCode(fileName1, js1),
- JSSourceFile.fromCode(fileName2, js2) };
- inputs = multiple;
+ inputs = ImmutableList.of(
+ SourceFile.fromCode(fileName1, js1),
+ SourceFile.fromCode(fileName2, js2));
}
Result result = compiler.compile(EXTERNS, inputs, options);
View
6 test/com/google/javascript/jscomp/CheckMissingReturnTest.java
@@ -191,6 +191,12 @@ public void testMultiConditions() {
testNotMissing("if (a) { return 1} else { while (1) {return 1} }");
}
+ public void testIssue779() {
+ testNotMissing(
+ "var a = f(); try { alert(); if (a > 0) return 1; }" +
+ "finally { a = 5; } return 2;");
+ }
+
private static String createFunction(String returnType, String body) {
return "/** @return {" + returnType + "} */ function foo() {" + body + "}";
}
View
4 test/com/google/javascript/jscomp/ControlFlowAnalysisTest.java
@@ -1104,7 +1104,7 @@ public void testDeepNestedBreakwithFinally() {
// BREAK to FINALLY.
assertCrossEdge(cfg, Token.BREAK, Token.BLOCK, Branch.UNCOND);
// FINALLY to FINALLY.
- assertCrossEdge(cfg, Token.BLOCK, Token.BLOCK, Branch.UNCOND);
+ assertCrossEdge(cfg, Token.BLOCK, Token.BLOCK, Branch.ON_EX);
assertCrossEdge(cfg, Token.WHILE, Token.BLOCK, Branch.ON_FALSE);
assertReturnEdge(cfg, Token.BLOCK);
}
@@ -1115,7 +1115,7 @@ public void testDeepNestedFinally() {
ControlFlowGraph<Node> cfg = createCfg(src);
assertCrossEdge(cfg, Token.THROW, Token.BLOCK, Branch.ON_EX);
assertCrossEdge(cfg, Token.VAR, Token.BLOCK, Branch.UNCOND);
- assertCrossEdge(cfg, Token.IF, Token.BLOCK, Branch.UNCOND);
+ assertCrossEdge(cfg, Token.IF, Token.BLOCK, Branch.ON_EX);
}
public void testReturn() {

No commit comments for this range

Something went wrong with that request. Please try again.