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

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


  }
 
  public static void main(String[] args) {
    RandomValueTypeVisitor r = new RandomValueTypeVisitor(ValueFactoryFactory.getValueFactory(), 3, null, null);
   
      Type intType = r.tf.integerType();
     
    System.out.println(r.generate(r.tf.setType(intType)));
  }
View Full Code Here


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

    IValueFactory vf = VF;
    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

    }

  }
 
  private void executeTimerAction(IConstructor timerAction){
    Type type = timerAction.getConstructorType();
    if(type == TimerAction_noChange){
      if(hidden){
        if(t !=null){
          int newDelay = (int)(t.delay - elapsedAtHide);
          t = new ExecuteTimer(newDelay);
View Full Code Here

 
  private IValue fixupTypeOfNodeValues(IValue input) {
    return input.accept(new IValueVisitor<IValue, RuntimeException>() {

      private Type calcLub(Iterable<? extends IValue> e) {
        Type elemType = tf.voidType();
        for (IValue v : e) {
          elemType = elemType.lub(v.getType());
        }
        return elemType;
      }

      @Override
View Full Code Here

    List l = (List)stack.peek();
    String name = (String)l.get(0);
    int arity = ((Double)l.get(1)).intValue();

    Set<Type> ctors = ts.lookupConstructor(type, name);
    Type ctor = null;
    for (Type t: ctors) {
      if (t.getArity() == arity) {
        ctor = t;
        break;
      }
    }
   
    if (ctor == null) {
      throw new IOException("no constructor " + name + "/" + arity+ " in " + type);
    }
   
    List argsList = (List) l.get(2);
 
    IValue[] args = new IValue[arity];
    for (int i = 0; i < arity; i++) {
      stack.push(argsList.get(i));
      args[i] = read(ctor.getFieldType(i));
      stack.pop();
    }

    Map<String, IValue> kwargs = null;
    if (ctor.hasKeywordParameters() && l.size() > 3) {
      kwargs = new HashMap<>();
      Map kw = (Map)l.get(3);
      for (Object k: kw.keySet()) {
        String label = (String)k;
        Type kwType = ctor.getKeywordParameterType(label);
        stack.push(kw.get(label));
        kwargs.put(label, read(kwType));
        stack.pop();
      }
    }
View Full Code Here

      super(__param1, __param2, __param3);
    }

    @Override
    public Type typeOf(Environment env, boolean instantiateTypeParameters, IEvaluator<Result<IValue>> eval) {
      Type adt;
      QualifiedName sort = this.getSort();
      String name = org.rascalmpl.interpreter.utils.Names.typeName(sort);

      if (org.rascalmpl.interpreter.utils.Names.isQualified(sort)) {
        GlobalEnvironment heap = env.getHeap();
View Full Code Here

       
        seen.add(large);
       
        for (Type alt : env.lookupAlternatives(large)) {
          for (int i = 0; i < alt.getArity(); i++) {
            Type fType = alt.getFieldType(i);
            if (seen.add(fType) && mayOccurIn(small, fType, seen, env)) {
              return true;
            }
          }
        }
View Full Code Here

   * @param input      Input text as char array
   * @param stacktrace   Stacktrace of calling context
   * @return
   */
  public IValue parse(IString moduleName, IValue start, IMap robust, URI location, char[] input, List<Frame> stacktrace) {
    Type reified = start.getType();
    IConstructor startSort = checkPreconditions(start, reified);
   
    IMap syntax = (IMap) ((IConstructor) start).get(1);
    try {
      IConstructor pt = parseObject(moduleName, startSort, robust, location, input, syntax);
View Full Code Here

  private static IConstructor checkPreconditions(IValue start, Type reified) {
    if (!(reified instanceof ReifiedType)) {
       throw RascalRuntimeException.illegalArgument(start, null, "A reified type is required instead of " + reified);
    }
   
    Type nt = reified.getTypeParameters().getFieldType(0);
   
    if (!(nt instanceof NonTerminalType)) {
      throw RascalRuntimeException.illegalArgument(start, null, "A non-terminal type is required instead of  " + nt);
    }
   
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.