Package org.eclipse.imp.pdb.facts.type

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


  @Override
  protected <U extends IValue> Result<U> addTuple(TupleResult that) {
    // Note reversed args
    TupleResult left = that;
    TupleResult right = this;
    Type leftType = left.getType();
    Type rightType = right.getType();
   
    int leftArity = leftType.getArity();
    int rightArity = rightType.getArity();
    int newArity = leftArity + rightArity;
   
    Type fieldTypes[] = new Type[newArity];
    String fieldNames[] = new String[newArity];
    IValue fieldValues[] = new IValue[newArity];
   
    boolean consistentLabels = true;
    for(int i = 0; i < leftArity; i++){
      fieldTypes[i] = leftType.getFieldType(i);
      fieldNames[i] = leftType.getFieldName(i);
      fieldValues[i] = left.getValue().get(i);
      consistentLabels = fieldNames[i] != null;
    }
   
    for(int i = 0; i < rightArity; i++){
      fieldTypes[leftArity + i] = rightType.getFieldType(i);
      fieldNames[leftArity + i] = rightType.getFieldName(i);
      fieldValues[leftArity + i] = right.getValue().get(i);
      consistentLabels = fieldNames[i] != null;
      if (consistentLabels) {
        for (int j = 0; j < leftArity; j++) {
          if (fieldNames[j].equals(fieldNames[i])) {
            // duplicate field name, so degenerate to unlabeled tuple
            consistentLabels = false;
          }
        }
      }
    }
   
    Type newTupleType;
    if (consistentLabels) {
      newTupleType = getTypeFactory().tupleType(fieldTypes, fieldNames);
    }
    else {
      newTupleType = getTypeFactory().tupleType(fieldTypes);
View Full Code Here


   
    Map<Type,Type> bindings = new HashMap<Type,Type>();
    if (!constructorType.getFieldTypes().match(TF.tupleType(actualTypes), bindings)) {
      throw new MatchFailed();
    }
    Type formalTypeParameters = constructorType.getAbstractDataType().getTypeParameters();
    Type instantiated = constructorType;

    if (!formalTypeParameters.isBottom()) {
      for (Type field : formalTypeParameters) {
        if (!bindings.containsKey(field)) {
          bindings.put(field, TF.voidType());
View Full Code Here

      }
      return o;
    }

    private boolean isParseTreeNode(INode node){
      Type tp = node.getType();
      return tp.isSubtypeOf(Factory.Tree) || tp.isSubtypeOf(Factory.Production) || tp.isSubtypeOf(Factory.Attributes||
           tp.isSubtypeOf(Factory.Attr) || tp.isSubtypeOf(Factory.Associativity) || tp.isSubtypeOf(Factory.Symbol) ||
           tp.isSubtypeOf(Factory.Symbol) || tp.isSubtypeOf(Factory.CharRange|| tp.isSubtypeOf(Factory.Condition) ;
    }
View Full Code Here

    return makeResult(getType().lub(s.getType()), s.getValue().subtract(getValue()), ctx);
  }

  @Override
  protected <U extends IValue> Result<U> multiplyListRelation(ListRelationResult that) {
    Type tupleType = getTypeFactory().tupleType(that.type.getElementType(), type.getElementType());
    // Note the reverse in .product
    return makeResult(getTypeFactory().lrelTypeFromTuple(tupleType), that.getValue().product(getValue()), ctx);
  }
View Full Code Here

    return makeResult(getTypeFactory().lrelTypeFromTuple(tupleType), that.getValue().product(getValue()), ctx);
  }

  @Override
  protected <U extends IValue> Result<U> multiplyList(ListResult s) {
    Type tupleType = getTypeFactory().tupleType(s.type.getElementType(), type.getElementType());
    // Note the reverse in .product
    return makeResult(getTypeFactory().lrelTypeFromTuple(tupleType), s.getValue().product(getValue()), ctx);
  }
View Full Code Here

    return makeResult(type.lub(s.type), s.getValue().intersect(getValue()), ctx);
  }

  @Override
  protected <U extends IValue, V extends IValue> Result<U> insertElement(Result<V> that) {
    Type newType = getTypeFactory().listType(that.getType().lub(getType().getElementType()));
    return makeResult(newType, value.insert(that.getValue()), ctx);
  }
View Full Code Here

    return makeResult(newType, value.insert(that.getValue()), ctx);
  }

  protected <U extends IValue, V extends IValue> Result<U> addElement(
      ElementResult<V> that) {
    Type newType = getTypeFactory().listType(that.getType().lub(getType().getElementType()));
    return makeResult(newType, getValue().append(that.getValue()), ctx);
  }
View Full Code Here

          moduleName);
      Result<IValue> simpleVariable = env.getSimpleVariable(variableName);
      if (simpleVariable == null)
        return false;
      for (String vt : variableType) {
        Type tp = getType(env, vt);
        if (tp == null)
          continue;
        if (simpleVariable.getType().equivalent(tp))
          return true;
      }
View Full Code Here

    try {
      evaluator.doImport(null, moduleName);
      ModuleEnvironment env = evaluator.getCurrentEnvt().getImport(
          moduleName);
      ArrayList<AbstractFunction> funcs = new ArrayList<AbstractFunction>();
      Type typ = getType(env, procedureResultType);
      if (typ == null)
        return false;
      env.getAllFunctions(typ, procedureName, funcs);
      for (AbstractFunction f : funcs) {
        if (f.getArity() == arity) {
View Full Code Here

      evaluator.unwind(old);
    }
  }

  private Type getType(ModuleEnvironment m, String typeString) {
    Type t = toType.get(typeString);
    if (t != null)
      return t;
    TypeStore ts = m.getStore();
    t = ts.lookupAlias(typeString);
    if (t != null)
View Full Code Here

TOP

Related Classes of org.eclipse.imp.pdb.facts.type.Type

Copyright © 2018 www.massapicom. 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.