Ejemplo 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);
    }
  }
Ejemplo n.º 2
0
 public void getstatic(String c, String name, String type) throws IOException {
   getstatic(pool.Fieldref(c, name, type));
 }
Ejemplo n.º 3
0
 public void print(String s) throws IOException {
   getstatic("java/lang/System", "out", "Ljava/io/PrintStream;");
   ldc(s);
   invokevirtual("java/io/PrintStream", "println", "(Ljava/lang/String;)V");
 }