Exemplo n.º 1
0
  // make a property args from the this accessor sig and kind
  public FuncInfo propertySig(final String accessorName) {
    FuncInfo fi = null;
    if (accessorName.equals("set")) {

      // remove the last argument from the set accessor

      Debug.Assert(
          +_paramTypes.length > 0,
          "a set accessor must have at least one argument (the value arg)");

      fi = new FuncInfo(this); // copy
      final int numPropArgs = _paramTypes.length - 1;

      final TypeSpec[] pTypes = new TypeSpec[numPropArgs];
      for (int i = 0; i < numPropArgs; i++) {
        pTypes[i] = _paramTypes[i];
      }

      final String[] pNames = new String[numPropArgs];
      for (int i = 0; i < numPropArgs; i++) {
        pNames[i] = _paramNames[i];
      }

      final Object[] pDefaults = new Object[numPropArgs];
      for (int i = 0; i < numPropArgs; i++) {
        pDefaults[i] = _paramDefaults[i];
      }

      final boolean[] pHasDefault = new boolean[numPropArgs];
      for (int i = 0; i < numPropArgs; i++) {
        pHasDefault[i] = _paramHasDefault[i];
      }

      fi._paramNames = pNames;
      fi._paramTypes = pTypes;
      fi._paramDefaults = pDefaults;
      fi._paramHasDefault = pHasDefault;
    } else if (accessorName.equals("get")) {
      // property args are the same as the get accessor args, no change
      fi = new FuncInfo(this); // copy
    } else {
      Debug.Assert(false, "invalid accessor kind name (should be 'get' or 'set'");
    }
    return fi;
  }
Exemplo n.º 2
0
  // make a property accessor signature from this property args and the
  // property type
  public FuncInfo accessorSig(final String accessorName, final TypeSpec propertyType) {
    FuncInfo fi = null;
    if (accessorName.equals("set")) { // add the propertyType as an extra
      // parameter named 'value'
      fi = new FuncInfo();
      final int numPropArgs = _paramTypes.length;

      final TypeSpec[] pTypes = new TypeSpec[numPropArgs + 1];
      for (int i = 0; i < numPropArgs; i++) {
        pTypes[i] = _paramTypes[i];
      }
      pTypes[numPropArgs] = propertyType;

      final String[] pNames = new String[numPropArgs + 1];
      for (int i = 0; i < numPropArgs; i++) {
        pNames[i] = _paramNames[i];
      }
      pNames[numPropArgs] = "value";

      final Object[] pDefaults = new Object[numPropArgs + 1];
      for (int i = 0; i < numPropArgs; i++) {
        pDefaults[i] = _paramDefaults[i];
      }
      pDefaults[numPropArgs] = null;

      final boolean[] pHasDefault = new boolean[numPropArgs + 1];
      for (int i = 0; i < numPropArgs; i++) {
        pHasDefault[i] = _paramHasDefault[i];
      }
      pHasDefault[numPropArgs] = false;

      fi._paramNames = pNames;
      fi._paramTypes = pTypes;
      fi._paramDefaults = pDefaults;
      fi._paramHasDefault = pHasDefault;
    } else if (accessorName.equals("get")) { // set the returnType to the
      // propertyType
      fi = new FuncInfo(this);
      fi._returnType = propertyType;
    } else {
      Debug.Assert(false, "invalid accessor kind name (should be 'get' or 'set'");
    }
    return fi;
  }