Debian Codegraph @

src/com/google/javascript/jscomp/PassFactory.java

raw symbols SCIP
1 /*
2 * Copyright 2009 The Closure Compiler Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.google.javascript.jscomp;
18
19 /**
20 * A factory for creating JSCompiler passes based on the Options
21 * injected. Contains all meta-data about compiler passes (like
22 * whether it can be run multiple times, a human-readable name for
23 * logging, etc.).
24 *
25 * @author [email protected] (Nick Santos)
26 */
27 public abstract class PassFactory {
28
29 private final String name;
30 private final boolean isOneTimePass;
31
32 /**
33 * @param name The name of the pass that this factory creates.
34 * @param isOneTimePass If true, the pass produced by this factory can
35 * only be run once.
36 */
37 protected PassFactory(String name, boolean isOneTimePass) {
38 this.name = name;
39 this.isOneTimePass = isOneTimePass;
40 }
41
42 /**
43 * @return The name of this pass.
44 */
45 String getName() {
46 return name;
47 }
48
49 /**
50 * @return Whether the pass produced by this factory can only be run once.
51 */
52 boolean isOneTimePass() {
53 return isOneTimePass;
54 }
55
56 /**
57 * Creates a new compiler pass to be run.
58 */
59 abstract CompilerPass create(AbstractCompiler compiler);
60
61 /**
62 * Any factory whose CompilerPass has a corresponding hot-swap version should
63 * override this.
64 *
65 * @param compiler The compiler that can has been used to do the full compile.
66 */
67 HotSwapCompilerPass getHotSwapPass(AbstractCompiler compiler) {
68 // TODO(bashir): If in future most of PassFactory's in DefaultPassConfig
69 // turns out to be DefaultPassConfig.HotSwapPassFactory, we should probably
70 // change the implementation here by the one in HotSwapPassFactory.
71 return null;
72 }
73 }