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

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


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

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


    return addElement((ElementResult<V>) valueResult);
  }

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

      super(__param1, __param2, __param3, __param4, __param5, __param6);
    }

    @Override
    public Result<IValue> interpret(IEvaluator<Result<IValue>> __eval) {
      Type annoType = getAnnoType().typeOf(__eval.getCurrentEnvt(), true, __eval);
      String name = org.rascalmpl.interpreter.utils.Names.name(this
          .getName());

      Type onType = getOnType().typeOf(__eval.getCurrentEnvt(), true, __eval);
     
      if (onType.isAbstractData() || onType.isConstructor() || onType.isNode()) {
        __eval.getCurrentModuleEnvironment().declareAnnotation(onType,
            name, annoType);
      } else {
        throw new UnsupportedOperation("Can only declare annotations on node and ADT types",getOnType());
      }
View Full Code Here

  public <U extends IValue, V extends IValue> Result<U> fieldUpdate(String name, Result<V> repl, TypeStore store) {
    if (!getType().hasField(name, store) && !getValue().getConstructorType().hasKeywordParameter(name)) {
      throw new UndeclaredField(name, getType(), ctx.getCurrentAST());
    }
   
    Type nodeType = getValue().getConstructorType();
    if (!nodeType.hasField(name) && !nodeType.hasKeywordParameter(name)) {
      throw RuntimeExceptionFactory.noSuchField(name, ctx.getCurrentAST(), null);
    }       
   
    if (nodeType.hasKeywordParameter(name)) {
      Type fieldType = nodeType.getKeywordParameterType(name);
      if (!repl.getType().isSubtypeOf(fieldType)) {
        throw new UnexpectedType(fieldType, repl.getType(), ctx.getCurrentAST());
      }
     
      return makeResult(getType(), getValue().asWithKeywordParameters().setParameter(name, repl.getValue()), ctx);
    }
    else {
      int index = nodeType.getFieldIndex(name);
      Type fieldType = nodeType.getFieldType(index);
      if (!repl.getType().isSubtypeOf(fieldType)) {
        throw new UnexpectedType(fieldType, repl.getType(), ctx.getCurrentAST());
      }

      return makeResult(getType(), getValue().set(index, repl.getValue()), ctx);
View Full Code Here

    }
  }

  @Override
  public <U extends IValue> Result<U> getAnnotation(String annoName, Environment env) {
    Type annoType = env.getAnnotationType(getType(), annoName);
 
    if (annoType == null) {
      throw new UndeclaredAnnotation(annoName, getType(), ctx.getCurrentAST());
    }
 
View Full Code Here

      __eval.setCurrentAST(this);
      __eval.notifyAboutSuspension(this);     

      java.util.List<Mapping_Expression> mappings = this.getMappings();
      java.util.Map<IValue, IValue> result = new HashMap<IValue, IValue>();
      Type keyType = TF.voidType();
      Type valueType = TF.voidType();

      for (Mapping_Expression mapping : mappings) {
        Result<IValue> keyResult = mapping.getFrom().interpret(__eval);
        Result<IValue> valueResult = mapping.getTo().interpret(__eval);

        if (keyResult.getType().isBottom()) {
          throw new NonVoidTypeRequired(mapping.getFrom());
        }

        if (valueResult.getType().isBottom()) {
          throw new NonVoidTypeRequired(mapping.getTo());
        }

        keyType = keyType.lub(keyResult.getType());
        valueType = valueType.lub(valueResult.getType());

        IValue keyValue = result.get(keyResult.getValue());
        if (keyValue != null) {
          throw org.rascalmpl.interpreter.utils.RuntimeExceptionFactory
              .MultipleKey(keyValue, mapping.getFrom(), __eval
                  .getStackTrace());
        }

        result.put(keyResult.getValue(), valueResult.getValue());
      }

      Type type = TF.mapType(keyType, valueType);
      IMapWriter w = __eval.__getVf().mapWriter();
      w.putAll(result);

      return org.rascalmpl.interpreter.result.ResultFactory.makeResult(
          type, w.done(), __eval);
View Full Code Here

    return new ConstructorCursor(constructor.set(label, focus), ctx);
  }

  @Override
  public IList toPath(IValueFactory vf) {
    Type type = constructor.getConstructorType();
    return ctx.toPath(vf).append(vf.constructor(Cursor.Nav_argumentPosition,
        vf.integer(type.getFieldIndex(label))));
  }
View Full Code Here

    if (anonymous) {
      return declaredType;
    }
   
    if(patternVars != null && patternVars.containsKey(name)){
      Type ot = patternVars.get(name).getType();
      if(ot.compareTo(declaredType) < 0)
          declaredType = ot;
    }
    return declaredType;
  }
View Full Code Here

  }
 
  @Override
  public Type getType(Environment env, HashMap<String,IVarPattern> patternVars) {
    if (type == null) {
      Type fieldTypes[] = new Type[children.size()];
      for(int i = 0; i < children.size(); i++){
        fieldTypes[i] = children.get(i).getType(env, patternVars);
        patternVars = merge(patternVars, children.get(i).getVariables());
      }
      type = tf.tupleType(fieldTypes);
View Full Code Here

    @Override
    public IMatchingResult buildMatcher(IEvaluatorContext eval) {
      org.rascalmpl.ast.Expression arg = this.getArgument();
      if (arg.hasType() && arg.hasName()) {
        Environment env = eval.getCurrentEnvt();
        Type type = arg.getType().typeOf(env, true, eval.getEvaluator());
        type = type.instantiate(env.getTypeBindings());
       
        // TODO: Question, should we allow non terminal types in splices?
        if (type instanceof NonTerminalType) {
          throw new UnsupportedOperation("splicing match", type, this);
//          throw new ImplementationError(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.