コード例 #1
1
 private void initializeExplicitConstructor(
     TurinTypeContructorDefinitionNode constructor, SymbolResolver resolver) {
   List<? extends FormalParameter> allParams = constructor.getParameters();
   List<FormalParameter> paramsWithoutDefaultValues =
       allParams
           .stream()
           .filter((p) -> !p.hasDefaultValue())
           .collect(Collectors.<FormalParameter>toList());
   List<String> paramSignatures =
       paramsWithoutDefaultValues
           .stream()
           .map((p) -> p.getType().jvmType().getSignature())
           .collect(Collectors.toList());
   boolean hasDefaultParameters =
       allParams.stream().filter((p) -> p.hasDefaultValue()).findFirst().isPresent();
   if (hasDefaultParameters) {
     paramSignatures.add("Ljava/util/Map;");
   }
   JvmConstructorDefinition constructorDefinition =
       new JvmConstructorDefinition(
           jvmType().getInternalName(), "(" + String.join("", paramSignatures) + ")V");
   constructors.add(
       new InternalConstructorDefinition(
           new ReferenceTypeUsage(this), allParams, constructorDefinition));
 }
コード例 #2
0
 public List<TurinTypeContructorDefinitionNode> getExplicitConstructors() {
   return members
       .stream()
       .filter((m) -> m instanceof TurinTypeContructorDefinitionNode)
       .map((m) -> (TurinTypeContructorDefinitionNode) m)
       .collect(Collectors.toList());
 }
コード例 #3
0
  @Override
  public JvmConstructorDefinition resolveConstructorCall(List<ActualParam> actualParams) {
    // all named parameters should be after the named ones
    if (!ParamUtils.verifyOrder(actualParams)) {
      throw new IllegalArgumentException(
          "Named params should all be grouped after the positional ones");
    }

    ensureIsInitialized(symbolResolver());
    Optional<InternalConstructorDefinition> constructor =
        constructors.stream().filter((c) -> c.match(symbolResolver(), actualParams)).findFirst();

    if (!constructor.isPresent()) {
      throw new UnsolvedConstructorException(getQualifiedName(), actualParams);
    }

    return constructor.get().getJvmConstructorDefinition();
  }
コード例 #4
0
 private boolean isDefiningMethod(
     String name, List<TypeUsage> paramTypes, SymbolResolver resolver) {
   return getDirectMethods()
           .stream()
           .filter((m) -> m.getName().equals(name))
           .filter(
               (m) ->
                   m.getParameters()
                       .stream()
                       .map((p) -> p.calcType().jvmType())
                       .collect(Collectors.toList())
                       .equals(
                           paramTypes
                               .stream()
                               .map((p) -> p.jvmType())
                               .collect(Collectors.toList())))
           .count()
       > 0;
 }