Esempio n. 1
0
  public void getArgs(Code code, Class<?>[] parameters) throws Exception {
    if (parameters.length == 0) {
      code.getstatic("org/python/core/Py", "EmptyObjects", $pyObjArr);
    } else {
      code.iconst(parameters.length);
      code.anewarray("java/lang/Object");

      int array = code.getLocal("[org/python/core/PyObject");
      code.astore(array);

      int local_index;
      int i;
      for (i = 0, local_index = 1; i < parameters.length; i++) {
        code.aload(array);
        code.iconst(i);

        switch (getType(parameters[i])) {
          case tBoolean:
          case tByte:
          case tShort:
          case tInteger:
            code.iload(local_index);
            local_index += 1;
            code.invokestatic("org/python/core/Py", "newInteger", "(I)" + $pyInteger);
            break;
          case tLong:
            code.lload(local_index);
            local_index += 2;
            code.invokestatic("org/python/core/Py", "newInteger", "(J)" + $pyObj);
            break;
          case tFloat:
            code.fload(local_index);
            local_index += 1;
            code.invokestatic("org/python/core/Py", "newFloat", "(F)" + $pyFloat);
            break;
          case tDouble:
            code.dload(local_index);
            local_index += 2;
            code.invokestatic("org/python/core/Py", "newFloat", "(D)" + $pyFloat);
            break;
          case tCharacter:
            code.iload(local_index);
            local_index += 1;
            code.invokestatic("org/python/core/Py", "newString", "(C)" + $pyStr);
            break;
          default:
            code.aload(local_index);
            local_index += 1;
            break;
        }
        code.aastore();
      }
      code.aload(array);
    }
  }
Esempio n. 2
0
  public void callSuper(
      Code code, String name, String superclass, Class<?>[] parameters, Class<?> ret, String sig)
      throws Exception {

    code.aload(0);
    int local_index;
    int i;
    for (i = 0, local_index = 1; i < parameters.length; i++) {
      switch (getType(parameters[i])) {
        case tCharacter:
        case tBoolean:
        case tByte:
        case tShort:
        case tInteger:
          code.iload(local_index);
          local_index += 1;
          break;
        case tLong:
          code.lload(local_index);
          local_index += 2;
          break;
        case tFloat:
          code.fload(local_index);
          local_index += 1;
          break;
        case tDouble:
          code.dload(local_index);
          local_index += 2;
          break;
        default:
          code.aload(local_index);
          local_index += 1;
          break;
      }
    }
    code.invokespecial(superclass, name, sig);

    doReturn(code, ret);
  }