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

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


    spine.push(v);
    spine.push(children);
  }
 
  private void push(IValue v){
    Type type = v.getType();
    if(type.isNode() || type.isConstructor() || type.isAbstractData()){
      if(interpretTree && (type.isConstructor() || type.isAbstractData()) && type == Factory.Tree){
        pushConcreteSyntaxNode((IConstructor) v);
        return;
      }
      push(v,  ((INode) v).getChildren().iterator());
    } else
    if(type.isList()){
      push(v, ((IList) v).iterator());
    } else
    if(type.isSet()){
      push(v, ((ISet) v).iterator());
    } else
    if(type.isMap()){
      push(v, new MapKeyValueIterator((IMap) v));
    } else
    if(type.isTuple()){
      push(v, new TupleElementIterator((ITuple) v));
    } else {
      spine.push(v);
    }
  }
View Full Code Here


        if (r.getValue() != null) {
          // Previously declared and initialized variable
          return new QualifiedNamePattern(eval, this, name);
        }

        Type type = r.getType();
        if (type instanceof NonTerminalType) {
          NonTerminalType cType = (NonTerminalType) type;
          if (cType.isConcreteListType()) {
            return new ConcreteListVariablePattern(eval, this, type, ((Default) name).lastName());
          }
View Full Code Here

    }

    // isSubtypeOf does not know about concrete syntax types
    // so deal with it here explicitly
    if (declaredType instanceof NonTerminalType) {
      Type subjectType = subject.getValue().getType();
      if (subjectType.isSubtypeOf(Factory.Tree) && ((IConstructor)subject.getValue()).getConstructorType() == Factory.Tree_Appl) {
        IConstructor tree = (IConstructor)subject.getValue();

        NonTerminalType nt = (NonTerminalType)declaredType;
       
        IConstructor declaredSymbol = nt.getSymbol();
        Type subjectNT = RascalTypeFactory.getInstance().nonTerminalType(tree);
       
        if(subjectNT.isSubtypeOf(nt)) {
          if(TreeAdapter.isList(tree)) {
            if(TreeAdapter.getArgs(tree).isEmpty()) {
              if(SymbolAdapter.isIterPlus(declaredSymbol|| (SymbolAdapter.isIterPlusSeps(declaredSymbol))) {
                return false;
              }
            }
          }

          if(anonymous) {
            return true;
          }   

          ctx.getCurrentEnvt().declareAndStoreInferredInnerScopeVariable(name, ResultFactory.makeResult(declaredType, subject.getValue(), ctx));
          this.alreadyStored = true;
          return true;
        }
      }
      return false;
    }

    Type tmp;
    if (subject.getValue().getType().isSubtypeOf(declaredType)) {
      if(debug)System.err.println("matches");
     
      try {
        // type checking code for formal parameters; the static type of the actual should be a sub-type of the type of the formal
View Full Code Here

    Set<FunctionType> types = new HashSet<FunctionType>();
    for(int fun : this.functions) {
      types.add((FunctionType) functionStore.get(fun).ftype);
    }
    for(int constr : this.constructors) {
      Type type = constructorStore.get(constr);
      types.add((FunctionType) RascalTypeFactory.getInstance().functionType(type.getAbstractDataType(), type.getFieldTypes(), type.getKeywordParameterTypes()));
    }
    this.type = RascalTypeFactory.getInstance().overloadedFunctionType(types);
    return this.type;
  }
View Full Code Here

  static final int[] modifiersSWT = {SWT.CTRL, SWT.COMMAND, SWT.ALT, SWT.SHIFT };
 
  public static IMap toRascalModifiers(int stateMask,IMap prevMap,IEvaluatorContext ctx){
    IValueFactory vf = ValueFactoryFactory.getValueFactory();
    for(int i = 0 ; i < modifiers.length ;i++){
      Type controlType = modifiers[i];
      IValue cons = vf.constructor(controlType);
      prevMap = prevMap.put(cons, vf.bool((stateMask & modifiersSWT[i]) != 0));
    }
    return prevMap;
  }
View Full Code Here

    IValueFactory vf = ValueFactoryFactory.getValueFactory();
    if(e.keyCode >= ' ' && e.keyCode < '~'){
      String keySym = "" + (char)e.keyCode;
      return vf.constructor(KeySym_keyPrintable, vf.string(keySym));
    } else {
      Type cons = unPrintableKeyName(e);
      if(cons == KeySym_keyUnknown){
        return vf.constructor(KeySym_keyUnknown,vf.integer(e.keyCode));
      } else {
        return vf.constructor(cons);
      }
View Full Code Here

   * @param declaration the declaration of that function
   * @param rvm in which function will be loaded
   */
  private void loadInstructions(String name, IConstructor declaration, RVM rvm, boolean isCoroutine){
 
    Type ftype = isCoroutine ? null : rvm.symbolToType((IConstructor) declaration.get("ftype"));
   
    //System.err.println("loadInstructions: " + name + ": ftype = " + ftype + ", declaration = " + declaration);
   
    String scopeIn = ((IString) declaration.get("scopeIn")).getValue();
    if(scopeIn.equals("")) {
View Full Code Here

    RandomValueTypeVisitor visitor = descend();

    LinkedList<IValue> values = new LinkedList<IValue>();
    for (int i = 0; i < type.getArity(); i++) {
      Type fieldType = type.getFieldType(i);
      IValue argument = visitor.generate(fieldType);
      if (argument == null) {
        return null;
        /*
         * Het is onmogelijk om de constructor te bouwen als ������n
View Full Code Here

  }

  @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

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.