Examples of TypeFactory


Examples of org.eclipse.imp.pdb.facts.type.TypeFactory

  public List<Type> getOptionalQueryParameterTypes() {
    return new ArrayList<Type>();
  }

  protected Type makeOptionalParameterType(Type t) {
    TypeFactory tf = TypeFactory.getInstance();
    TypeStore ts = new TypeStore();

    Type paramType = tf.parameterType("T");
    Type adtType = tf.abstractDataType(ts, "Option", paramType);
    Map<Type,Type> bindings = new HashMap<Type,Type>();
    bindings.put(paramType, t);
    adtType = adtType.instantiate(bindings);

    return adtType;
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.type.TypeFactory

 
  @SuppressWarnings("deprecation")
  M3Converter(final TypeStore typeStore) {
    super(typeStore, true);
    this.DATATYPE_M3_NODE_TYPE = this.typeStore.lookupAbstractDataType(DATATYPE_M3_NODE);
    TypeFactory tf = TypeFactory.getInstance();
    this.CONSTRUCTOR_M3= this.typeStore.lookupConstructor(DATATYPE_M3_NODE_TYPE, "m3", tf.tupleType(tf.sourceLocationType()));
    this.DATATYPE_TYPESYMBOL = this.typeStore.lookupAbstractDataType("TypeSymbol");
    uses = values.relationWriter(m3TupleType);
    declarations = values.relationWriter(m3TupleType);
    containment = values.relationWriter(m3TupleType);
    extendsRelations = values.relationWriter(m3TupleType);
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.type.TypeFactory

    }
    return elems;
  }

  private static IList convertToRealList(double[] l, IValueFactory vf) {
    TypeFactory tf = TypeFactory.getInstance();
    IListWriter writer = vf.listWriter(tf.realType());
    for (int i = 0; i < l.length; i++) {
      writer.append(vf.real(l[i]));
    }
    return writer.done();
  }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.type.TypeFactory

   
    return TypeFactory.getInstance().tupleType(kwTypes, kwLabels);
  }
 
  public void declareConstructor(Data x, Environment env) {
    TypeFactory tf = TypeFactory.getInstance();

    // needs to be done just in case the declaration came
    // from a shell instead of from a module
    Type adt = declareAbstractDataType(x.getUser(), env);

    List<KeywordFormal> common = x.getCommonKeywordParameters().isPresent()
        ? x.getCommonKeywordParameters().getKeywordFormalList()
            : Collections.<KeywordFormal>emptyList();
   
    for (Variant var : x.getVariants()) {
      String altName = Names.name(var.getName());

      Type kwType = tf.voidType();
     
      if (var.isNAryConstructor()) {
        List<KeywordFormal> local = var.getKeywordArguments().hasKeywordFormalList() ? var.getKeywordArguments().getKeywordFormalList() : Collections.<KeywordFormal>emptyList();
        List<KeywordFormal> kws = new ArrayList<>(common.size() + local.size());
       
        if (var.getKeywordArguments().isDefault()) {
          kws.addAll(common);
          kws.addAll(local);
         
          kwType = computeKeywordParametersType(kws, eval);
        }
        else if (!common.isEmpty()) {
          kwType = computeKeywordParametersType(common, eval);
          kws = common;
        }

        List<TypeArg> args = var.getArguments();
        int nAllArgs = args.size();
       
        Type[] fields = new Type[nAllArgs];
        String[] labels = new String[nAllArgs];

        for (int i = 0; i < args.size(); i++) {
          TypeArg arg = args.get(i);
          fields[i] = arg.getType().typeOf(env, true, eval);

          if (fields[i] == null) {
            throw new UndeclaredType(arg.hasName() ? Names.name(arg.getName()) : "?", arg);
          }

          if (arg.hasName()) {
            labels[i] = Names.name(arg.getName());
          } else {
            labels[i] = "arg" + java.lang.Integer.toString(i);
          }
        }
       
        Type children = tf.tupleType(fields, labels);
       
        try {
          ConstructorFunction cons = env.constructorFromTuple(var, eval, adt, altName, children, kwType, kws);
          cons.setPublic(true); // TODO: implement declared visibility
        } catch (org.eclipse.imp.pdb.facts.exceptions.RedeclaredConstructorException e) {
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.type.TypeFactory

    }
    return env.abstractDataType(Names.typeName(name), computeTypeParameters(decl, env));
  }

  private Type[] computeTypeParameters(UserType decl, Environment env) {
    TypeFactory tf = TypeFactory.getInstance();

    Type[] params;
    if (decl.isParametric()) {
      java.util.List<org.rascalmpl.ast.Type> formals = decl
          .getParameters();
      params = new Type[formals.size()];
      int i = 0;
      for (org.rascalmpl.ast.Type formal : formals) {
        if (!formal.isVariable()) {
          throw new SyntaxError(
              "Declaration of parameterized type with type instance "
                  + formal + " is not allowed", formal.getLocation());
        }
        TypeVar var = formal.getTypeVar()
        Type bound = var.hasBound() ? var.getBound().typeOf(env, true, eval) : tf
            .valueType();
        params[i++] = tf
            .parameterType(Names.name(var.getName()), bound);
      }
    } else {
      params = new Type[0];
    }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.type.TypeFactory

    } else {
      for(int j = first; j >= 0 && j > end && j < getValue().arity(); j += increment){
        w.append(getValue().get(j));
      }
    }
    TypeFactory tf = TypeFactory.getInstance();
    return makeResult(tf.listType(tf.valueType()), w.done(), ctx);
  }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.type.TypeFactory

    });
    return sortedData;
  }
 
  public IList getProfileData(){
    TypeFactory TF = TypeFactory.getInstance();
    Type elemType = TF.tupleType(TF.sourceLocationType(), TF.integerType());
    IValueFactory VF = ValueFactoryFactory.getValueFactory();
    IListWriter w = VF.listWriter(elemType);
    for(Map.Entry<ISourceLocation, Count> e : sortData()){
      w.insert(VF.tuple(e.getKey(), VF.integer(e.getValue().getTicks())));
    }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.type.TypeFactory

    super(message);
    this.main = main;
  }
 
  public String help(String command) {
    TypeFactory tf = TypeFactory.getInstance();
    StringBuilder b = new StringBuilder();
   
    b.append("Usage: ");
    b.append(command);
   
    Map<String, IValue> kwargs = main.computeKeywordArgs(new IValue[] {}, Collections.<String,IValue>emptyMap());
   
    if (kwargs.size() > 1) {
      b.append(" [options]\n\nOptions:\n");
   
      for (Entry<String, IValue> param : kwargs.entrySet()) {
        b.append("\t-");
        b.append(param.getKey());
        if (param.getValue().getType().isSubtypeOf(tf.boolType())) {
          b.append("\t[arg]: one of nothing (true), \'1\', \'0\', \'true\' or \'false\';\n");
        }
        else {
          b.append("\t[arg]: " + param.getValue().getType() + " argument;\n");
        }
View Full Code Here

Examples of org.hibernate.type.TypeFactory

  @Override
  public Type getType() throws MappingException {
    // TODO : temporary initial step towards HHH-1907
    final ComponentMetamodel metamodel = new ComponentMetamodel( this );
    final TypeFactory factory = getMappings().getTypeResolver().getTypeFactory();
    return isEmbedded() ? factory.embeddedComponent( metamodel ) : factory.component( metamodel );
  }
View Full Code Here

Examples of org.hibernate.type.TypeFactory

    }
    resolveCollectionElementTypeInformation( attributeBinding.getCollectionElement() );
  }

  private Type determineDefaultCollectionInformation(AbstractPluralAttributeBinding attributeBinding) {
    final TypeFactory typeFactory = metadata.getTypeResolver().getTypeFactory();
    switch ( attributeBinding.getAttribute().getNature() ) {
      case SET: {
        return typeFactory.set(
            attributeBinding.getAttribute().getName(),
            attributeBinding.getReferencedPropertyName()
        );
      }
      case BAG: {
        return typeFactory.bag(
            attributeBinding.getAttribute().getName(),
            attributeBinding.getReferencedPropertyName()
        );
      }
      default: {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.