Ejemplo n.º 1
0
  /**
   * Resolves arguments, creates local variables and fills the vars and overlists
   *
   * @param c
   * @return list of arguments
   */
  protected final GeoElement[] resArgsForZip(Command c) {
    // check if there is a local variable in arguments
    int numArgs = c.getArgumentNumber();
    vars = new GeoElement[numArgs / 2];
    over = new GeoList[numArgs / 2];
    Construction cmdCons = (Construction) c.getKernel().getConstruction();

    for (int varPos = 1; varPos < numArgs; varPos += 2) {
      String localVarName = c.getVariableName(varPos);
      if (localVarName == null) {
        throw argErr(app, c.getName(), c.getArgument(varPos));
      }

      // add local variable name to construction

      GeoElement num = null;

      // initialize first value of local numeric variable from initPos

      boolean oldval = cons.isSuppressLabelsActive();
      cons.setSuppressLabelCreation(true);
      GeoList gl = (GeoList) resArg(c.getArgument(varPos + 1))[0];
      cons.setSuppressLabelCreation(oldval);
      num = gl.get(0).copyInternal(cons);

      cmdCons.addLocalVariable(localVarName, num);
      // set local variable as our varPos argument
      c.setArgument(varPos, new ExpressionNode(c.getKernel(), num));
      vars[varPos / 2] = num.toGeoElement();
      over[varPos / 2] = gl;
      // resolve all command arguments including the local variable just
      // created

      // remove local variable name from kernel again

    }
    GeoElement[] arg = resArgs(c);
    for (GeoElement localVar : vars) cmdCons.removeLocalVariable(localVar.getLabel());
    return arg;
  }