Exemple #1
0
    public ArgumentLink(VClass toClass, VConstructor con, OtherClassLink otherClassLink) {
      this.toClass = toClass;
      this.otherClassLink = otherClassLink;
      // this.constructor = constructor;

      String str = "to" + toClass.getRealName().replace('.', '_');
      arg = new VArgument(str, str, toClass, false, false, con, this);

      cba = new ConstructorBlockArgs(con, this);

      if (con.getBlock() != null) con.getBlock().addMod(cba);
    }
Exemple #2
0
  public OtherClassLink(VClass forClass, VClass toClass) {
    this.toClass = toClass;
    field =
        new VField(
            "c" + Integer.toString(toClass.hashCode()).replace('-', '_'),
            null,
            toClass,
            Modifier.PUBLIC,
            forClass);

    for (VConstructor con : forClass.constructors) {
      con.addModificator(new ArgumentLink(toClass, con, this));
    }
  }
Exemple #3
0
    public ConstructorBlockArgs(VConstructor constructor, ArgumentLink otherClassLink) {
      this.constructor = constructor;
      this.otherClassLink = otherClassLink;

      /*
      VArgument[] args = constructor.getArguments().stream().filter(e->{
          if (e.getCreator() != null && e.getCreator().getClass() == ArgumentLink.class) {
              ArgumentLink al = (ArgumentLink)e.getCreator();
              if (al.getToClass() == otherClassLink.getToClass())
                  return true;
          }
          return false;
      }).toArray(VArgument[]::new);
      if (args.length != 1)
          throw new RuntimeException("Bad argument count");
          */
      sf =
          new SetField(
              new This(constructor.getParent()),
              otherClassLink.otherClassLink.getField(),
              otherClassLink.getArg(),
              Assign.AsType.ASSIGN,
              null,
              null);
    }
Exemple #4
0
  public static void renaming(VClassLoader loader) {
    String name = loader.getName();
    loader.setName(name.replace('-', '_').replace('.', '$'));

    for (VClass v : loader.classes) {
      if (v.alias == null) v.alias = v.fullName;
      v.fullName =
          v.fullName.replace('.', '_')
              + "_"
              + Long.toString(++classNameIterator, Character.MAX_RADIX);

      for (VField f : v.fields) {
        if (f.alias == null) f.alias = f.name;
        f.name = "f" + Integer.toString(++fieldIterator, Character.MAX_RADIX);
      }

      for (VMethod m : v.methods) {
        if (m.alias == null) m.alias = m.getRunTimeName();
        int argIterator = 0;
        for (VArgument a : m.arguments) {
          a.name = a.name + "_" + Integer.toString(++argIterator, Character.MAX_RADIX);
        }
        if (m.getReplace() == null)
          m.setRuntimeName(
              m.getRunTimeName() + "_" + Long.toString(++methodNameIterator, Character.MAX_RADIX));
      }

      int constructIterator = 0;

      for (VConstructor m : v.constructors) {
        m.setRuntimeName("c" + Integer.toString(++constructIterator, Character.MAX_RADIX));
        int argIterator = 0;
        for (VArgument a : m.arguments) {
          a.name = "a" + Integer.toString(++argIterator, Character.MAX_RADIX);
        }
      }
    }

    for (VClassLoader cl : loader.parents) renaming(cl);
  }