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

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


  }

  @Override
  public IValue visitParameter(Type parameterType) {
    // FIXME Type parameters binden aan echte type van actual value in call.
    Type type = typeParameters.get(parameterType);
    if(type == null){
      throw new IllegalArgumentException("Unbound type parameter " + parameterType);
    }
    return this.generate(type);
  }
View Full Code Here


  public IValue visitTuple(Type type) {
    RandomValueTypeVisitor visitor = descend();

    IValue[] elems = new IValue[type.getArity()];
    for (int i = 0; i < type.getArity(); i++) {
      Type fieldType = type.getFieldType(i);
      IValue element = visitor.generate(fieldType);
      if (element == null) {
        return null;
      }
      elems[i] = visitor.generate(fieldType);
View Full Code Here

    @Override
    public Type typeOf(Environment env, boolean instantiateTypeParameters, IEvaluator<Result<IValue>> eval) {
      RascalTypeFactory RTF = org.rascalmpl.interpreter.types.RascalTypeFactory
          .getInstance();
      Parameters parameters = getParameters();
      Type kwParams = TF.voidType();

      if (parameters.hasKeywordFormals() && parameters.getKeywordFormals().hasKeywordFormalList()) {
        List<KeywordFormal> kwd = parameters.getKeywordFormals().getKeywordFormalList();
        kwParams = TypeDeclarationEvaluator.computeKeywordParametersType(kwd, eval);
      }
View Full Code Here

    @Override
    public Type typeOf(Environment env, boolean instantiateTypeParameters, IEvaluator<Result<IValue>> eval) {
      RascalTypeFactory RTF = RascalTypeFactory.getInstance();

      Type kwParams = TF.voidType();

      Parameters parameters = getParameters();

      if (parameters.hasKeywordFormals() && parameters.getKeywordFormals().hasKeywordFormalList()) {
        List<KeywordFormal> kwd = parameters.getKeywordFormals().getKeywordFormalList();
View Full Code Here

  public boolean isTreeConstructorName(QualifiedName name, Type signature) {
    java.util.List<Name> names = name.getNames();
   
    if (names.size() > 1) {
      String sort = Names.sortName(name);
      Type sortType = getAbstractDataType(sort);
     
      if (sortType != null) {
        String cons = Names.consName(name);
       
        if (getConstructor(sortType, cons, signature) != null) {
View Full Code Here

    return typeStore.lookupAbstractDataType(name);
  }
 
  @Override
  public Type lookupConcreteSyntaxType(String name) {
    Type type = concreteSyntaxTypes.get(name);
   
    if (type == null) {
      for (String i : getImports()) {
        ModuleEnvironment mod = getImport(i);
       
View Full Code Here

 
  @Override
  public Result<IValue> fieldSelect(Field[] selectedFields) {
    int nFields = selectedFields.length;
    int fieldIndices[] = new int[nFields];
    Type baseType = this.getType();
   
    for (int i = 0; i < nFields; i++) {
      Field f = selectedFields[i];
      if (f.isIndex()) {
        fieldIndices[i] = ((IInteger) f.getFieldIndex()
            .interpret(this.ctx.getEvaluator()).getValue()).intValue();
      } else {
        String fieldName = org.rascalmpl.interpreter.utils.Names
            .name(f.getFieldName());
        try {
          fieldIndices[i] = baseType.getFieldIndex(fieldName);
        } catch (UndeclaredFieldException e) {
          throw new UndeclaredField(fieldName, baseType,
              ctx.getCurrentAST());
        }
      }

      if (fieldIndices[i] < 0 || fieldIndices[i] > baseType.getArity()) {
        throw org.rascalmpl.interpreter.utils.RuntimeExceptionFactory
            .indexOutOfBounds(ValueFactoryFactory.getValueFactory().integer(fieldIndices[i]),
                ctx.getCurrentAST(), ctx.getStackTrace());
      }
    }
View Full Code Here

        throw new UndeclaredField(name, getType(), ctx.getCurrentAST());
      }
     
      try {
        int index = getType().getFieldIndex(name);
        Type type = getType().getFieldType(index);
        return makeResult(type, getValue().get(index), ctx);
      }
      catch (UndeclaredFieldException e){
        throw new UndeclaredField(name, getType(), ctx.getCurrentAST());
      }
View Full Code Here

      throw new UndeclaredField(name, getType(), ctx.getCurrentAST());
    }

    try {
      int index = getType().getFieldIndex(name);
      Type type = getType().getFieldType(index);
      if(!type.isSubtypeOf(repl.getType())){
        throw new UnexpectedType(type, repl.getType(), ctx.getCurrentAST());
      }
      return makeResult(getType(), getValue().set(index, repl.getValue()), ctx);
    } catch (UndeclaredFieldException e) {
      throw new UndeclaredField(name, getType(), ctx.getCurrentAST());
View Full Code Here

    }
    if ( (idx >= getValue().arity()) || (idx < 0)) {
      throw RuntimeExceptionFactory.indexOutOfBounds(index, ctx.getCurrentAST(), ctx.getStackTrace());
    }
   
    Type elementType = getType().getFieldType(idx);
    IValue element = getValue().get(idx);
    return makeResult(elementType, element, ctx);
  }
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.