コード例 #1
0
  @Override
  public boolean visit(final CFGNode node, final Element element) {
    final LinkedList<Pair<XMLPattern, SimpleAutomatonID>> matchings =
        new LinkedList<Pair<XMLPattern, SimpleAutomatonID>>();
    for (XMLPattern pattern : getXMLAutomatonDefinition().getXMLpatterns()) {
      final Pair<Boolean, XMLPatternVariablesAssignment> matchResult =
          pattern.matchesNode(node, aliasResolver);
      if (matchResult.getFirst()) {
        final XMLPatternVariablesAssignment assign = matchResult.getSecond();
        final boolean isGlobal = isGlobalAssignement(assign);
        matchings.add(Pair.make(pattern, new SimpleAutomatonID(assign, isGlobal)));
      }
    }

    if (matchings.size() > 1) checkMatchingConflict(element, matchings);

    if (!matchings.isEmpty()) {
      final PatternLocation newLocation = createCommonPatternLocation(node, matchings);
      getNodeLocationDictionary().put(node, Pair.make(newLocation, newLocation));
      if (matchings.getFirst().getFirst().isConstructive())
        getAutomataIDs().add(matchings.getFirst().getSecond());
    } else if (getNavigator().isCallNode(node)) {
      final PatternLocation callLocation = createRuleLessPatternLocation(node);
      final PatternLocation returnLocation = createRuleLessPatternLocation(node);
      getNodeLocationDictionary().put(node, Pair.make(callLocation, returnLocation));
      callLocation.setLocationForCallNotPassedStates(returnLocation);
    }

    return true;
  }
コード例 #2
0
  private void createStartEndPatternLocations() {
    final PatternLocation startLocation = createRuleLessPatternLocation(getCfg().getStartNode());
    getNodeLocationDictionary()
        .put(getCfg().getStartNode(), Pair.make(startLocation, startLocation));

    final PatternLocation endLocation = createRuleLessPatternLocation(getCfg().getEndNode());
    getNodeLocationDictionary().put(getCfg().getEndNode(), Pair.make(endLocation, endLocation));
  }