Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2008 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;
import com.google.gwt.dev.jjs.InternalCompilerException;
import com.google.gwt.dev.jjs.SourceInfo;
import com.google.gwt.dev.jjs.SourceOrigin;
import com.google.gwt.dev.jjs.ast.Context;
import com.google.gwt.dev.jjs.ast.JBlock;
import com.google.gwt.dev.jjs.ast.JCaseStatement;
import com.google.gwt.dev.jjs.ast.JClassType;
import com.google.gwt.dev.jjs.ast.JDeclaredType;
import com.google.gwt.dev.jjs.ast.JExpression;
import com.google.gwt.dev.jjs.ast.JGwtCreate;
import com.google.gwt.dev.jjs.ast.JMethod;
import com.google.gwt.dev.jjs.ast.JMethodBody;
import com.google.gwt.dev.jjs.ast.JMethodCall;
import com.google.gwt.dev.jjs.ast.JModVisitor;
import com.google.gwt.dev.jjs.ast.JProgram;
import com.google.gwt.dev.jjs.ast.JReboundEntryPoint;
import com.google.gwt.dev.jjs.ast.JReferenceType;
import com.google.gwt.dev.jjs.ast.JReturnStatement;
import com.google.gwt.dev.jjs.ast.JSwitchStatement;
import com.google.gwt.dev.jjs.ast.JType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* Replaces any "GWT.create()" calls with a new expression for the actual result
* of the deferred binding decision.
*/
public class ResolveRebinds {
private class RebindVisitor extends JModVisitor {
@Override
public void endVisit(JGwtCreate x, Context ctx) {
if (isSoftRebind(x.getSourceType())) {
JMethod method = rebindMethod(x.getSourceType(), x.getResultTypes(),
x.getInstantiationExpressions());
JMethodCall call = new JMethodCall(x.getSourceInfo(), null, method);
ctx.replaceMe(call);
return;
}
JClassType rebindResult = rebind(x.getSourceType());
List rebindResults = x.getResultTypes();
for (int i = 0; i < rebindResults.size(); ++i) {
// Find the matching rebound type.
if (rebindResult == rebindResults.get(i)) {
// Replace with the associated instantiation expression.
ctx.replaceMe(x.getInstantiationExpressions().get(i));
return;
}
}
throw new InternalCompilerException(
"No matching rebind result in all rebind results!");
}
@Override
public void endVisit(JReboundEntryPoint x, Context ctx) {
if (isSoftRebind(x.getSourceType())) {
JMethod method = rebindMethod(x.getSourceType(), x.getResultTypes(),
x.getEntryCalls());
JMethodCall call = new JMethodCall(x.getSourceInfo(), null, method);
ctx.replaceMe(call.makeStatement());
return;
}
JClassType rebindResult = rebind(x.getSourceType());
List rebindResults = x.getResultTypes();
for (int i = 0; i < rebindResults.size(); ++i) {
// Find the matching rebound type.
if (rebindResult == rebindResults.get(i)) {
// Replace with the associated instantiation expression.
ctx.replaceMe(x.getEntryCalls().get(i).makeStatement());
return;
}
}
throw new InternalCompilerException(
"No matching rebind result in all rebind results!");
}
}
public static boolean exec(JProgram program,
Map[] orderedRebindAnswers) {
return new ResolveRebinds(program, orderedRebindAnswers).execImpl();
}
/**
* Returns the rebind answers that do not vary across various maps of rebind
* answers.
*/
public static Map getHardRebindAnswers(
Map[] rebindAnswers) {
Iterator