com.google.gwt.dev.jjs.impl.codesplitter.LivenessPredicate Maven / Gradle / Ivy
/*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.dev.jjs.impl.codesplitter;
import com.google.gwt.dev.jjs.ast.JDeclaredType;
import com.google.gwt.dev.jjs.ast.JField;
import com.google.gwt.dev.jjs.ast.JMethod;
/**
*
* A predicate on whether statements and variables should be considered live.
*
*
* Any supplied predicate must satisfy load-order dependencies. For any atom
* considered live, the atoms it depends on at load time should also be live.
* The following load-order dependencies exist:
*
*
* - A class literal depends on the strings contained in its instantiation
* instruction.
*
* - Types depend on their supertype.
*
* - Instance methods depend on their enclosing type.
*
* - Static fields that are initialized to strings depend on the string they
* are initialized to.
*
*/
public interface LivenessPredicate {
/**
* Subclasses should return true if {@code type} is deemed live and false otherwise.
*/
boolean isLive(JDeclaredType type);
/**
* Subclasses should return true if {@code field} is deemed live and false otherwise.
*/
boolean isLive(JField field);
/**
* Subclasses should return true if {@code method} is deemed live and false otherwise.
*/
boolean isLive(JMethod method);
/**
* Whether miscellaneous statements should be considered live.
* Miscellaneous statements are any that the fragment extractor does not
* recognize as being in any particular category. This method should almost
* always return true
, but does return false
for
* {@link NothingAlivePredicate}.
*/
boolean miscellaneousStatementsAreLive();
}