コード例 #1
0
ファイル: OtherClassLink.java プロジェクト: TradeLine/TWT
    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);
    }
コード例 #2
0
ファイル: OtherClassLink.java プロジェクト: TradeLine/TWT
  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));
    }
  }
コード例 #3
0
ファイル: OtherClassLink.java プロジェクト: TradeLine/TWT
    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);
    }
コード例 #4
0
ファイル: CodeGenerator.java プロジェクト: TradeLine/TWT
  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);
  }