Ejemplo n.º 1
0
  public static OtherClassLink getOrCreate(VClass forClass, VClass toClass) {
    Optional<ClassModificator> cm =
        forClass.getModificator(
            e -> {
              if (e instanceof OtherClassLink) {
                OtherClassLink m = (OtherClassLink) e;
                if (m.toClass == toClass) return true;
              }
              return false;
            });

    if (cm.isPresent()) return (OtherClassLink) cm.get();

    OtherClassLink ocl = new OtherClassLink(forClass, toClass);
    forClass.addMod(ocl);
    return ocl;
  }
Ejemplo n.º 2
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);
    }
Ejemplo n.º 3
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);
  }
Ejemplo n.º 4
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));
    }
  }