private Object debug(ProceedingJoinPoint pjp, MethodTimeDebugger timeDebugger) throws Throwable {
   if (!timeDebugger.value()) {
     return pjp.proceed();
   }
   String type = timeDebugger.type();
   StringBuffer msg = new StringBuffer();
   msg.append(type + "[")
       .append(pjp.getTarget().getClass().getName())
       .append(".")
       .append(getMethod(pjp.getSignature()).getName())
       .append("(..)");
   ExecutionStack.push(msg.toString());
   Object result = pjp.proceed();
   ExecutionStack.pop(msg.toString());
   return result;
 }
Пример #2
0
  public Function parse() {
    int start = cursor;

    int startCond = 0;
    int endCond = 0;

    int blockStart;
    int blockEnd;

    int end = cursor + length;

    cursor = ParseTools.captureToNextTokenJunction(expr, cursor, end, pCtx);

    if (expr[cursor = ParseTools.nextNonBlank(expr, cursor)] == '(') {
      /**
       * If we discover an opening bracket after the function name, we check to see if this function
       * accepts parameters.
       */
      endCond =
          cursor = balancedCaptureWithLineAccounting(expr, startCond = cursor, end, '(', pCtx);
      startCond++;
      cursor++;

      cursor = ParseTools.skipWhitespace(expr, cursor, pCtx);

      if (cursor >= end) {
        throw new CompileException("incomplete statement", expr, cursor);
      } else if (expr[cursor] == '{') {
        blockEnd =
            cursor = balancedCaptureWithLineAccounting(expr, blockStart = cursor, end, '{', pCtx);
      } else {
        blockStart = cursor - 1;
        cursor = ParseTools.captureToEOS(expr, cursor, end, pCtx);
        blockEnd = cursor;
      }
    } else {
      /** This function has not parameters. */
      if (expr[cursor] == '{') {
        /** This function is bracketed. We capture the entire range in the brackets. */
        blockEnd =
            cursor = balancedCaptureWithLineAccounting(expr, blockStart = cursor, end, '{', pCtx);
      } else {
        /** This is a single statement function declaration. We only capture the statement. */
        blockStart = cursor - 1;
        cursor = ParseTools.captureToEOS(expr, cursor, end, pCtx);
        blockEnd = cursor;
      }
    }

    /** Trim any whitespace from the captured block range. */
    blockStart = ParseTools.trimRight(expr, start, blockStart + 1);
    blockEnd = ParseTools.trimLeft(expr, start, blockEnd);

    cursor++;

    /** Check if the function is manually terminated. */
    if (splitAccumulator != null && ParseTools.isStatementNotManuallyTerminated(expr, cursor)) {
      /** Add an EndOfStatement to the split accumulator in the parser. */
      splitAccumulator.add(new EndOfStatement());
    }

    /** Produce the funciton node. */
    return new Function(
        name,
        expr,
        startCond,
        endCond - startCond,
        blockStart,
        blockEnd - blockStart,
        fields,
        pCtx == null ? pCtx = AbstractParser.getCurrentThreadParserContext() : pCtx);
  }