Пример #1
0
  /**
   * Liest die Argumente eines Funktonsaufruf ein und prft ob die Funktion innerhalb der FLD
   * (Function Library Descriptor) definiert ist. Falls sie existiert wird die Funktion gegen diese
   * geprft und ein build-in-function CFXD Element generiert, ansonsten ein normales funcion-call
   * Element. <br>
   * EBNF:<br>
   * <code>[impOp{"," impOp}];</code>
   *
   * @param name Identifier der Funktion als Zeichenkette
   * @param checkLibrary Soll geprft werden ob die Funktion innerhalb der Library existiert.
   * @param flf FLD Function definition .
   * @return CFXD Element
   * @throws PageException
   */
  private Ref[] functionArg(String name, boolean checkLibrary, FunctionLibFunction flf, char end)
      throws PageException {

    // get Function Library
    checkLibrary = checkLibrary && flf != null;

    // Function Attributes
    ArrayList arr = new ArrayList();

    ArrayList arrFuncLibAtt = null;
    int libLen = 0;
    if (checkLibrary) {
      arrFuncLibAtt = flf.getArg();
      libLen = arrFuncLibAtt.size();
    }
    int count = 0;
    do {
      cfml.next();
      cfml.removeSpace();

      // finish
      if (cfml.isCurrent(end)) break;

      // too many Attributes
      boolean isDynamic = false;
      int max = -1;
      if (checkLibrary) {
        isDynamic = isDynamic(flf);
        max = flf.getArgMax();
        // Dynamic
        if (isDynamic) {
          if (max != -1 && max <= count)
            throw new ExpressionException("too many Attributes in function [" + name + "]");
        }
        // Fix
        else {
          if (libLen <= count)
            throw new ExpressionException("too many Attributes in function [" + name + "]");
        }
      }

      if (checkLibrary && !isDynamic) {
        // current attribues from library
        FunctionLibFunctionArg funcLibAtt = (FunctionLibFunctionArg) arrFuncLibAtt.get(count);
        short type = CFTypes.toShort(funcLibAtt.getType(), CFTypes.TYPE_UNKNOW);
        if (type == CFTypes.TYPE_VARIABLE_STRING) {
          arr.add(functionArgDeclarationVarString());
        } else {
          arr.add(new Casting(pc, funcLibAtt.getTypeAsString(), type, functionArgDeclaration()));
        }
      } else {
        arr.add(functionArgDeclaration());
      }

      // obj=andOrXor();
      cfml.removeSpace();
      count++;
    } while (cfml.isCurrent(','));

    // end with ) ??
    if (!cfml.forwardIfCurrent(end)) {
      if (name.startsWith("_json"))
        throw new ExpressionException("Invalid Syntax Closing [" + end + "] not found");
      throw new ExpressionException(
          "Invalid Syntax Closing [" + end + "] for function [" + name + "] not found");
    }

    // check min attributes
    if (checkLibrary && flf.getArgMin() > count)
      throw new ExpressionException("to less Attributes in function [" + name + "]");

    cfml.removeSpace();
    return (Ref[]) arr.toArray(new Ref[arr.size()]);
  }
Пример #2
0
 /** @see railo.runtime.type.UDF#getReturnType() */
 public int getReturnType() {
   return CFTypes.toShortStrict(getReturnTypeAsString(), CFTypes.TYPE_UNKNOW);
 }