Beispiel #1
0
  @Override
  public void add(CompileCommand compileCommand) {
    isFileValid &= compileCommand.isValid();
    MethodDescriptor methodDescriptor = compileCommand.methodDescriptor;

    switch (compileCommand.command) {
      case INLINE:
      case DONTINLINE:
        inlines.add(compileCommand);
        break;
    }
    for (MethodDescriptor md : matchBlocks.keySet()) {
      if (methodDescriptor.getCanonicalString().matches(md.getRegexp())) {
        matchBlocks.get(md).add(compileCommand);
      }
    }
    if (!matchBlocks.containsKey(compileCommand.methodDescriptor)) {
      List<CompileCommand> commands = new ArrayList<>();
      commands.add(compileCommand);
      matchBlocks.put(compileCommand.methodDescriptor, commands);
    }
  }
Beispiel #2
0
  private State getState(Pair<Executable, Callable<?>> pair) {
    State state = null;
    MethodDescriptor execDesc = MethodGenerator.commandDescriptor(pair.first);
    boolean isMatchFound = false;

    if (stateMap.containsKey(pair.first)) {
      state = stateMap.get(pair.first);
    }
    for (MethodDescriptor matchDesc : matchBlocks.keySet()) {
      if (execDesc.getCanonicalString().matches(matchDesc.getRegexp())) {
        /*
         * if executable matches regex
         * then apply commands from this match to the state
         */
        for (CompileCommand cc : matchBlocks.get(matchDesc)) {
          if (state == null) {
            state = new State();
          }
          if (!isMatchFound) {
            // this is a first found match, apply all commands
            state.apply(cc);
          } else {
            // apply only inline directives
            switch (cc.command) {
              case INLINE:
              case DONTINLINE:
                state.apply(cc);
                break;
            }
          }
        }
        isMatchFound = true;
      }
    }
    return state;
  }