예제 #1
0
 public LabelReferences(Delegator delegator, LabelManagerFactory factory) {
   this.delegator = delegator;
   this.labels = factory.getLabels();
   DelegatorElement delegatorInfo = null;
   try {
     delegatorInfo = EntityConfigUtil.getDelegator(delegator.getDelegatorBaseName());
   } catch (GenericEntityConfException e) {
     Debug.logWarning(e, "Exception thrown while getting delegator config: ", module);
   }
   String modelName;
   if (delegatorInfo != null) {
     modelName = delegatorInfo.getEntityModelReader();
   } else {
     modelName = "main";
   }
   // since we do not associate a dispatcher to this DispatchContext, it is important to set a name
   // of an existing entity model reader:
   // in this way it will be possible to retrieve the service models from the cache
   this.dispatchContext = new DispatchContext(modelName, this.getClass().getClassLoader(), null);
   Collection<LabelInfo> infoList = this.labels.values();
   for (LabelInfo labelInfo : infoList) {
     this.labelSet.add(labelInfo.getLabelKey());
   }
   Collection<ComponentConfig> componentConfigs = ComponentConfig.getAllComponents();
   for (ComponentConfig config : componentConfigs) {
     String rootFolder = config.getRootLocation();
     rootFolder = rootFolder.replace('\\', '/');
     if (!rootFolder.endsWith("/")) {
       rootFolder = rootFolder + "/";
     }
     this.rootFolders.add(rootFolder);
   }
 }
예제 #2
0
 @Override
 public void visitLabel(final Label label) {
   if (first) {
     LabelInfo.setTarget(label);
   }
   if (successor) {
     LabelInfo.setSuccessor(label);
   }
 }
예제 #3
0
 private void visitSwitchInsn(final Label dflt, final Label[] labels) {
   LabelInfo.resetDone(dflt);
   LabelInfo.resetDone(labels);
   setTargetIfNotDone(dflt);
   for (final Label l : labels) {
     setTargetIfNotDone(l);
   }
   successor = false;
   first = false;
 }
예제 #4
0
  @Override
  public void visitTryCatchBlock(
      final Label start, final Label end, final Label handler, final String type) {
    // Enforce probe at the beginning of the block. Assuming the start of
    // the block already is successor of some other code, adding a target
    // makes the start a multitarget. However, if the start of the block
    // also is the start of the method, no probe will be added.
    LabelInfo.setTarget(start);

    // Mark exception handler as possible target of the block
    LabelInfo.setTarget(handler);
  }
예제 #5
0
 @Override
 public void visitJumpInsn(final int opcode, final Label label) {
   LabelInfo.setTarget(label);
   if (opcode == Opcodes.JSR) {
     throw new AssertionError("Subroutines not supported.");
   }
   successor = opcode != Opcodes.GOTO;
   first = false;
 }
 /**
  * Rename label references in breaks and continues.
  *
  * @param node The break or continue node.
  */
 private void visitBreakOrContinue(Node node) {
   Node nameNode = node.getFirstChild();
   if (nameNode != null) {
     // This is a named break or continue;
     String name = nameNode.getString();
     Preconditions.checkState(!name.isEmpty());
     LabelInfo li = getLabelInfo(name);
     if (li != null) {
       String newName = getNameForId(li.id);
       // Mark the label as referenced so it isn't removed.
       li.referenced = true;
       if (!name.equals(newName)) {
         // Give it the short name.
         nameNode.setString(newName);
         compiler.reportCodeChange();
       }
     }
   }
 }
예제 #7
0
 private static void setTargetIfNotDone(final Label label) {
   if (!LabelInfo.isDone(label)) {
     LabelInfo.setTarget(label);
     LabelInfo.setDone(label);
   }
 }