Examples of IList


Examples of org.eclipse.imp.pdb.facts.IList

         */
        rvm.executeProgram(uid_module_init, arguments);

        IListWriter w = vf.listWriter();
        for(String uid_testsuite: testsuites){
          IList test_results = (IList)rvm.executeProgram(uid_testsuite, arguments);
          w.insertAll(test_results);
        }
        result = w.done();
      } else {
        /*
 
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

   
    Integer nlocals = ((IInteger) declaration.get("nlocals")).intValue();
    IMap localNames = ((IMap) declaration.get("localNames"));
    Integer nformals = ((IInteger) declaration.get("nformals")).intValue();
    Integer maxstack = ((IInteger) declaration.get("maxStack")).intValue();
    IList code = (IList) declaration.get("instructions");
    ISourceLocation src = (ISourceLocation) declaration.get("src");
    CodeBlock codeblock = new CodeBlock(vf);
    // Loading instructions
    try {
    for (int i = 0; i < code.length(); i++) {
      IConstructor instruction = (IConstructor) code.get(i);
      String opcode = instruction.getName();

      switch (opcode) {
      case "LOADCON":
        codeblock.LOADCON(instruction.get("val"));
        break;

      case "LOADVAR":
        codeblock.LOADVAR(getStrField(instruction, "fuid"),
                  getIntField(instruction, "pos"));
        break;

      case "LOADLOC":
        codeblock.LOADLOC(getIntField(instruction, "pos"));
        break;
       
      case "LOADCONT":
        codeblock.LOADCONT(getStrField(instruction, "fuid"));
        break;

      case "STOREVAR":
        codeblock.STOREVAR(getStrField(instruction, "fuid"),
                   getIntField(instruction, "pos"));
        break;

      case "STORELOC":
        codeblock.STORELOC(getIntField(instruction, "pos"));
        break;

      case "LABEL":
        codeblock = codeblock.LABEL(getStrField(instruction, "label"));
        break;

      case "CALLPRIM":
        codeblock.CALLPRIM(RascalPrimitive.valueOf(getStrField(instruction, "name")),
                   getIntField(instruction, "arity"),
                   getLocField(instruction, "src"));
        break;

      case "CALLMUPRIM":
        codeblock.CALLMUPRIM(MuPrimitive.valueOf(getStrField(instruction, "name")),
                   getIntField(instruction, "arity"));
        break;

      case "CALL":
        codeblock.CALL(getStrField(instruction, "fuid"), getIntField(instruction, "arity"));
        break;

      case "CALLDYN":
        codeblock.CALLDYN( getIntField(instruction, "arity"));
        break;
       
      case "APPLY":
        codeblock.APPLY(getStrField(instruction, "fuid"),
                getIntField(instruction, "arity"));
        break;
       
      case "APPLYDYN":
        codeblock.APPLYDYN(getIntField(instruction, "arity"));
        break;

      case "LOADFUN":
        codeblock.LOADFUN(getStrField(instruction, "fuid"));
        break;

      case "RETURN0":
        codeblock.RETURN0();
        break;

      case "RETURN1":
        codeblock.RETURN1(getIntField(instruction, "arity"));
        break;

      case "JMP":
        codeblock.JMP(getStrField(instruction, "label"));
        break;

      case "JMPTRUE":
        codeblock.JMPTRUE(getStrField(instruction, "label"));
        break;

      case "JMPFALSE":
        codeblock.JMPFALSE(getStrField(instruction, "label"));
        break;

      case "HALT":
        codeblock.HALT();
        break;
       
      case "CREATE":
        codeblock.CREATE(getStrField(instruction, "fuid"),
                 getIntField(instruction, "arity"));
        break;

      case "CREATEDYN":
        codeblock.CREATEDYN(getIntField(instruction, "arity"));
        break;
       
      case "RESET":
        codeblock.RESET();
        break;

      case "NEXT0":
        codeblock.NEXT0();
        break;

      case "NEXT1":
        codeblock.NEXT1();
        break;

      case "YIELD0":
        codeblock.YIELD0();
        break;

      case "YIELD1":
        codeblock.YIELD1(getIntField(instruction, "arity"));
        break;
       
      case "SHIFT":
        codeblock.SHIFT();
        break;

      case "PRINTLN":
        codeblock.PRINTLN(getIntField(instruction, "arity"));
        break;

      case "POP":
        codeblock.POP();
        break;

      case "LOADLOCREF":
        codeblock.LOADLOCREF(getIntField(instruction, "pos"));
        break;

      case "LOADVARREF":
        codeblock.LOADVARREF(getStrField(instruction, "fuid"),
                   getIntField(instruction, "pos"));
        break;

      case "LOADLOCDEREF":
        codeblock.LOADLOCDEREF(getIntField(instruction, "pos"));
        break;

      case "LOADVARDEREF":
        codeblock.LOADVARDEREF(getStrField(instruction, "fuid"),
                     getIntField(instruction, "pos"));
        break;

      case "STORELOCDEREF":
        codeblock.STORELOCDEREF(getIntField(instruction, "pos"));
        break;

      case "STOREVARDEREF":
        codeblock.STOREVARDEREF(getStrField(instruction, "fuid"),
                    getIntField(instruction, "pos"));
        break;

      case "LOAD_NESTED_FUN":
        codeblock.LOADNESTEDFUN(getStrField(instruction, "fuid"),
                    getStrField(instruction, "scopeIn"));
        break;

      case "LOADCONSTR":
        codeblock.LOADCONSTR(getStrField(instruction, "fuid"));
        break;

      case "CALLCONSTR":
        codeblock.CALLCONSTR(getStrField(instruction, "fuid"),
                   getIntField(instruction, "arity")/*, getLocField(instruction, "src")*/);
        break;

      case "LOADTYPE":
        codeblock.LOADTYPE(rvm.symbolToType((IConstructor) instruction.get("type")));
        break;
      case "LOADBOOL":
        codeblock.LOADBOOL(getBooleanField(instruction, "bval"));
        break;

      case "LOADINT":
        codeblock.LOADINT(getIntField(instruction, "nval"));
        break;

      case "FAILRETURN":
        codeblock.FAILRETURN();
        break;

      case "LOADOFUN" :
        codeblock.LOADOFUN(getStrField(instruction, "fuid"));
        break;

      case "OCALL" :
        codeblock.OCALL(getStrField(instruction, "fuid"),
                getIntField(instruction, "arity"),
                getLocField(instruction, "src"));
        break;

      case "OCALLDYN" :
        codeblock.OCALLDYN(rvm.symbolToType((IConstructor) instruction.get("types")),
                   getIntField(instruction, "arity"),
                   getLocField(instruction, "src"));
        break;

      case "CALLJAVA":
        codeblock.CALLJAVA(getStrField(instruction, "name"),
                       getStrField(instruction, "class"),
                    rvm.symbolToType((IConstructor) instruction.get("parameterTypes")),
                    rvm.symbolToType((IConstructor) instruction.get("keywordTypes")),
                    getIntField(instruction, "reflect"));
        break;

      case "THROW":
        codeblock.THROW(getLocField(instruction, "src"));
        break;
     
      case "TYPESWITCH":
        codeblock.TYPESWITCH((IList)instruction.get("labels"));
        break;
       
      case "UNWRAPTHROWNLOC":
        codeblock.UNWRAPTHROWNLOC(getIntField(instruction, "pos"));
        break;
       
      case "FILTERRETURN":
        codeblock.FILTERRETURN();
        break;
       
      case "EXHAUST":
        codeblock.EXHAUST();
        break;
       
      case "GUARD":
        codeblock.GUARD();
        break;
       
      case "SUBSCRIPTARRAY":
        codeblock.SUBSCRIPTARRAY();
        break;
       
      case "SUBSCRIPTLIST":
        codeblock.SUBSCRIPTLIST();
        break;
       
      case "LESSINT":
        codeblock.LESSINT();
        break;
       
      case "GREATEREQUALINT":
        codeblock.GREATEREQUALINT();
        break;
       
      case "ADDINT":
        codeblock.ADDINT();
        break;
       
      case "SUBTRACTINT":
        codeblock.SUBTRACTINT();
        break;
       
      case "ANDBOOL":
        codeblock.ANDBOOL();
        break;
       
      case "TYPEOF":
        codeblock.TYPEOF();
        break;
       
      case "SUBTYPE":
        codeblock.SUBTYPE();
        break;
       
      case "CHECKARGTYPE":
        codeblock.CHECKARGTYPE();
        break;
       
      case "JMPINDEXED":
        codeblock.JMPINDEXED((IList)instruction.get("labels"));
        break;
       
      case "LOADLOCKWP":
        codeblock.LOADLOCKWP(getStrField(instruction, "name"));
        break;
       
      case "LOADVARKWP":
        codeblock.LOADVARKWP(getStrField(instruction, "fuid"),
                   getStrField(instruction, "name"));
        break;
       
      case "STORELOCKWP":
        codeblock.STORELOCKWP(getStrField(instruction, "name"));
        break;
       
      case "STOREVARKWP":
        codeblock.STOREVARKWP(getStrField(instruction, "fuid"),
                    getStrField(instruction, "name"));
        break;
       
      case "UNWRAPTHROWNVAR":
        codeblock.UNWRAPTHROWNVAR(getStrField(instruction, "fuid"),
                        getIntField(instruction, "pos"));
        break;
       
      default:
        throw new CompilerError("In function " + name + ", nknown instruction: " + opcode);
      }

    }
    } catch (Exception e){
      throw new CompilerError("In function " + name + " : " + e.getMessage());
    }
   
    Function function = new Function(name, ftype, scopeIn, nformals, nlocals, localNames, maxstack, codeblock, src);
    if(isCoroutine) {
      function.isCoroutine = true;
      IList refList = (IList) declaration.get("refs");
      int[] refs = new int[refList.length()];
      int i = 0;
      for(IValue ref : refList) {
        refs[i++] = ((IInteger) ref).intValue();
      }
      function.refs = refs;
    } else {
      IList exceptions = (IList) declaration.get("exceptions");
      function.attachExceptionTable(exceptions, rvm);
      boolean isVarArgs = ((IBool) declaration.get("isVarArgs")).getValue();
      function.isVarArgs = isVarArgs;
    }
    rvm.declare(function);
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

  public void initElem(IFigureConstructionEnv env, MouseOver mparent, boolean swtSeen, boolean visible, NameResolver resolver){
    if(innerFig != null){
      innerFig.destroy(env);
    }
    TypeFactory tf = TypeFactory.getInstance();
    IList originalsL = VF.list(originals.toArray(tmpArray));
    IConstructor figureCons = (IConstructor) env.getCallBackEnv().executeRascalCallBackSingleArgument(whole,tf.listType(tf.valueType()),originalsL).getValue();
    innerFig = FigureFactory.make(env, figureCons, prop, childProps);
    innerFig.registerIds(env, resolver);
    innerFig.registerConverts(resolver);
    setInnerFig( innerFig);
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

    int i = 0;
   
    for (IValue prod : robust) {
      robustProds[i] = (IConstructor) prod;
      List<Integer> chars = new LinkedList<Integer>();
      IList ranges = (IList) robust.get(prod);
     
      for (IValue range : ranges) {
        int from = ((IInteger) ((IConstructor) range).get("begin")).intValue();
        int to = ((IInteger) ((IConstructor) range).get("end")).intValue();
       
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

//        return tree.asAnnotatable().setAnnotation("can not parse fragment due to " + e.getMessage(), src);
//      }
    }
   
    private char[] replaceAntiQuotesByHoles(IConstructor lit, Map<String, IConstructor> antiquotes) {
      IList parts = TreeAdapter.getArgs(lit);
      StringBuilder b = new StringBuilder();
     
      for (IValue elem : parts) {
        IConstructor part = (IConstructor) elem;
        String cons = TreeAdapter.getConstructorName(part);
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

        @Override
        public IConstructor visitTreeAppl(IConstructor tree)  {
          String cons = TreeAdapter.getConstructorName(tree);
          if (cons == null || !cons.equals("$MetaHole") ) {
            IListWriter w = vf.listWriter();
            IList args = TreeAdapter.getArgs(tree);
            for (IValue elem : args) {
              w.append(elem.accept(this));
            }
            args = w.done();
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

    if (g != null)
      s += (File.separator + g.getValue());
    InputStreamReader a = new InputStreamReader(getClass()
        .getResourceAsStream(s));
    try {
      IList r = readLines(a);
      // System.out.println(r);
      return r;
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

  public IValue getRascalFileContent(ISourceLocation g) {
    FileReader a = null;
    try {
      a = new FileReader(g.getURI().getPath());
      IList r = readLines(a, "`", "\"", "\"", "\\\\\"", "<", "\\\\<",
          ">", "\\\\>");
      // System.out.println(((IString) r.get(0)).getValue());
      return r.get(0);
    } catch (FileNotFoundException fnfex) {
      throw RuntimeExceptionFactory.pathNotFound(g, null, null);
    } catch (IOException ioex) {
      throw RuntimeExceptionFactory.io(values.string(ioex.getMessage()),
          null, null);
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

      Result<IValue> value = stat.interpret(__eval);
      if (!value.getType().isList()) {
        throw new ImplementationError(
            "template eval returns non-list");
      }
      IList list = (IList) value.getValue();
      if (list.length() == 0) {
        System.out.println("bla");
      }

      if (!list.get(0).getType().isString()) {
        throw new ImplementationError(
            "template eval returns list with non-string");
      }
     
      return ResultFactory.makeResult(TF.stringType(), list.get(0), __eval);
     
//      // todo: concat not needed anymore, because of appendString in Accumulator.
//      // list is always non-empty
//      Result<IValue> s = ResultFactory.makeResult(TF.stringType(),
//          list.get(0), __eval);
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IList

    return RascalTypeFactory.getInstance().functionType(returnType, parameters, tf.voidType());
  }

  private Type consToType(IConstructor symbol, TypeStore store) {
    Type adt = symbolToType((IConstructor) symbol.get("adt"), store);
    IList parameters = (IList) symbol.get("parameters");
    String name = ((IString) symbol.get("name")).getValue();
    Type tupleType = symbolsToTupleType(parameters, store);
    Type t = tf.constructorFromTuple(store, adt, name, tupleType);
    return t;
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.